Skip to content
cheapxapi

For AI agents

X (Twitter) data for AI agents. MCP, REST and three workflows.

Point your agent at https://api.cheapxapi.com/mcp, or call the REST API from your own code. One API key, $0.0006 a call, JSON with the same fields every time.

Get an API key

No card. New accounts get a $1 promotional credit.

Connect your client.

Replace YOUR_KEY with the key from your dashboard. The MCP server has read-only tools; the full tool list is on the MCP server page.

claude mcp add --transport http cheapxapi https://api.cheapxapi.com/mcp \
  --header "x-api-key: YOUR_KEY"

Built for how agents call.

Per call
$0.0006
$0.60 per 1,000 calls, no seat or monthly fee
Per 1,000 posts
$0.03
Search and timelines, 20 posts a call
Per 1,000 profiles
$0.03
By ID, 20 profiles a call; followers 100 a call
Rate limit
10/s
2/s before the first top-up; 429 with Retry-After, not charged

No account: x402

An agent with a wallet can skip sign-up. Call a read-only endpoint without an API key and the API answers 402 Payment Required with the price. An x402 client pays $0.001 in USDC on Base (eip155:8453) and retries the call.

You pay only when data comes back: errors and empty results are not charged. With an API key the same call is $0.0006 from your balance. The MCP server and account actions such as posting still need a key.

curl -i "https://api.cheapxapi.com/twitter/user/info?userName=NASA"
# HTTP/2 402
# payment-required: <base64 JSON: x402Version 2, network eip155:8453, amount 1000 (= $0.001 USDC), payTo>

Pay in PAYMENT-SIGNATURE (x402 v2) or X-PAYMENT (v1); the receipt comes back in PAYMENT-RESPONSE.

Measured latency per endpoint: benchmarks.

Workflow 1

Cashtag sentiment triage

Search recent posts about a cashtag, take the three most liked, read their most liked replies, and have the model call the mood and list the claims worth checking.

4 calls per run: 1 search, 3 reply pages, $0.0006 each.

Needs pip install requests anthropic, CHEAPXAPI_KEY and ANTHROPIC_API_KEY.

import json, os, time, requests, anthropic

API = "https://api.cheapxapi.com"
HEADERS = {"x-api-key": os.environ["CHEAPXAPI_KEY"]}
MODEL = "claude-sonnet-5-5"  # any model works

def get(path, **params):
    r = requests.get(API + path, headers=HEADERS, params=params, timeout=75)
    if r.status_code == 429:  # over the per-second limit; not charged
        time.sleep(float(r.headers.get("retry-after", "1")))
        return get(path, **params)
    r.raise_for_status()
    return r.json()

def ask(prompt):
    msg = anthropic.Anthropic().messages.create(
        model=MODEL, max_tokens=800, messages=[{"role": "user", "content": prompt}])
    return msg.content[0].text

CASHTAG = "$NVDA"
posts = get("/twitter/tweet/advanced_search",
            query=f"{CASHTAG} lang:en min_faves:20", queryType="Latest")["tweets"]
context = []
for t in sorted(posts, key=lambda t: t["likeCount"], reverse=True)[:3]:
    replies = get("/twitter/tweet/replies/v2", tweetId=t["id"], queryType="Likes")["tweets"]
    context.append({"post": t["text"], "likes": t["likeCount"],
                    "author": t["author"]["userName"], "followers": t["author"]["followers"],
                    "top_replies": [r["text"] for r in replies[:10]]})

print(ask(f"Classify the sentiment on {CASHTAG} in these posts and replies as bullish, "
          "bearish or mixed, then list the three claims most worth fact-checking.\n\n"
          + json.dumps(context)))

Workflow 2

Mention and complaint escalation

Read the latest posts that mention your account, keep authors with a real audience, ask the model which ones are complaints, and pull the full profile of each one to escalate.

1 call for mentions, plus 1 per escalated author, $0.0006 each.

Needs pip install requests anthropic, CHEAPXAPI_KEY and ANTHROPIC_API_KEY.

import json, os, time, requests, anthropic

API = "https://api.cheapxapi.com"
HEADERS = {"x-api-key": os.environ["CHEAPXAPI_KEY"]}
MODEL = "claude-sonnet-5-5"  # any model works

def get(path, **params):
    r = requests.get(API + path, headers=HEADERS, params=params, timeout=75)
    if r.status_code == 429:  # over the per-second limit; not charged
        time.sleep(float(r.headers.get("retry-after", "1")))
        return get(path, **params)
    r.raise_for_status()
    return r.json()

def ask(prompt):
    msg = anthropic.Anthropic().messages.create(
        model=MODEL, max_tokens=800, messages=[{"role": "user", "content": prompt}])
    return msg.content[0].text

BRAND = "yourbrand"     # your X handle, without @
MIN_FOLLOWERS = 5000

mentions = get("/twitter/user/mentions", userName=BRAND)["tweets"]
for t in mentions:
    author = t["author"]
    if author["followers"] < MIN_FOLLOWERS or author["userName"].lower() == BRAND:
        continue
    verdict = ask(f"Is this post a customer complaint about @{BRAND}? Start with COMPLAINT "
                  f"or OTHER, then give one line of reason.\n\n{t['text']}")
    if verdict.startswith("COMPLAINT"):
        profile = get("/twitter/user/info", userName=author["userName"])["data"]
        print(f"ESCALATE {t['url']} @{profile['userName']} "
              f"({profile['followers']} followers): {verdict}")

Workflow 3

Thread and narrative summarizer

Read an account's latest posts, open the threads behind the ones that started a conversation, keep the author's own posts, and summarize each thread.

1 timeline call, plus 1 per thread, $0.0006 each.

Needs pip install requests anthropic, CHEAPXAPI_KEY and ANTHROPIC_API_KEY.

import json, os, time, requests, anthropic

API = "https://api.cheapxapi.com"
HEADERS = {"x-api-key": os.environ["CHEAPXAPI_KEY"]}
MODEL = "claude-sonnet-5-5"  # any model works

def get(path, **params):
    r = requests.get(API + path, headers=HEADERS, params=params, timeout=75)
    if r.status_code == 429:  # over the per-second limit; not charged
        time.sleep(float(r.headers.get("retry-after", "1")))
        return get(path, **params)
    r.raise_for_status()
    return r.json()

def ask(prompt):
    msg = anthropic.Anthropic().messages.create(
        model=MODEL, max_tokens=800, messages=[{"role": "user", "content": prompt}])
    return msg.content[0].text

HANDLE = "NASA"
latest = get("/twitter/user/last_tweets", userName=HANDLE)["data"]["tweets"]
starters = [t for t in latest if not t["isReply"] and t["replyCount"] > 0][:3]
for root in starters:
    thread = get("/twitter/tweet/thread_context", tweetId=root["id"])["tweets"]
    own = [t["text"] for t in thread if t["author"]["userName"].lower() == HANDLE.lower()]
    print(root["url"])
    print(ask(f"Summarize this thread by @{HANDLE} in three bullet points:\n\n"
              + "\n---\n".join(own or [root["text"]])))

Questions.

MCP or the REST API: which should my agent use?

Use the MCP server when a model chooses the calls itself (Claude Code, Cursor, agent frameworks). Use the REST API when your own code decides what to fetch, as in the workflows on this page. Both use the same API key and the same price per call.

What does an agent run cost?

$0.0006 per call, whether it comes through MCP or REST. A search or timeline call returns up to 20 posts, so most agent steps cost a fraction of a cent. There is no seat or monthly fee.

What happens when the agent calls too fast?

It gets HTTP 429 with a Retry-After header, and that call is not charged. Accounts that have never topped up get 2 requests per second; accounts that have paid get 10.

Can an agent pay without signing up?

Yes, on the REST API's read-only endpoints. Call one without an API key and the API answers HTTP 402 Payment Required with the price; an x402 client pays $0.001 in USDC on Base and retries the call; it is charged only when data comes back. At $0.001 that is 67% more than the $0.0006 a call costs with a key, so an agent that runs every day is cheaper with an account. The MCP server and account actions still need a key.

Can an agent post or reply on X?

Through the REST API, yes, as an X account you log in to. The MCP server is read-only, so a model connected over MCP cannot post.