xdk is the official Python SDK for the X API v2. It includes typed Pydantic models, OAuth 2.0 PKCE and OAuth 1.0a auth, cursor pagination, and streaming.
PyPI
pip install xdk · Python 3.8+GitHub
Source code and issues.
Quick example
Guides
Install
Install with pip, uv, or poetry.
Quickstart
Run your first search query.
Authentication
Bearer Token, OAuth 2.0 PKCE, and OAuth 1.0a.
Pagination
Iterate across multi-page endpoints.
Streaming
Filtered streams and rule management.
API Reference
Methods and parameters for each client.