Coder Social home page Coder Social logo

twitterapi's Introduction

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)

twitterapi's People

Contributors

geduldig avatar jonasgeduldig avatar dylancaponi avatar peguerosdc avatar rickredsix avatar biancini avatar drbig avatar torufurukawa avatar joseph-rossi-bose avatar tangentmonger avatar dheavyman avatar x0139 avatar ravinewaters avatar leogregianin avatar dbuendiab avatar gitter-badger avatar rodrigogiraoserrao avatar factorlive avatar neodymiumferbore avatar neilcturner avatar marviel avatar reuning avatar jeffnappi avatar hammadh avatar karlicoss avatar ckovamees avatar aronwc avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.