Twython: A Pure Python Wrapper for the Twitter API

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

Twython: A Pure Python Wrapper for the Twitter API

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

Analyzed by OSRepos on July 28, 2026

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

Related repositories

Similar repositories that may be relevant next.

gspread: A Python API for Seamless Google Sheets Integration

gspread: A Python API for Seamless Google Sheets Integration

July 28, 2026

gspread is a powerful Python API designed for seamless interaction with Google Sheets. It offers a simple and comprehensive interface to programmatically open, read, write, and format data in spreadsheets, along with managing worksheets and access permissions. This library is an essential tool for automating Google Sheets operations directly from Python applications.

gspreadPythongoogle-sheets
purl: A Simple, Immutable Python URL Class for Clean Manipulation

purl: A Simple, Immutable Python URL Class for Clean Manipulation

July 27, 2026

purl is a Python library offering a simple, immutable URL class designed for easy interrogation and manipulation of URLs. It provides a clean API, supports various Python versions, and includes features like URL template expansion based on RFC 6570. This makes it an excellent tool for handling URLs robustly in your Python projects.

PythonURL ParsingWeb Development
pyshorteners: Simplify URL Shortening in Python

pyshorteners: Simplify URL Shortening in Python

July 27, 2026

pyshorteners is a Python library designed to make URL shortening effortless. It acts as a simple API wrapper, supporting various popular shortening services. Developers can easily integrate URL shortening capabilities into their Python applications with this versatile tool.

PythonURL ShortenerAPI Wrapper
webargs: Efficient HTTP Request Argument Parsing for Python Web Frameworks

webargs: Efficient HTTP Request Argument Parsing for Python Web Frameworks

July 27, 2026

webargs is a robust Python library designed for parsing and validating HTTP request arguments across various web frameworks. It offers seamless integration with popular choices like Flask, Django, and aiohttp, simplifying the process of handling incoming request data. This library helps developers build more secure and reliable web applications by ensuring proper data validation.

PythonWeb DevelopmentAPI

Source repository

Open the original repository on GitHub.

View on GitHub
OS
OSRepos

Analysis and discovery of open source repositories. Find interesting projects and follow their updates.

Monitor your website with YourWebsiteScore

OSRepos shares public repositories for knowledge and discovery only. Any installation, execution, configuration, or use of third-party repository code is at your own risk. Always review source code, dependencies, licenses, and security implications before running anything.

© 2025 OSRepos. Built with Nuxt 3 and lots of ❤️