Bookmarks lookup
Getting started with the Bookmarks lookup endpoint
This quick start guide will help you make your first request to the Bookmarks lookup endpoint using Postman.
Please visit our X API v2 sample code GitHub repository if you want to see sample code in different languages.
Prerequisites
To 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.
Steps to build a Bookmarks lookup request
Step one: Start with a tool or library
There are several different tools, code examples, and libraries that you can use to make a request to this endpoint, but we will use the Postman tool here to simplify the process.
To load the X API v2 Postman collection into your environment, please click on the following button:
Once you have the X API v2 collection loaded in Postman, navigate to the “Bookmarks” folder, and select “ Bookmarks lookup”.
Step two: Authenticate your request
To make a successful request to this endpoint, you will need to use OAuth 2.0 Authorization Code Flow with PKCE. You can generate an access token within Postman.
If you go to the tab entitled “Authorization” and select “OAuth 2.0”.
In this tab, be sure to follow these steps:
-
Name your token
-
Select the Grant Type as Authorization Code (with PKCE)
-
Update the parameters:
Callback URL - https://www.example.com
This should be matching the callback URL you set in your auth settings page in the Developer Portal.
Auth URL - https://twitter.com/i/oauth2/authorize
Access Token URL - https://api.x.com/2/oauth2/token
Client ID - Cut and paste OAuth 2.0 client ID from the Developer Portal
Client Secret - Cut and paste OAuth 2.0 client ID from the Developer Portal. You will need this only if you are using an App type that is a confidential client.
-
Update the scopes with the following values: post.read users.read bookmark.read
-
Populate the field state with “State”
-
Click where it says “Generate Token”
-
Press the save icon to save the folder changes.
You may get a message that you are not logged into X. If you get this error, you will need to log in to the X account inside of Postman you are trying to post on behalf of.
Step three: Specify a user
With this endpoint, you must specify the user ID whose followers you would like to receive in the response. For example, the user ID for @XDevelopers is2244994945. In Postman, navigate to the “Params” tab and enter the ID of yourself or an authenticated user as the value for the id parameter.
Key | Value |
id | 2244994945 |
Step four: Make your request and review your response
Once you have everything set up, hit the “Send” button and you will receive a similar response to the following example response: