Text of docs.x.com › tools › python-xdk as Styx crawled it on Nov 19, 2026. The page may have changed since. Only its words are kept, without pictures or layout.

Open the live page

Python XDK - X

Documentation Index Fetch the complete documentation index at: /llms.txt Use this file to discover all available pages before exploring further. Skip to main content The Python XDK is the official client library for the X API v2. It handles authentication, pagination, and streaming so you can focus on building. GitHub repository Source code, issues, and releases. Installation pip install xdk Requires Python 3.8+. Quick start from xdk import Client client = Client( bearer_token = "YOUR_BEARER_TOKEN" ) # Search for posts for page in client.posts.search_recent( query = "X API" , max_results = 10 ): if page.data and len (page.data) > 0 : print (page.data[ 0 ].text) break Key features Feature Description OAuth support Bearer Token, OAuth 2.0 with PKCE, and OAuth 1.0a Automatic pagination Iterate through results without manual next_token handling Streaming Real-time data via persistent connections (filtered stream, etc.) Full API coverage All X API v2 endpoints — search, timelines, filtered stream, and more Authentication Bearer Token OAuth 2.0 OAuth 1.0a from xdk import Client client = Client( bearer_token = "YOUR_BEARER_TOKEN" ) Example from xdk import Client from xdk.oauth2_auth import OAuth2PKCEAuth auth = OAuth2PKCEAuth( client_id = "YOUR_CLIENT_ID" , redirect_uri = "YOUR_CALLBACK_URL" , scope = "tweet.read users.read offline.access" ) auth_url = auth.get_authorization_url() tokens = auth.fetch_token( authorization_response = callback_url) client = Client( bearer_token = tokens[ "access_token" ]) from xdk import Client from xdk.oauth1_auth import OAuth1 oauth1 = OAuth1( api_key = "YOUR_API_KEY" , api_secret = "YOUR_API_SECRET" , access_token = "YOUR_ACCESS_TOKEN" , access_token_secret = "YOUR_ACCESS_TOKEN_SECRET" ) client = Client( auth = oauth1) Common methods Category Method Posts client.posts.search_recent() Users client.users.get_me() Spaces client.spaces.get() Lists client.lists.get() DMs client.direct_messages.get() Learn more Installation Development install, prerequisites, and verification.

Quickstart Step-by-step first request walkthrough. Authentication Detailed guide for all auth methods. Pagination Automatic pagination and iterators. Streaming Real-time data via filtered stream. API Reference Complete client and model reference. For code examples, see the samples repo . ⌘ I