GithubHelp home page GithubHelp logo

twitterapi's Introduction

TwitterAPI

This python package supports the latest Twitter API (version 1.1) with OAuth, and it works with the latest python versions in both 2.x and 3.x tracks.

Scripting Usage

See TwitterAPI/cli.py for a working scripting example.

First, authenticate with your application credentials:

from TwitterAPI import TwitterAPI
api = TwitterAPI(consumer_key, consumer_secret, access_token_key, access_token_secret)

Tweet something:

api.request('statuses/update', {'status':'This is a tweet!'})

Get some tweets:

api.request('search/tweets', {'q':'zzz'})
iter = api.get_iterator()
for item in iter:
	print item

Stream tweets from New York City:

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

Command-line Usage (cli.py)

For help:

> python -m TwitterAPI.cli -h 

You will need to supply your Twitter application OAuth credentials. The easiest option is to enter them in TwitterAPI/credentials.txt. The the default place where cli.py will look for them. You also can supply an alternative credentials file as a command-line argument.

Call any REST API endpoint:

> python -m TwitterAPI.cli -endpoint statuses/update -parameters status='my tweet'

Another example (here using abreviated option names) that parses selected output fields:

> python -m TwitterAPI.cli -e search/tweets -p q=zzz count=10 -field screen_name text 

Calling any Streaming API endpoint works too:

> python -m TwitterAPI.cli -e statuses/filter -p track=zzz -f screen_name text

If you do not include the -field (-f) option cli.py prints the entire JSON response object. Or, to print just fields of interest add one or more field names after -field.

Installation

> pip install TwitterAPI

Contributors

Jonas Geduldig

twitterapi's People

Contributors

geduldig avatar jonasgeduldig avatar

Watchers

 avatar  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.