Getting started with the user Post and mention timeline endpoints
This quick start guide will help you make your first request to the user Post timeline endpoint with a set of specified fields using Postman. If you would like to see sample code in different languages, please visit our X API v2 sample code GitHub repository.PrerequisitesTo complete this guide, you will need to have a set of keys and tokens to authenticate your request. You can generate these keys and tokens by following these steps:
- Sign up for a developer account and receive approval.
- Create a Project and an associated developer App in the developer portal.
- Navigate to your App’s “Keys and tokens” page to generate the required credentials. Make sure to save all credentials in a secure location.
XDevelopers.
https://x.com/XDevelopers
To convert this username to the user ID, you will have to use the users lookup endpoint with the username and find the numerical user ID in the payload. In the case of @XDevelopers, the user ID is 2244994945.
In Postman, navigate to the “Params” tab and enter this user ID into the “Value” column of the id parameter.
Step four: Identify and specify which fields you would like to retrieve
If you click the “Send” button after step three, you will receive the default Post object fields in your response: id and text.
If you would like to receive additional fields beyond id and text, you will have to specify those fields in your request with the field and/or expansion parameters.
For this exercise, we will request a three additional different sets of fields from different objects:
- The additional tweet.created_at field in the primary user objects.
- The associated authors’ user object’s default fields for the returned Posts: id, name, and username
- The additional user.created_at field in the associated user objects.
You should now see the following URL next to the “Send” button:
https://api.x.com/2/users/:id/tweets?tweet.fields=created_at&expansions=author_id&user.fields=created_at&max_results=5
Please note:In Postman, the path parameter :id in the URL field will not automatically update to the value that you enter into the
id params field, which is why the above URL includes :id and not 2244994945.- oldest_id
- newest_id
- results_count
- next_token
- previous_token
Once this is all set up, you can click “Send” again and you should receive the next page of results.
We have put together a guide on pagination to further explain this concept.
Next steps
Customize your request using the API Reference
Reach out to the community for help