How to Get a Twitter API Key in 2026 (X Console Steps)
Get a Twitter (X) API key at console.x.com in four steps: which of the four credential types you need, what a first call costs, and a free read-only key.
Tarun Khatri
Published · Updated · 7 min read
To get a Twitter API key, sign in at console.x.com, create an app, and copy the keys X shows you once.
This guide is for you if you're calling the X (Twitter) API for the first time in 2026. You get X's own steps, which credential does what, and a first call with its price. We run Weir, the free read-only route at the end.
Once you have a bearer token, this is the first call in X's quickstart:
curl "https://api.x.com/2/users/by/username/xdevelopers" \
-H "Authorization: Bearer $BEARER_TOKEN"
- Sign in at console.x.comUse your X account and accept the Developer Agreement.
- Create an appGive it a name, a description and a use case.
- Save the credentialsX shows them once. Put them in a password manager.
- Buy creditsPay-per-use: no credits, no data.
- Make a first callSend the bearer token to the user lookup endpoint.
Step 1: Sign in to the X Developer Console and create an app
X's getting-access page sends you to console.x.com, the X Developer Console. Sign in there with the X account that should own the app.
X's page then lists three things to do:
- Accept the Developer Agreement and Policy. It's X's contract for using the API.
- Describe your use. X asks for "basic information about how you'll use the API."
- Click New App. Give it a name, a description and a use case.
X says the console then generates your keys and tokens.
Older guides describe a developer application that X must approve, at developer.x.com or apps.twitter.com. X's getting-access page, checked on 22 October 2026, mentions no review wait.
Step 2: Save your X API key, secret and bearer token
You see each credential once. X's getting-access page says "Credentials are only displayed once," and that losing them means you regenerate, "which invalidates the old ones."
Here is what X generates, and when you need each one:
| Credential | What X says it does | You need it to |
|---|---|---|
| API key and secret | Identifies your app; signs 1.0a | Make other tokens |
| Bearer token | App-only access to public data | Read posts and users |
| Access token and secret | Acts as your own account | Post from your own bot |
| Client ID and secret | OAuth 2.0 user-context requests | Act for other users |
Most first projects only need the bearer token.
X's older pages call the API key and secret "consumer API keys," and many guides still do. X's apps page adds that OAuth 2.0 public clients, such as mobile apps, get no client secret and use PKCE instead.
Step 3: Buy credits, because every call costs money
X bills its API pay-per-use. Its pricing page tells you to "purchase credits upfront in the Developer Console," and its billing FAQ says that without credits, requests "will fail until you purchase more credits."
Neither X's pricing page nor its getting-access page lists a free tier, as of 22 October 2026.
Those free credits have conditions. X's free-credits page gives $20 after your first eligible card and first credit purchase.
It also matches your first auto-recharge, up to $50. Adding a card alone stopped counting on 13 October 2026. Both credits expire three months after X grants them.
X says the offers are "currently rolling out," so your account may not get them yet.
Set a spending limit in the console before you write any loop. Every rate is in our X API pricing guide.
Step 4: Make your first call with the bearer token
In the console, open your app and copy its bearer token. Then export it and run X's own example, a user lookup:
export BEARER_TOKEN="paste-your-token-here"
curl "https://api.x.com/2/users/by/username/xdevelopers" \
-H "Authorization: Bearer $BEARER_TOKEN"
X's quickstart shows this reply:
{
"data": {
"id": "2244994945",
"name": "X Developers",
"username": "xdevelopers"
}
}
That call returns one user, so it costs $0.010 at X's "User: Read" rate.
A search costs more. By default, recent search returns up to 10 posts. That full first page costs $0.05.
Run the same lookup again today and X shouldn't charge twice. It removes duplicates within a UTC day, which it calls a "soft guarantee."
How to get a Twitter API key free for reading
If you only read public data, you can skip X's developer app and its prepaid credits. We run Weir, a read-only API for public X data, so weigh this section knowing that.
Sign up with no card, then create a key under API keys in the dashboard. Like X, Weir shows a key once and stores only its hash.
Here is the same lookup on Weir:
curl https://api.weirapp.io/v1/x/users/XDevelopers \
-H "Authorization: Bearer $WEIR_API_KEY"
We ran it on 22 October 2026. It charged 3 credits, one for the call and two for the profile. The reply, trimmed:
{
"data": {
"id": "2244994945",
"username": "XDevelopers",
"name": "Developers",
"followersCount": 697848,
"createdAt": "2013-12-14T04:35:55.000Z"
}
}
Same account id. The display name and follower count are live, not X's sample.
Your 5,000 free credits a month cover about 1,600 lookups like this. Spent on search instead, they read about 4,760 posts. Failed calls cost nothing.
TwitterAPI.io's pricing page lists $0.15 per 1,000 tweets, so it is cheaper per post than Weir. Weir's figure assumes search pages of about 20 posts, at 1 credit per post plus 1 per call. Price your own job with the X API cost calculator.
If your X API key doesn't work
These are the errors you're most likely to hit on day one:
- 401 Unauthorized: the token is wrong, missing or regenerated. Check the
Authorization: Bearerheader. - 402 Payment Required: your balance is empty. X blocks calls until you buy credits, so our X API 402 guide starts there.
- 403 Forbidden: the token works but lacks access, such as a bearer token on an endpoint that needs a user.
- 429 Too Many Requests: you hit a rate limit. Wait until the time in
x-rate-limit-reset. - Lost secret: X can't show it again. Regenerate it and update your code.
When not to use Weir
- You need to post, reply, like or DM. Weir is read-only, and only X's API writes.
- You need X's own terms and guarantees. Weir is not licensed by X, so its access can change.
- You read your own account. X prices those "Owned Reads" at $0.001 each.
- Price per post is all that matters. TwitterAPI.io charges less per tweet.
FAQ
Is the Twitter API key free?
X lists no fee for creating an app or its keys, but every call that returns data costs credits. Its pricing page lists no free tier as of October 2026. New accounts can earn up to $70 in one-time credits, and both offers need a payment first.
Where do I find my Twitter bearer token?
In the X Developer Console at console.x.com. Open your app and copy the bearer token from its credentials. X shows it once, so if you lost it, regenerate it. X's docs also show how to mint one from your API key and secret.
What is the X Developer Console?
It's X's site for API access, at console.x.com. X's docs call it "your central hub for managing X API access": you create apps, generate credentials, buy credits and watch usage there.
Can one X API key read and post?
Not the bearer token: it only reads public data. To post as your own account, X points you to the access token and secret. To act for other users, use OAuth 2.0 with your client ID. A plain post costs $0.015.
Sources
All checked on 22 October 2026:
- X API, getting access: https://docs.x.com/x-api/getting-started/getting-access
- X API, make your first request: https://docs.x.com/make-your-first-request
- X API pricing: https://docs.x.com/x-api/getting-started/pricing
- X API free credits (updated 13 October 2026): https://docs.x.com/x-api/getting-started/free-credits
- X API usage and billing FAQ: https://docs.x.com/x-api/fundamentals/post-cap
- X Developer Console: https://docs.x.com/fundamentals/developer-portal
- X developer apps and credentials: https://docs.x.com/fundamentals/developer-apps
- X app-only bearer tokens: https://docs.x.com/fundamentals/authentication/oauth-2-0/bearer-tokens
- X recent search reference (max_results 10 to 100): https://docs.x.com/x-api/posts/search-recent-posts
- X API response codes and errors: https://docs.x.com/x-api/fundamentals/response-codes-and-errors
- X Help Center, About X Premium (Internet Archive copy of 10 October 2026): https://help.x.com/en/using-x/x-premium
- TwitterAPI.io pricing: https://twitterapi.io/pricing
- Weir authentication and billing: https://docs.weirapp.io/authentication and https://docs.weirapp.io/billing
- Our @XDevelopers lookup through Weir, 22 October 2026 (request 62c2c9c6)