GitHub - geduldig/TwitterAPI: Minimal python wrapper for Twitter's REST and Streaming APIs | Latest TMZ Celebrity News & Gossip | Watch TMZ Live
Skip to content

geduldig/TwitterAPI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LOGO

TwitterAPI is a minimal python wrapper for the TwitterAPIs. A list of what it can do:

  • Support for all V1.1 and V2 endpoints, plus Premium, Ads, Labs, Collections.
  • OAuth1 and bearer token authentication, and proxy server authentication.
  • Streaming endpoints.
  • Paging results.
  • The option to "hydrate" results returned by V2 endpoints.
  • Error handling.

Installation

> pip install TwitterAPI

Twitter API Version 1.1 Code Snippets

[More examples in TwitterAPI/examples/v1.1]

Search for recent tweets

from TwitterAPI import TwitterAPI
api = TwitterAPI(consumer_key, consumer_secret, access_token_key, access_token_secret)
r = api.request('search/tweets', {'q':'pizza'})
for item in r:
        print(item)

Stream tweets from New York City as they get tweeted

r = api.request('statuses/filter', {'locations':'-74,40,-73,41'})
for item in r:
        print(item)

Twitter API Version 2 Code Snippets

[More examples in TwitterAPI/examples/v2 ]

Search for recent tweets, and specify fields and expansions

from TwitterAPI import TwitterAPI
api = TwitterAPI(consumer_key, consumer_secret, access_token_key, access_token_secret, api_version='2')
r = api.request('tweets/search/recent', {
        'query':'pizza',
        'tweet.fields':'author_id',
        'expansions':'author_id'})
for item in r:
        print(item)

One Method For Everything

The request() method works with all version 1.1 and version 2 endpoints. Typcally, request() takes two arguments: a Twitter endpoint and a dictionary of endpoint parameters.

The method returns an object that will iterate either search results and streams. The returned object also gives you access to the raw response (r.text) and the HTTP status code (r.status_code). See the requests library documentation for more details.

Documentation

Extra Goodies

Command-Line Utility (examples/cli)

About

Minimal python wrapper for Twitter's REST and Streaming APIs

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 32

Languages

TMZ Celebrity News – Breaking Stories, Videos & Gossip

Looking for the latest TMZ celebrity news? You've come to the right place. From shocking Hollywood scandals to exclusive videos, TMZ delivers it all in real time.

Whether it’s a red carpet slip-up, a viral paparazzi moment, or a legal drama involving your favorite stars, TMZ news is always first to break the story. Stay in the loop with daily updates, insider tips, and jaw-dropping photos.

🎥 Watch TMZ Live

TMZ Live brings you daily celebrity news and interviews straight from the TMZ newsroom. Don’t miss a beat—watch now and see what’s trending in Hollywood.