Module 2: Consuming Data from an API

Module Overview

A powerful way to enhance a web application is by connecting it to an API. These Application Programming Interfaces accept requests and return results, similar to the servers you build with Flask. What makes APIs powerful is the breadth of data they provide—from tweets to weather to space imagery to Pokémon—enabling your applications to leverage rich, real-world information.

Learning Objectives

Guided Project

Open guided-project.md in the GitHub repository to follow along with the guided project.

Due to recent changes in the accessibility of the Twitter API, you will no longer need to request Twitter API keys. Please refer to the information below for instructions.

Twitter is changing their API policies and tweepy is going offline very soon. In its place, we have implemented a Twitter-API-like clone and an API interface library to bridge the gap. We named the Twitter API "NotTwitter" and the library "NotTweepy".

To install NotTweepy, copy the folder not_tweepy into your local repo at the root level of your project.

  • Project
    • twitoff
    • not_tweepy

You will find the folder in the GitHub repository for the Unit here.

You may follow the instructions in this Guided Project video with the only exception:

When you see:

import tweepy

You will instead type:

import not_tweepy as tweepy

NotTwitter has been prepopulated with tweets from the following users:

  • calebhicks
  • elonmusk
  • rrherr
  • SteveMartinToGo
  • alyankovic
  • NASA
  • jkhowland
  • Austen
  • common_squirrel
  • KenJennings
  • ConanOBrien
  • big_ben_clock
  • IAM_SHAKESPEARE

Module Assignment

Ensure you can access the Twitter API and SpaCy package, then write methods to pull real Users and Tweets, replacing invented data with actual Twitter data, and add a tweet_vect field to your Tweet model using SpaCy embeddings.

Assignment Solution Video

Additional Resources

Current Tools

Background Reading