This is a brief introduction to commonly used apis
1, What is API
An application programming interface, or so-called API, is a computing interface that defines interactions between multiple software intermediaries. It defines the kinds of calls or requests that can be made, how to make them, the data formats that should be used, the conventions to follow, etc.
In short, API is where you can get data.
2, Commonly used APIs
- stock data: Quandl API
e.g. https://www.quandl.com/api/v3/datatables/WIKI/PRICES.csv?ticker=AAPL&api_key=YOURAPIKEY
Documentation:
# notice that yourkey is put in the request
$ curl "https://www.quandl.com/api/v3/datasets/WIKI/FB/data.json?api_key=YOURAPIKEY"
- movie data: OMDb API
Documentation:
- house data: Zillow
Documentation:
- vedio data: youtube API
e.g. https://www.youtube.com/watch?v=
Documentation:
# how to establish
from googleapiclient.discovery import build
YOUTUBE_API_SERVICE_NAME = "youtube"
YOUTUBE_API_VERSION = "v3"
DEVELOPER_KEY = your_key_hereyoutube = build(YOUTUBE_API_SERVICE_NAME, YOUTUBE_API_VERSION, developerKey=DEVELOPER_KEY)# get youtube list
search_response = youtube.search().list(
q=QUERY,
part=PART,
maxResults=NUMBER).execute()# get youtube vedio comment
comments = youtube.commentThreads().list(
part=PART,
videoId= VIDEOID,
textFormat="plainText",
maxResults=NUMBER).execute()
- twitter data: twitter development API
Documentation:
# how to establish
import tweepy
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
api = tweepy.API(auth)# get user's info
user = api.get_user('realdonaldtrump')# get user's timeline
tweets = api.user_timeline('realdonaldtrump', count=100)# get user's follower or friend
friends = api.friends('realdonaldtrump', count=100)