Twython: A Pure Python Wrapper for the Twitter API
This repository profile is provided by osrepos.com, an open source repository discovery platform.

Summary
Twython is an actively maintained, pure Python library designed to simplify interaction with the Twitter API. It provides comprehensive support for both normal and streaming Twitter APIs, making it easy to query user data, timelines, direct messages, and handle image uploads. This battle-tested wrapper is a robust solution for integrating Twitter functionalities into Python applications.
Repository Information
Topics
Click on any tag to explore related repositories
Use at your own risk
OSRepos shares public repositories for knowledge and discovery only. Any installation, execution, configuration, or use of code from these repositories is the user's own responsibility. Always review the repository, source code, dependencies, licenses, and security implications before running or installing anything. OSRepos is not responsible for issues, damages, or losses resulting from third-party repositories.
Introduction
Twython is an actively maintained, pure Python wrapper for the Twitter API. It simplifies interaction with Twitter's extensive API, supporting both normal and streaming functionalities. This library is battle-tested by companies, educational institutions, and individuals, providing a robust solution for integrating Twitter features into your Python applications.
Key features include querying user information, Twitter lists, timelines, and direct messages. It also supports image uploading for various purposes, OAuth 2 Application Only (read-only) authentication, and seamless Python 3 compatibility. The project is currently seeking new maintainers, offering a valuable opportunity to contribute to a widely used open-source project.
Installation
Installing Twython is straightforward using pip:
pip install twython
For legacy projects requiring Python 2.7 support, you can install the last compatible version:
pip install twython==3.7.0
Alternatively, to install directly from the GitHub repository:
git clone git://github.com/ryanmcgrath/twython.git
cd twython
python setup.py install
Examples
To get started, you'll need to register an application on the Twitter Developer Platform to obtain your Consumer Key and Consumer Secret.
First, import Twython:
from twython import Twython
APP_KEY = 'YOUR_APP_KEY'
APP_SECRET = 'YOUR_APP_SECRET'
OAUTH_TOKEN = 'YOUR_OAUTH_TOKEN'
OAUTH_TOKEN_SECRET = 'YOUR_OAUTH_TOKEN_SECRET'
twitter = Twython(APP_KEY, APP_SECRET, OAUTH_TOKEN, OAUTH_TOKEN_SECRET)
Fetching the Authenticated User's Home Timeline:
timeline = twitter.get_home_timeline()
for tweet in timeline:
print(f"{tweet['user']['screen_name']}: {tweet['text']}")
Updating User Status:
twitter.update_status(status='See how easy using Twython is!')
For detailed authentication flows, including OAuth 1 and OAuth 2, refer to the official documentation.
Why Use Twython?
Twython stands out as a reliable choice for Twitter API integration due to several factors:
- Pure Python: Built entirely in Python, ensuring compatibility and ease of use within the Python ecosystem.
- Active Maintenance: The project is actively maintained, ensuring it keeps up with Twitter API changes and Python advancements.
- Comprehensive API Coverage: It supports a wide range of Twitter API endpoints, including the Streaming API, allowing for diverse application functionalities.
- Flexibility: Dynamic function arguments map directly to Twitter API parameters, providing flexibility without waiting for library updates.
- Battle-Tested: Proven in various real-world scenarios by a diverse user base.
Links
- GitHub Repository: ryanmcgrath/twython
- Official Documentation: Twython Read the Docs
- Twitter Developer Documentation: Twitter API Docs
- Twython on PyPI: Twython
- Follow Ryan McGrath on Twitter: @ryanmcgrath
- Follow Mike Helmick on Twitter: @mikehelmick
Related repositories
Similar repositories that may be relevant next.

oh-my-hermes: Enhance Hermes Agent with Advanced AI Workflow and Memory
September 17, 2026
oh-my-hermes is an all-in-one plugin designed to significantly enhance the Hermes Agent. It provides advanced coding intelligence, a robust long-term memory system, and optimized workflow packages, transforming standard Hermes requests into structured, actionable tasks with clear operational layers.
ASC: A Super Fast Android Decompiler for Mobile Reverse Engineering
September 17, 2026
ASC is an innovative and exceptionally fast Android decompiler front-end, specifically designed for mobile researchers and agents. It redefines traditional decompilation by directly querying compiled artifacts, offering on-demand code extraction and analysis without heavy preprocessing. This approach results in significantly reduced memory usage and lightning-fast performance, even on large APKs.

Open Index: A Deterministic Memory Layer for Your AI Agents
September 16, 2026
Open Index is a powerful tool for building domain-specific, accurate, and structured data that AI agents can effectively operate on. It enables the creation of a "brain," a searchable and continuously improving context graph tailored to any domain. This system ensures agents have access to reliable, up-to-date information, enhancing their capabilities and decision-making processes.
tooltrim: Drastically Reduce LLM Agent Tool Output Tokens, Improve Accuracy
September 16, 2026
tooltrim provides drop-in compression for LLM agent tool outputs, drastically cutting tokens while often improving answer accuracy. This provider-agnostic solution offers content-aware compression, faithfulness benchmarks, and seamless integration with popular frameworks or as an OpenAI-compatible proxy.
Source repository
Open the original repository on GitHub.
21 counted GitHub visits