# Twython: A Pure Python Wrapper for the Twitter API

This repository profile is provided by osrepos.com, an open source repository discovery platform.

Source: osrepos.com
Repository profile: https://osrepos.com/repo/ryanmcgrath-twython
Generated for open source discovery and AI-assisted research.

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.

GitHub: https://github.com/ryanmcgrath/twython
OSRepos URL: https://osrepos.com/repo/ryanmcgrath-twython

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

## Topics

- Python
- Twitter API
- Wrapper
- Social Media
- API Client
- Open Source

## Repository Information

Last analyzed by OSRepos: Tue Jul 28 2026 09:43:48 GMT+0100 (Western European Summer Time)
Detail views: 0
GitHub clicks: 0

## Safety Notice

OSRepos shares public repositories for knowledge and discovery only. Review source code, dependencies, licenses, and security implications before running or installing anything.

## Content

## 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:

bash
pip install twython


For legacy projects requiring Python 2.7 support, you can install the last compatible version:

bash
pip install twython==3.7.0


Alternatively, to install directly from the GitHub repository:

bash
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:

python
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:**

python
timeline = twitter.get_home_timeline()
for tweet in timeline:
    print(f"{tweet['user']['screen_name']}: {tweet['text']}")


**Updating User Status:**

python
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](https://github.com/ryanmcgrath/twython){target="_blank"}
*   **Official Documentation:** [Twython Read the Docs](https://twython.readthedocs.io/en/latest/){target="_blank"}
*   **Twitter Developer Documentation:** [Twitter API Docs](https://developer.twitter.com/en/docs){target="_blank"}
*   **Twython on PyPI:** [Twython](https://pypi.python.org/pypi/twython){target="_blank"}
*   **Follow Ryan McGrath on Twitter:** [@ryanmcgrath](https://twitter.com/ryanmcgrath){target="_blank"}
*   **Follow Mike Helmick on Twitter:** [@mikehelmick](https://twitter.com/mikehelmick){target="_blank"}