Pay-per-request Twitter/X user lookup via x402 — $0.005 USDC per call on Base
What it does
twit.sh provides a payment-gated Twitter/X data API accessible via the x402 protocol. The `/users/by/username` endpoint lets you look up a Twitter/X user profile by screen name, returning full profile data including numeric ID, display name, bio, follower counts, and verification status in X v2 API-compatible JSON format. Payment is $0.005 USDC per request, settled on Base mainnet with no API keys, accounts, or OAuth flows required.
The broader twit.sh API covers a wide range of Twitter/X operations beyond user lookup: tweet retrieval and search, user timelines, followers/following lists, quote tweets, replies, retweets, community and list data, and X Articles in markdown. Authenticated actions (posting tweets, liking, bookmarking, retweeting, following/unfollowing) are also available using Twitter session credentials (auth_token and ct0 cookies). Prices range from $0.0025 to $0.01 USDC per call depending on the endpoint.
The API is designed for autonomous AI agents. When an unauthenticated request hits a protected endpoint, the server returns HTTP 402 with a machine-readable payment challenge. The agent pays in USDC on Base, retries with a payment proof header, and receives data. No gas is required on the agent side. A CLI skill (`npx twitsh`) is available for integration with Claude Code, Cursor, OpenClaw, and other agent frameworks.
Capabilities
Use cases
- —AI agents autonomously fetching Twitter/X user profiles and tweets without API key setup
- —Monitoring Twitter accounts, followers, and engagement metrics programmatically
- —Searching Twitter's full archive with advanced filters (date ranges, engagement thresholds, hashtags)
- —Retrieving X Community posts and members not available via the official X API
- —Automating Twitter actions (post, like, retweet, follow) through agent workflows
Fit
Best for
- —AI agents needing Twitter/X data without OAuth or API key registration
- —Developers who want pay-per-call pricing instead of monthly Twitter API subscriptions
- —Autonomous workflows that need to read and write to Twitter/X accounts
- —Accessing X Communities and Articles data not exposed by the official API
Not for
- —High-volume bulk data collection (pay-per-call costs add up)
- —Applications requiring official Twitter API compliance or enterprise SLAs
- —Users without USDC on Base mainnet for payment
Quick start
# Look up a Twitter user by username (x402 payment handled by agent)
curl -X GET 'https://x402.twit.sh/users/by/username?username=elonmusk'
# Returns 402 with payment challenge; after paying:
curl -X GET 'https://x402.twit.sh/users/by/username?username=elonmusk' \
-H 'X-PAYMENT: <payment_proof>'Example
Response
{
"data": {
"id": "44196397",
"name": "Elon Musk",
"username": "elonmusk",
"verified": true,
"description": "...",
"public_metrics": {
"tweet_count": 50000,
"followers_count": 190000000,
"following_count": 800
}
}
}Endpoint
Quality
Full OpenAPI 3.1 spec with all endpoints, parameters, and pricing. The 402 challenge is confirmed live. Response schemas are not formally defined for most GET endpoints (only action endpoints have response schemas), so the example response is inferred from the landing page description of 'X v2-compatible JSON'. Documentation is clear but thin (FAQ answers not expanded, /docs returns 404).
Warnings
- —Response schema for GET /users/by/username is not formally defined in the OpenAPI spec; the example response is inferred from the site description of 'X v2 API-compatible JSON'
- —Authenticated actions (post, like, follow, etc.) require raw Twitter session cookies (auth_token, ct0) passed as query parameters, which raises security concerns
- —The /docs, /pricing, and /api paths all return 404 — documentation lives only on the landing page
Citations
- —The /users/by/username endpoint costs $0.005 USDC per requesthttps://x402.twit.sh
- —Payment is settled in USDC on Base mainnet with no gas requiredhttps://x402.twit.sh
- —Data is returned in X v2 API-compatible JSON formathttps://x402.twit.sh
- —API prices range from $0.0025 to $0.01 USDC per callhttps://x402.twit.sh
- —A CLI skill is available via npx twitsh for AI agent integrationhttps://x402.twit.sh
- —Communities and Articles endpoints provide data not available in the official X APIhttps://x402.twit.sh