tweepy
Library for accessing the X API (Twitter)
What it is and what it does
Tweepy is a mature Python wrapper around the X (Twitter) API that abstracts away the complexity of OAuth authentication and HTTP request formatting. It lets you write Python code to search tweets, retrieve user timelines, post updates, and manage followers without manually constructing API calls or handling token refresh cycles. The library depends on oauthlib, requests, and requests-oauthlib to handle the OAuth handshake and HTTP transport.
The package is designed for developers who need programmatic access to X data—whether for data collection, bot automation, or social media monitoring. It supports both synchronous and asynchronous workflows (via the optional async extra) and maintains compatibility with modern Python versions (3.9 and later). Since it's actively maintained and carries no known vulnerabilities, it's a stable choice for production use.
Use it for:
- Collect tweets matching a search query or from a specific user's timeline for analysis or archival.
- Build a Twitter bot that automatically posts updates or responds to mentions on a schedule.
- Monitor brand mentions or hashtags in real-time and trigger alerts or logging based on tweet content.
- Analyze social media trends by fetching historical tweet data and user engagement metrics.
- Integrate X data into a larger application dashboard or reporting pipeline.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Tweepy is a Python library that provides access to the X (Twitter) API, handling authentication and request formatting so you can fetch tweets, post updates, and interact with user data programmatically.
Yes. Tweepy is a production-stable, actively maintained library with no security issues, low install friction, and permissive licensing. If you need programmatic access to the X API from Python, it's the standard choice and will save you from writing OAuth and HTTP plumbing yourself. Install it unless you have a specific reason to use a different X API client.
Install
tweepy on PyPI
pip
pip install tweepyuv
uv add tweepypoetry
poetry add tweepyInstalling tweepy
Before you install
Installation is straightforward with pip and carries low friction. The package is actively maintained with a recent release (43 days old) and an established repository with 11177 stars. It supports current Python versions (3.9 and later) and has no known security vulnerabilities.
License in practice
Tweepy is released under a permissive license, meaning you can use, modify, and distribute it freely in both open-source and commercial projects with minimal restrictions.
Quickstart
pip install tweepy
import tweepy
client = tweepy.Client(bearer_token="YOUR_BEARER_TOKEN")
tweets = client.get_users_mentions(id=user_id)
print(tweets.data)
You must obtain API credentials from the X Developer Portal and set a valid bearer token to authenticate requests.
Verify before relying
- Whether the async extra (tweepy[async]) adds significant overhead or is necessary for your use case.
- Rate limiting behavior and how the library handles X API quota exhaustion.
- Support timeline for Python versions currently in bugfix/security phases.
- Specific API endpoints and methods available in version 4.17.0.
Package facts
| License | not declared (permissive) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 3 — oauthlib, requests, requests-oauthlib |
| Maintenance | actively maintained — 43 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 4,731,411/month — #2,243 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: tweepy-4.17.0-py3-none-any.whl
Keywords: X.com, API, Twitter
Tags
More Libraries packages
urllib3 is an HTTP client library that provides…
permissive · top 100 on PyPI
requestsRequests is a Python HTTP library that…
permissive · top 100 on PyPI
pluggyPluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
python-dateutilProvides parsing, arithmetic, and recurrence…
permissive · top 100 on PyPI
sixSix provides utility functions to write Python…
permissive · top 100 on PyPI
pytestpytest is a testing framework that lets you…
permissive · top 100 on PyPI
Mastodon.pyPython wrapper for the Mastodon API that lets…
permissive · top 15,000 on PyPI
twikitTwikit is a Twitter scraper library that lets…
permissive · top 15,000 on PyPI
twythonTwython is a Python wrapper for the Twitter API…
permissive · top 15,000 on PyPI
ScweetScrape tweets, profiles, followers, and user…
permissive · top 15,000 on PyPI
python-twitterA Python wrapper that provides programmatic…
permissive · top 15,000 on PyPI
twscrapetwscrape is an async Python library and CLI for…
permissive · top 15,000 on PyPI
TikTokApiUnofficial Python wrapper for retrieving public…
permissive · top 15,000 on PyPI
crowdin-api-clientA lightweight Python client library for the…
permissive · top 15,000 on PyPI
xclienttransactionGenerates X-Client-Transaction-ID headers for…
permissive · top 15,000 on PyPI
pyobjc-framework-SocialProvides Python bindings to macOS's Social…
permissive · top 15,000 on PyPI