X API Postman Collection: Setup and First Calls (2026)
Test the X API in Postman: find X's official collection, keep the bearer token secret, send recent search and a user lookup, then repeat both on Weir.
Tarun Khatri
Published · Updated · 6 min read
To test the X API in Postman, add X's official X API v2 collection, put your bearer token in a variable, and send Recent search.
This guide is for developers who want to try X (Twitter) API calls before writing code. You get X's collection, the token setup, two first calls with prices, and the same calls on Weir, which we run. We can't run Postman here, so we say exactly what we checked.
Paste this into Postman's URL bar, and Postman turns it into a request:
curl "https://api.x.com/2/tweets/search/recent?query=from%3AXDevelopers&max_results=10" \
-H "Authorization: Bearer {{bearer_token}}"
- Add X's collectionFrom the link on docs.x.com.
- Set the bearer tokenbearer_token, marked Secure.
- Send Recent searchquery=from:XDevelopers
- Look up a userusers/by/username/XDevelopers
- Repeat on WeirImport openapi.json, set bearerToken.
Does X have an official X API Postman collection?
Yes. X's Tools and Libraries page and its Postman tutorial, checked on 22 October 2026, link an "X API v2 Collection" in X's public Postman workspace. The tutorial also links an X Ads API collection.
X says adding the v2 collection creates an environment called "X API v2". Its tutorial fills in five variables:
bearer_tokenfor app-only reads, which is all this guide needs.consumer_keyandconsumer_secret, your API key and secret.access_tokenandtoken_secret, for OAuth 1.0a calls as your own account.
What we couldn't check. The postman.com page renders only with JavaScript. Plain curl and the Internet Archive's 6 October 2026 copy both returned an empty shell, so we couldn't list its folders.
X's older export on GitHub, last updated in April 2023, sets Bearer auth with {{bearer_token}} on the whole collection. It names the requests "Recent search" and "User by Username", on the old api.twitter.com host. The live copy may differ.
Step 1: Add X's collection, or import X's OpenAPI file
Open the X API v2 Collection link in X's Postman tutorial. X says this adds "a ready-to-use collection with all of the endpoints" to your Postman app.
You have two other routes:
- Import X's spec. X's docs say you can import
https://api.x.com/2/openapi.jsoninto Postman. Click Use resources or import, open Import, paste the URL and pick Postman Collection. - Import the GitHub file. It's from 2023, but it's plain JSON you can read before you trust it.
Step 2: Set the bearer token as a secret
Copy the bearer token from your app in the X Developer Console. Our guide to getting an X API key shows where.
Then store it where the collection looks for it:
- Select the "X API v2" environment in the top-right selector.
- Paste the token as the value of
bearer_token. - Click Secure next to the name. Postman's docs say to do this for sensitive data.
Postman keeps that value on your machine and doesn't sync it to its cloud unless you share it. X's tutorial still shows Postman's old "initial" and "current" value columns.
Using one setup only? Postman's docs say collection variables suit auth details, so a bearer_token collection variable works too. Each request should use Inherit auth from parent.
Step 3: Send a recent search
Open Recent search and turn on these params:
| Key | Value |
|---|---|
query |
from:XDevelopers -is:retweet |
max_results |
10 |
tweet.fields |
created_at,public_metrics |
Recent search covers the last 7 days and returns 10 to 100 posts per request. A full page of 10 costs $0.05 at X's rate. Our Twitter search API guide covers the operators.
What we ran. We have no X key. On 22 October 2026 we sent this search and the user lookup with curl, with the unfilled text {{bearer_token}} as the token. X answered both the same way:
{ "title": "Unauthorized", "type": "about:blank", "status": 401, "detail": "Unauthorized" }
Step 4: Look up a user by username
Open User by Username and set the username path variable to XDevelopers. Add user.fields with created_at,public_metrics. The request it sends:
GET https://api.x.com/2/users/by/username/XDevelopers?user.fields=created_at,public_metrics
X bills a user lookup as one user read, $0.010. More calls to paste are in our X API curl examples.
Test the same calls on Weir in Postman
We run Weir, a read-only API for public X and Reddit data, so weigh this part knowing that. Weir has no Postman collection; its OpenAPI file is the source.
- Import the spec. Paste
https://api.weirapp.io/openapi.jsoninto Import and pick Postman Collection. - Set
bearerTokento yourweir_live_key, as a Secure collection or environment variable. - Send "Get a public X profile" with the
userpath variable set toXDevelopers.
Why bearerToken? Weir's spec declares one bearer scheme. Postman's open-source converter, which we read on GitHub, turns that into Bearer auth with {{bearerToken}}, plus a baseUrl variable. We didn't run the import, so check the collection's Authorization tab after it.
The file loads with plain curl: we fetched it on 22 October 2026 and got OpenAPI 3.1.0 with 51 paths.
We ran the same lookup through Weir's MCP server, which calls the same operation. It charged 3 credits. Trimmed:
{
"id": "2244994945",
"username": "XDevelopers",
"name": "Developers",
"followersCount": 697846,
"createdAt": "2013-12-14T04:35:55.000Z"
}
For a search, open "Search public X posts with composable filters" and put this in the raw JSON body:
{ "fromUsers": ["XDevelopers"], "query": "-filter:nativeretweets", "limit": 10 }
A search costs 1 credit per call plus 1 per post. The x-credits-charged header, under the response's Headers tab, shows what each call cost:
Weir's figure assumes search pages of about 20 posts.
Why does Postman return 401?
- The variable shows red. It has no value, or the wrong environment is active.
- The name doesn't match. X's collection reads
bearer_token; an imported spec readsbearerToken. - The request has its own auth. Set its Auth Type to Inherit auth from parent.
- Weir says "not a recognised API key". We got that
401when we sent the unfilled{{bearerToken}}text.
When not to use Weir
- You need to post, like or DM. Weir is read-only, so test writes in X's collection.
- You need a contract with X itself. Use X's API.
- Price per post is all that matters. TwitterAPI.io lists $0.15 per 1,000 tweets, and it can post.
Weir reads public data only and isn't licensed by X, so access can change.
FAQ
Is there an official Twitter API Postman collection?
Yes. X's docs link an X API v2 collection and an X Ads API collection, as of October 2026. The v2 one lives in X's public workspace on postman.com. An older copy, last updated in 2023, is on X's GitHub.
Can I test the X API in Postman for free?
Postman isn't the cost; X's API is. X's pricing page has you buy credits upfront, and a post read costs $0.005. So a 10-post test search costs 5 cents. Weir gives 5,000 free credits a month for read-only tests.
How do I add a bearer token in Postman?
Open the collection's Authorization tab, pick Bearer Token, and enter {{bearer_token}}. Put the real token in an environment or collection variable, marked Secure. Then set each request to Inherit auth from parent.
Sources
All checked on 22 October 2026:
- X's Postman tutorial, read as Markdown: https://docs.x.com/tutorials/postman-getting-started
- X Tools and Libraries and the OpenAPI note: https://docs.x.com/tools-and-libraries and https://docs.x.com/tools/mcp
- X's v2 collection (renders only with JavaScript; contents not verified): https://www.postman.com/xapidevelopers/x-api-public-workspace/collection/34902927-2efc5689-99c6-4ab6-8091-996f35c2fd80
- X's older collection export, April 2023: https://github.com/xdevplatform/postman-twitter-api
- X OpenAPI spec 2.172 and pricing: https://api.x.com/2/openapi.json and https://docs.x.com/x-api/getting-started/pricing
- Postman docs on import, auth and variables: https://learning.postman.com/docs/getting-started/importing-and-exporting/importing-data, https://learning.postman.com/docs/use/send-requests/authorization/specifying-authorization-details and https://learning.postman.com/docs/use/send-requests/variables/variables
- Postman's OpenAPI converter: https://github.com/postmanlabs/openapi-to-postman
- TwitterAPI.io: https://twitterapi.io/pricing and https://docs.twitterapi.io/api-reference/endpoint/create_tweet_v2
- Weir: https://api.weirapp.io/openapi.json and https://docs.weirapp.io/billing
- Our calls: X's 401s to an unfilled token, and Weir's get_x_user for @XDevelopers (3 credits)