Skip to main content
Get started with the X API in three steps: sign up, create an app, and save your credentials.

Step 1: Create a developer account

1

Go to the Developer Console

Visit console.x.com and sign in with your X account.
2

Accept the Developer Agreement

Review and accept the Developer Agreement and Policy.
3

Complete your profile

Provide basic information about how you’ll use the API.

Step 2: Create an app

After signing up, create an app to get your API credentials:
1

Click 'New App'

From the Developer Console dashboard, create a new app.
2

Enter app details

Provide a name, description, and use case for your app.
3

Generate credentials

The console will generate your API keys and tokens.

Step 3: Save your credentials

You’ll receive several credentials depending on your authentication needs:
CredentialPurpose
API Key & SecretIdentify your app. Used to generate tokens and sign OAuth 1.0a requests.
Bearer TokenApp-only authentication for reading public data.
Access Token & SecretMake requests on behalf of your own account (OAuth 1.0a).
Client ID & SecretOAuth 2.0 authentication for user-context requests.
Save immediately. Credentials are only displayed once. Store them in a password manager or secure vault. If you lose them, you’ll need to regenerate (which invalidates the old ones).

Which credentials do you need?

Use the Bearer Token for simple, read-only access to public data.
curl "https://api.x.com/2/users/by/username/xdevelopers" \
  -H "Authorization: Bearer $BEARER_TOKEN"
Best for: Searching posts, looking up users, reading trends.

Credential security best practices

Use environment variables

Never hardcode credentials in your source code.

Don't commit to git

Add credential files to .gitignore.

Rotate regularly

Regenerate credentials periodically as a security measure.

Use minimal scopes

Only request the OAuth permissions your app needs.

Next steps