
How to get an X API key _
Two routes resolve to a working key. The official X Developer Platform issues one to an X developer account, billed pay-per-use against a saved payment card. TwitterAPI.io, a third-party X (Twitter) API, issues one on Google sign-in with up to $1 in free credits for new accounts (bot check, one per person or network, expires after 31 days). The second is faster; the first is first-party. The rest of this page covers storage, rotation, and what to do when a key leaks.
[ SYNOPSIS ]
x-api-key — credential for the X (Twitter) developer ecosystem
ttapi_<28-char-random>curl https://api.twitterapi.io/twitter/user/info \ -H "X-API-Key: $TWITTERAPI_IO_KEY"
[ PATH A — TwitterAPI.io ]
EXEC TIME ≈ 5 MIN
> visit /dashboard
> click "sign in with google"
> oauth complete
> read X-API-Key from the issued key card
> export TWITTERAPI_IO_KEY="ttapi_..."
> curl https://api.twitterapi.io/twitter/user/info?userName=elonmusk \
-H "X-API-Key: $TWITTERAPI_IO_KEY"[ PATH B — X Developer Console ]
EXEC TIME ≈ NO PUBLISHED SLA
> step 1 sign in at console.x.com with the X account that will own the app
> step 2 accept the Developer Agreement and Policy
> step 3 describe how you will use the API
> step 4 New App (inside a project) -> generates the credentials
> step 5 copy API Key + Secret, Bearer Token, Access Token + Secret
> step 6 save a payment card and buy credits (pay-per-use, no subscription)
> rates post read $0.005 | user read $0.010 | enterprise above 3M reads/mo
> step 7 curl https://api.x.com/2/users/by/username/elonmusk \
-H "Authorization: Bearer $X_BEARER"[ STORAGE & ROTATION ]
// .env (gitignored)
TWITTERAPI_IO_KEY=ttapi_...
// usage
const key = process.env.TWITTERAPI_IO_KEY
if (!key) throw new Error("missing TWITTERAPI_IO_KEY")import os key = os.environ["TWITTERAPI_IO_KEY"] # KeyError if absent
Schedule a rotation any time the surface around the key changes — a contractor offboards, a build pipeline is replaced, a shared inbox cycles. The Rotate control on the dashboard is single-click and instant; the friction is preparing the dependents to read the new value, not the rotation itself.
[ ERRATA — HANDLE WITH CARE ]
WARN 01. A key committed to a private repository is still a leaked key. Repository visibility changes; forks proliferate; backups index the same blobs. Rewrite history or rotate — preferably both.
WARN 02. Embedding the key in client-side JavaScript ships it to every visitor. The browser's view-source reveals it; the network panel reveals it; the cached bundle preserves it. A server proxy is the only honest fix.
WARN 03. Screenshots taken for support tickets capture the dashboard verbatim. Crop or redact before sending. The same applies to recorded walkthroughs and live screen-share sessions.
WARN 04. One key reused across personal projects, prototypes, and production multiplies the blast radius. Issue one per service when the cost of doing so is small.
[ Q & A ]
- Q01 Is there a way to get a key without applying?
- Yes. Third-party APIs like TwitterAPI.io grant a key on Google sign-in with no application review. TwitterAPI.io gives up to $1 in free credits for new accounts that pass a bot check (one per person or network, expires after 31 days; see /pricing), enough for an end-to-end evaluation. The official X Developer Platform requires an X developer account and, for pay-per-use, a saved payment card.
- Q02 How do I get an X API key from the X Developer Portal?
- Sign in at console.x.com (the X Developer Console, formerly the developer portal), accept the Developer Agreement and Policy, describe how you will use the API, then click New App. Creating the app generates the API Key and Secret, a Bearer Token and Access Tokens; copy them once, because secrets are not shown again. Reads need credits, so save a payment card and buy credits before the first call.
- Q03 What does the official X path require?
- An X developer account with a project and app, plus a saved payment card for pay-per-use billing. There are no subscriptions: X bills $0.005 per post read and $0.010 per user read, and pay-per-use is capped at 3 million post reads per monthly billing cycle. X publishes no SLA for account setup, so do not pin a launch date to it.
- Q04 Where does my key appear after sign-in on TwitterAPI.io?
- Immediately on /dashboard after Google OAuth completes. Format is a prefixed string. The Rotate control on the same surface invalidates the old key the moment a new one issues.
- Q05 What if the key leaks?
- Rotate first, investigate second. On TwitterAPI.io the Rotate action is instant. Audit your repository history for accidental commits. Search build logs, screenshots, and shared docs for the leaked prefix. Consider key-per-service so the blast radius shrinks for next time.
- Q06 How should the key be stored?
- Read from an environment variable, never from a literal. In CI, use the secret manager — not a plain env var visible in build logs. For client-side code, proxy through a server you control rather than embedding the key in browser JavaScript where any user can read it.
[ SEE ALSO ]
$ ./issue-key.sh
Sign in once. Read the key off the dashboard. Make the first call before this tab loses focus.
proceed →