Skip to main content
The TypeScript XDK is the official client library for the X API v2. Full type safety, automatic pagination, and event-driven streaming.

GitHub repository

Source code, issues, and releases.

Installation

npm install @xdevplatform/xdk
Requires Node.js 16+ and TypeScript 4.5+ (if using TypeScript).

Quick start

import { Client } from '@xdevplatform/xdk';

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

const userResponse = await client.users.getByUsername('XDevelopers');
console.log(userResponse.data?.username);

Key features

FeatureDescription
Type safetyComplete TypeScript definitions for all endpoints and parameters
AuthenticationBearer Token, OAuth 2.0 with PKCE, and OAuth 1.0a
Automatic paginationAsync iteration support for paginated endpoints
StreamingEvent-driven streaming with automatic reconnection
Full API coverageUsers, Posts, Lists, Bookmarks, Communities, and more

Authentication

import { Client } from '@xdevplatform/xdk';

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

Common methods

CategoryMethod
Postsclient.posts.search()
Usersclient.users.getMe()
Spacesclient.spaces.findSpaceById()
Listsclient.lists.getList()
DMsclient.directMessages.lookup()

Learn more

Installation

Package managers, TypeScript setup, and requirements.

Authentication

Detailed guide for all auth methods.

Pagination

Async iteration and paginated responses.

Streaming

Event-driven streaming with reconnection.

API Reference

Complete client, interface, and type reference.
For code examples, see the samples repo.