Skip to main content
This guide walks you through making your first X API request. You’ll need a developer account with app credentials before starting.

Quick start with cURL

The fastest way to test the API is with cURL. Let’s look up a user:
Replace $BEARER_TOKEN with your actual Bearer Token. You’ll get a response like:

Step-by-step guide

1

Get your Bearer Token

In the Developer Console, navigate to your app and copy the Bearer Token.
2

Choose an endpoint

Start with one of these beginner-friendly endpoints:
EndpointWhat it does
User lookupGet user profile by username or ID
Post lookupGet post by ID
Recent searchSearch posts from the last 7 days
3

Make the request

Use cURL, Postman, or your preferred HTTP client:
4

Parse the response

Responses are JSON. The primary data is in the data field:

Request more data with fields

By default, endpoints return minimal fields. Use the fields parameter to request additional data:
Response:
Learn more about fields →

More examples


Using code instead of cURL


Tools for testing

Postman

Visual API testing with our collection.

Sample code

Examples in multiple languages.

API reference

Full endpoint documentation.

Troubleshooting

  • Check that your Bearer Token is correct
  • Ensure the token hasn’t been regenerated
  • Verify the Authorization header format: Bearer YOUR_TOKEN
  • Your app may not have access to this endpoint
  • Some endpoints require user-context authentication (OAuth 1.0a or 2.0)
  • Check your app’s permissions in the Developer Console
  • You’ve hit a rate limit
  • Check the x-rate-limit-reset header for when to retry
  • Implement exponential backoff in your code
Full error reference →

Next steps

Learn authentication

Understand OAuth for user-context requests.

Explore endpoints

Discover what you can build.

Use an SDK

Faster development with official libraries.

Build something

Ideas for what to create.