In short
- X API keys come from an app you create in the X Developer Console at console.x.com.
- The console generates an API Key and Secret, a Bearer Token, an Access Token and Secret, and an OAuth 2.0 Client ID and Secret, and shows each one only once. Read on Getting access (docs.x.com) (opens in a new tab)
- To read public data you send the Bearer Token; posting and DMs need user tokens from OAuth.
- As of 2026-11-14, self-serve access is Pay-Per-Use only: reads cost $0.005 per post and $0.010 per user returned, from credits bought upfront. Read on X API pricing (docs.x.com) (opens in a new tab)
- PrimaryAPI reads public X profiles, posts, replies and followers with one PrimaryAPI key, priced per call.
How to get an X API key, step by step
X’s getting-started guide has three steps: create a developer account, create an app, and save the credentials it generates. Read on Getting access (docs.x.com) (opens in a new tab)
- Go to console.x.com and sign in with your X account. Read on Getting access (docs.x.com) (opens in a new tab)
- Review and accept the Developer Agreement and Policy. Read on Getting access (docs.x.com) (opens in a new tab)
- Complete your profile with basic information about how you will use the API. Read on Getting access (docs.x.com) (opens in a new tab)
- Create a new app and give it a name, a description and a use case. Read on Getting access (docs.x.com) (opens in a new tab)
- Generate the keys and tokens you need and store them in a password manager or vault straight away, because the console shows them only once. Read on Getting access (docs.x.com) (opens in a new tab)
- Buy credits in the Developer Console. Each request is deducted from that balance, and you can set a spending limit per billing cycle. Read on X API pricing (docs.x.com) (opens in a new tab)
Which X credential does what
Most people searching for an X API key need the Bearer Token. It goes in the Authorization header of read requests such as a user lookup, while the API Key and Secret identify your app and sign OAuth 1.0a requests.
X is retiring OAuth 1.0a user authentication. Apps have until January 31, 2027 to move to OAuth 2.0, and after that date requests signed with OAuth 1.0a stop working. Read on OAuth 1.0a token exchange (docs.x.com) (opens in a new tab)
| Credential | What it is for |
|---|---|
| API Key and Secret | Identify your app; used to generate tokens and sign OAuth 1.0a requests |
| Bearer Token | App-only authentication for reading public data |
| Access Token and Secret | Requests made as your own account, the one that owns the app (OAuth 1.0a) |
| Client ID and Secret | OAuth 2.0 for requests made on behalf of users who sign in |
What the X API costs in 2026
As of 2026-11-14, X sells self-serve access only as Pay-Per-Use credits: reads are charged for each resource a response returns and writes for each request, with no contract, subscription or minimum spend. Read on X API pricing (docs.x.com) (opens in a new tab)
On 2026-10-27, X staff wrote that the X API no longer has Basic or other subscription tiers: you buy credits and pay per request. Read on X Developer Community: staff reply, 2026-10-27 (opens in a new tab)
The same post read twice in one UTC day is charged once, and only successful responses that return data are billed. Read on X API usage and billing (docs.x.com) (opens in a new tab)
| Item | Price |
|---|---|
| Posts: Read | $0.005 per post returned |
| User: Read | $0.010 per user returned |
| Following/Followers: Read | $0.010 per account returned |
| Post: Create | $0.015 per request |
| Post: Create (with URL) | $0.200 per request |
| DM Interaction: Create | $0.015 per request |
| Trends | $0.010 per request |
What each access level gives you
There is one self-serve plan, Pay-Per-Use, and an Enterprise plan above it. A few apps qualify for free access, and new accounts can earn some starter credit.
- Pay-Per-Use: every endpoint in X’s API reference except those marked Enterprise-only. Read on X API overview (docs.x.com) (opens in a new tab)
- The Pay-Per-Use cap: 3 million post reads per monthly billing cycle, with Enterprise for higher volume. Read on X API usage and billing (docs.x.com) (opens in a new tab)
- Enterprise-only endpoints: volume streams, likes streams, Powerstream, post and media analytics, Account Activity and stream webhooks. Read on X API overview (docs.x.com) (opens in a new tab)
- Enterprise: everything in Pay-Per-Use plus those endpoints, dedicated support and custom packages, requested through X’s interest form. Read on X Enterprise API (docs.x.com) (opens in a new tab)
- Public Utility Apps: since Pay-Per-Use launched on 2026-02-06, free scaled access is limited to apps X classes this way. Read on X Developer Community: Pay-Per-Use launch, 2026-02-06 (opens in a new tab)
- Starter credit: new pay-per-use accounts can earn a one-time $20 after their first eligible card and first credit purchase, plus a match of their first auto-recharge up to $50. Both expire 3 months after they are granted. Read on Free credit incentives (docs.x.com) (opens in a new tab)
Common problems with a new X API key
Most trouble with a new X API key comes down to the wrong credential, an empty balance or a limit. These are the cases X’s docs describe.
- Lost credentials: they are shown only once, and regenerating one invalidates the old value, so update every place that uses it. Read on Getting access (docs.x.com) (opens in a new tab)
- A 401 error means missing or invalid credentials. Check that you used the right method for the endpoint, that the credentials were not regenerated, and the format of the Authorization header. Read on Response codes and errors (docs.x.com) (opens in a new tab)
- A 403 error means the credentials work but your app has no access to that endpoint or action. Some endpoints need specific enrollment or approval, and user-context endpoints need the right OAuth scopes. Read on Response codes and errors (docs.x.com) (opens in a new tab)
- A 429 error means a rate limit or usage cap was hit. The x-rate-limit-reset header gives the time the window resets. Read on Response codes and errors (docs.x.com) (opens in a new tab)
- Blocked requests: a balance that goes slightly negative blocks requests until you add credits, and a spending limit blocks them until the next billing cycle. Read on X API pricing (docs.x.com) (opens in a new tab)
- Callback errors (code 415): the callback URL must match one registered on the app exactly, and for local development X asks for http://127.0.0.1 rather than localhost. Read on Apps (docs.x.com) (opens in a new tab)
- Writes with the Bearer Token: it is for reading public data, so posting and DMs need OAuth 2.0 or OAuth 1.0a user tokens. Read on Getting access (docs.x.com) (opens in a new tab)
Read public X data with one PrimaryAPI key
If your app or agent only reads public X data, you can skip the X developer app. PrimaryAPI’s X APIs return public profiles, posts, replies, follower and following lists, and account search results as JSON, and you call them with the same key you use for every other API in the catalog.
There is no application review: create an account, copy your API key and send a request to the X Profile API with a handle. Each API’s page shows its price per call, its input and output fields and an example response.
Calls spend credits from a prepaid balance, credits you buy never expire, and you only pay when data comes back. Each key can carry its own spend limit, so a runaway script stops where you set it.
When to use X’s own API instead
Use X’s API when you act for an account: posting, replying, sending DMs or managing lists for users who sign in to your app. PrimaryAPI’s X APIs read public data only.
X’s API is also the way to private data a signed-in user owns, such as bookmarks and DMs, and to the firehose and analytics endpoints X sells on Enterprise plans.
Try it with PrimaryAPI
One key for every API below, for your code and your AI agents. You only pay when data comes back.
- X ProfilePublic X profile for one handle1 credit / call
- X User PostsPosts-tab timeline of a public X account2 credits / call
- X PostOne public X post by URL1 credit / call
- X Post RepliesReplies to a public X post as structured records with author, text and engagement, cursor-paged about 20 per page2 credits / call
- X FollowersFollower list of a public X account with bio, counts and avatar per follower, cursor-paged up to 200 per page2 credits / call
- X User SearchSearch X accounts by keyword and get profile records with follower, following and post counts2 credits / call