Sign in
Log inSign up

Request data from Twitter API in json using Python

anuj tyagi's photo
anuj tyagi
·Oct 15, 2016

Anyone used twitter REST API to GET/POST data ? I am using python requests module.. need help.

Initially starting with GET. it should go like this... after adding keys and username :

import requests

url = 'api.twitter.com/1.1/account/verify_credent…
auth = OAuth1(API_KEY, API_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SECRET)
requests.get(url, auth=auth)

r = requests.get('api.twitter.com/1.1/statuses/user_timeline…<username>&count=10', auth=auth)
for tweet in r.json():
  print tweet['text']

It's not working for me. Also, what if I don't want to use any third party module like twitter. Just by importing modules like request and json.