Skip to main content
Client supports Bearer Token (app-only), OAuth 2.0 with PKCE (user context), and OAuth 1.0a (user context). Get your credentials from the X Developer Console.

Bearer Token

For public read, search, and streaming endpoints:
bearer.ts

OAuth 2.0 with PKCE

For user-authorized actions (creating posts, bookmarks, DMs, X Chat):
oauth2.ts

OAuth 1.0a

OAuth 1.0a is disabled for newly created apps and is scheduled to be retired on January 31, 2027. Newly created apps must use OAuth 2.0 with PKCE or Bearer Token. Existing apps with OAuth 1.0a enabled can continue using it until January 31, 2027 — see Migrate from OAuth 1.0a to OAuth 2.0.
For OAuth 1.0a HMAC-SHA1 user context:
oauth1.ts
See the TypeScript samples repo for more examples.