A TypeScript SDK for the X API (formerly Twitter API), built with modern TypeScript practices. This SDK is designed with developers in mind, providing full type safety, ease of use, and support for the latest X API features.
Note: This SDK is currently under development and not ready for production use.
This project is a fork of the official Twitter API SDK and has been rebranded and updated to support the latest X API functionality.
- Full type safety: Comprehensive type definitions for requests and responses.
- OAuth2 support: Authenticate securely using X's OAuth2 mechanisms.
- Built for modern Node.js: Supports Node.js 16+.
- Streaming support: Easy-to-use Async Generators for real-time data.
- Pagination made simple: Handle paginated endpoints seamlessly.
npm install x-api-sdk
import { Client } from 'x-api-sdk';
const client = new Client('MY-BEARER-TOKEN');
const stream = client.tweets.sampleStream({
'tweet.fields': ['author_id'],
});
for await (const tweet of stream) {
console.log(tweet.data?.author_id);
}
const tweet = await client.tweets.findTweetById('20');
console.log(tweet.data?.text);
This SDK supports App-only Bearer Tokens and OAuth 2.0 authentication. See X API documentation for more details.
We welcome contributions to the SDK! If you're interested in helping, here's how to get started:
-
Clone the Repository:
git clone https://github.com/<your-username>/x-api-typescript-sdk
-
Install Dependencies:
pnpm install
-
Run the Generation Script: Generate the SDK using the latest OpenAPI spec:
pnpm generate
-
Build:
pnpm build
-
Test:
pnpm test
This SDK is based on the original twitter-api-typescript-sdk
, originally developed by Twitter, Inc. under the Apache 2.0 license.
This project is licensed under the Apache 2.0 license. See the LICENSE file for details.