Skip to main content
Speed up your development with official SDKs, community libraries, and developer tools.

Official SDKs

X provides official SDKs for TypeScript and Python with full X API v2 support.

Python SDK

Async support, type hints, and automatic token refresh. Perfect for data analysis and automation.

TypeScript SDK

Full type safety and ESM support. Works in Node.js and modern bundlers.

Why use the official SDKs?

BenefitDescription
Always up-to-dateMaintained by X, updated with new endpoints
Type safetyFull type definitions for all objects and methods
Built-in authOAuth 2.0 and OAuth 1.0a support
Automatic paginationIterate through results without manual token handling

Quick start

Installation

pip install xdk

Basic usage

from xdk import Client

client = Client(bearer_token="YOUR_BEARER_TOKEN")

# Search for posts (returns an iterator)
for page in client.posts.search_recent(query="api", max_results=10):
    if page.data and len(page.data) > 0:
        first_post = page.data[0]
        print(first_post.text)
        break

Authentication

Both SDKs support multiple authentication methods:
Simplest option for reading public data.Python:
from xdk import Client

client = Client(bearer_token="YOUR_BEARER_TOKEN")
TypeScript:
import { Client } from '@xdevplatform/xdk';

const client = new Client({ bearerToken: 'YOUR_BEARER_TOKEN' });

Available methods

The SDKs provide methods for all X API v2 endpoints:
CategoryPythonTypeScript
Postsclient.posts.search_recent()client.posts.search()
Usersclient.users.get_me()client.users.getMe()
Spacesclient.spaces.get()client.spaces.findSpaceById()
Listsclient.lists.get()client.lists.getList()
DMsclient.direct_messages.get()client.directMessages.lookup()

Python SDK Docs

Complete Python documentation.

TypeScript SDK Docs

Complete TypeScript documentation.

Python GitHub

Source code and issues.

TypeScript GitHub

Source code and issues.

Official tools

ToolDescription
Postman CollectionInteractive API testing for all v2 endpoints
xurlCommand line tool for the X APIs that handles authentication for you
OpenAPI SpecMachine-readable API specification
twitter-textParse and validate post text, count characters
Embed GeneratorBuild embeddable posts, timelines, or buttons for your site

Community libraries

These community-maintained libraries support X API v2. Check each library’s documentation for current API coverage.
LibraryDescription
tweepyPopular Python library with v2 support
twarcCLI and library for data collection
python-twitterSimple Python wrapper
TwitterAPIMinimal Python wrapper
Community libraries are not maintained by X. Check their repositories for support and current status.

X Ads API libraries

For tools and libraries specific to the X Ads API, see the Ads API tools and libraries page.

Code samples

Find examples on GitHub:

Building a library?

If you have built an X API library, share it with the community:
  1. Post in the Libraries and SDKs forum
  2. We may add it to this page!

Getting help

Developer Forum

Get help from the community.