跳转到主要内容
一款面向 X API(原 Twitter API)的完整 TypeScript SDK,提供智能分页、多种身份验证方式、实时流式处理和完备的类型安全等高级功能。

关键功能

  • 🔐 身份验证:用户上下文(OAuth 1.0a、OAuth 2.0)与仅 App(Bearer 令牌)身份验证
  • 🔄 分页:自动分页,支持异步迭代
  • 📡 流式:事件驱动的流式处理与自动重连
  • 📚 类型安全:为所有端点与参数提供完整的 TypeScript 定义
  • 🎯 完整的 X API 支持:用户、Post、列表、书签、社区等

快速上手

quickstart.ts
import { 
  Client, 
  type ClientConfig,
  type UsersGetByUsernameResponse
} from '@xdevplatform/xdk';

const config: ClientConfig = { bearerToken: 'your-bearer-token' };

const client: Client = new Client(config);

async function main(): Promise<void> {
  const userResponse: UsersGetByUsernameResponse = await client.users.getByUsername('XDevelopers');
  const username: string = userResponse.data?.username!;
  console.log(username);
}

main();

接下来?