twython alternatives and similar packages
Based on the "Third-party APIs" category.
Alternatively, view twython alternatives based on common mentions on social networks and blogs.
9.1 4.0 L3 twython VS botoFor the latest version of boto, see https://github.com/boto/boto3 -- Python interface to Amazon Web Services
8.8 9.1 L2 twython VS google-api-python-client🐍 The official Python client library for Google's discovery based APIs.
8.5 8.6 L3 twython VS TelethonPure Python 3 MTProto API Telegram client library, for bots too!
7.2 7.9 L2 twython VS apache-libcloudApache Libcloud is a Python library which hides differences between different cloud provider APIs and allows you to manage different cloud resources through a unified and easy to use API
7.1 9.0 L4 twython VS PRAWPRAW, an acronym for "Python Reddit API Wrapper", is a python package that allows for simple access to Reddit's API.
1.0 0.0 L4 twython VS Python-OnfleetA full-featured Python wrapper for the Onfleet API.
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of twython or a related project?
Twython is a Python library providing an easy way to access Twitter data. Supports Python 3. It's been battle tested by companies, educational institutions and individuals alike. Try it today!
Note: As of Twython 3.7.0, there's a general call for maintainers put out. If you find the project useful and want to help out, reach out to Ryan with the info from the bottom of this README. Great open source project to get your feet wet with!
- Query data for:
- User information
- Twitter lists
- Direct Messages
- and anything found in the docs
- Image Uploading:
- Update user status with an image
- Change user avatar
- Change user background image
- Change user banner image
- OAuth 2 Application Only (read-only) Support
- Support for Twitter's Streaming API
- Seamless Python 3 support!
Install Twython via pip:
$ pip install twython
Or, if you want the code that is currently on GitHub
git clone git://github.com/ryanmcgrath/twython.git cd twython python setup.py install
Documentation is available at https://twython.readthedocs.io/en/latest/
First, you'll want to head over to https://apps.twitter.com and register an application!
After you register, grab your applications
Consumer Key and
Consumer Secret from the application details tab.
The most common type of authentication is Twitter user authentication using OAuth 1. If you're a web app planning to have users sign up with their Twitter account and interact with their timelines, updating their status, and stuff like that this is the authentication for you!
First, you'll want to import Twython
from twython import Twython
Obtain Authorization URL
Now, you'll want to create a Twython instance with your
Consumer Key and
- Only pass callback_url to get_authentication_tokens if your application is a Web Application
- Desktop and Mobile Applications do not require a callback_url
APP_KEY = 'YOUR_APP_KEY' APP_SECRET = 'YOUR_APP_SECRET' twitter = Twython(APP_KEY, APP_SECRET) auth = twitter.get_authentication_tokens(callback_url='http://mysite.com/callback')
auth variable, save the
oauth_token_secret for later use (these are not the final auth tokens). In Django or other web frameworks, you might want to store it to a session variable
OAUTH_TOKEN = auth['oauth_token'] OAUTH_TOKEN_SECRET = auth['oauth_token_secret']
Send the user to the authentication url, you can obtain it by accessing
Handling the Callback
If your application is a Desktop or Mobile Application oauth_verifier will be the PIN code
After they authorize your application to access some of their account details, they'll be redirected to the callback url you specified in
You'll want to extract the
oauth_verifier from the url.
oauth_verifier = request.GET['oauth_verifier']
Now that you have the
oauth_verifier stored to a variable, you'll want to create a new instance of Twython and grab the final user tokens
twitter = Twython( APP_KEY, APP_SECRET, OAUTH_TOKEN, OAUTH_TOKEN_SECRET ) final_step = twitter.get_authorized_tokens(oauth_verifier)
Once you have the final user tokens, store them in a database for later use::
OAUTH_TOKEN = final_step['oauth_token'] OAUTH_TOKEN_SECRET = final_step['oauth_token_secret']
For OAuth 2 (Application Only, read-only) authentication, see our documentation.
Dynamic Function Arguments
Keyword arguments to functions are mapped to the functions available for each endpoint in the Twitter API docs. Doing this allows us to be incredibly flexible in querying the Twitter API, so changes to the API aren't held up from you using them by this library.
Function definitions (i.e. get_home_timeline()) can be found by reading over twython/endpoints.py
Create a Twython instance with your application keys and the users OAuth tokens
from twython import Twython twitter = Twython(APP_KEY, APP_SECRET, OAUTH_TOKEN, OAUTH_TOKEN_SECRET)
Authenticated Users Home Timeline
This method makes use of dynamic arguments, read more about them.
twitter.update_status(status='See how easy using Twython is!')
Questions, Comments, etc?
My hope is that Twython is so simple that you'd never have to ask any questions, but if you feel the need to contact me for this (or other) reasons, you can hit me up at [email protected].
Or if I'm to busy to answer, feel free to ping [email protected] as well.
Follow us on Twitter:
Want to help?
Twython is useful, but ultimately only as useful as the people using it (say that ten times fast!). If you'd like to help, write example code, contribute patches, document things on the wiki, tweet about it. Your help is always appreciated!