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.

awesome-cli-coding-agents: A Curated Directory of Terminal-Native AI Tools
August 9, 2026
The `awesome-cli-coding-agents` repository offers a comprehensive, curated directory of over 100 terminal-native AI coding agents. These powerful tools operate directly within your command line, enabling autonomous code reading, editing, and execution. The list also covers various harnesses and orchestration solutions for managing these agents.

QwenPaw: Your Personal AI Assistant for Local and Cloud Deployment
August 7, 2026
QwenPaw is a powerful personal AI assistant designed for easy installation and deployment, either on your local machine or in the cloud. It supports multiple chat applications and offers highly extensible capabilities, making it a versatile tool for various AI-driven tasks. With its robust memory system and security features, QwenPaw aims to be an intuitive and private partner in your digital life.

DeepTutor: Lifelong Personalized Tutoring with AI Agents
August 7, 2026
DeepTutor is an advanced AI-powered platform designed for lifelong personalized tutoring, integrating various learning modes into a single, extensible system. It leverages large language models and multi-agent systems to offer features like interactive chat, quiz generation, and skill development. This project provides a comprehensive environment for learners and educators seeking intelligent, adaptive educational tools.

Memori: Agent-Native Memory Infrastructure for LLM Production Systems
August 6, 2026
Memori provides agent-native memory infrastructure, offering an LLM-agnostic layer that transforms agent execution and conversations into structured, persistent state. Designed for enterprise use, it seamlessly integrates with existing data infrastructure and supports various deployment environments, ensuring robust memory management for AI agents.
Source repository
Open the original repository on GitHub.