Python SDK
Async support, type hints, comprehensive v2 coverage.
TypeScript SDK
Full TypeScript types, ESM support, works with Node.js.
Why use the official SDKs?
| Benefit | Description |
|---|---|
| Always up-to-date | Maintained by X, updated with new endpoints |
| Type safety | Full type definitions for all objects and methods |
| Built-in auth | OAuth 2.0 and OAuth 1.0a support |
| Automatic pagination | Iterate through results without manual token handling |
Quick start
Authentication
Both SDKs support multiple authentication methods:- Bearer Token (App-only)
- OAuth 2.0 (User Context)
- OAuth 1.0a (User Context)
Simplest option for reading public data.Python:TypeScript:
Available methods
The SDKs provide methods for all X API v2 endpoints:| Category | Python | TypeScript |
|---|---|---|
| Posts | client.posts.search_recent() | client.posts.search() |
| Users | client.users.get_me() | client.users.getMe() |
| Spaces | client.spaces.get() | client.spaces.findSpaceById() |
| Lists | client.lists.get() | client.lists.getList() |
| DMs | client.direct_messages.get() | client.directMessages.lookup() |