READ API LIVEBuild on /v1 for search, profiles, timelines, audience graph, and tweet context.READ DOCS

Use case · AI & agents

X/Twitter data your AI agents can actually use

Feed current X/Twitter posts into RAG, agents, and LLM pipelines. xfetch returns normalized JSON with deduped authors and one-call workflow endpoints — so you skip the glue code and the scraper maintenance.

See the endpoints
RAG ingestionillustrative

One poll · normalized records

  • Vectorless RAG — retrieval that reasons over documents instead of embeddingsrag builder
  • We cut agent token burn ~40% by caching parsed context between runsml infra lead
  • Shipped an MCP server for our internal docs over a weekendindie ai builder

Deduped & ready

  • 20 tweets · 18 unique authorsone response, no join
  • { id, text, author, url }→ your vector store

built from GET /v1/search/recent/enriched · 41 credits

One call, ingestion-ready records

Most AI features need fresh, structured public data — and X/Twitter is where a lot of it surfaces first. The slow part is never the model; it is normalizing raw responses, deduping authors, and keeping a scraper alive. One call to enriched search returns matched tweets and a deduped authors[] array as normalized JSON, and X-style operators — min_faves:, lang:, -filter:replies — keep what you ingest signal, not the firehose.

GET/v1/search/recent/enriched
ingest
Request
GET /v1/search/recent/enriched?query="ai agents" min_faves:50 lang:en -filter:replies&limit=20
Authorization: Bearer <api_key>
Response shape
{
  "data": {
    "tweets": [ { "id", "text", "author_id" } … ],
    "authors": [ { "id", "username", "verified" } … ]
  },
  "meta": { "credits": { "charged": 41 } }
}

One call for full tweet context

Summarizers and moderation agents need more than a single tweet. One call returns the tweet, its author, its quotes, and its retweeters as named blocks — no multi-call stitching.

GET/v1/tweets/:id/context
enrich
Request
GET /v1/tweets/1234567890/context
Authorization: Bearer <api_key>
Response shape
{
  "data": {
    "tweet": { … },
    "author": { … },
    "quotes": [ … ],
    "retweeters": [ … ]
  },
  "meta": { "credits": { "charged": 3 } }
}

A contract your agent can read

Point a coding agent at these and it can integrate without hand-holding — the API describes itself. For six common read workflows, MCP-capable agents can connect straight to the hosted MCP server without writing those HTTP calls.

OpenAPI schema

Every /v1 and /2 endpoint, typed — point your codegen or coding agent at it.

/openapi.json

LLM context

A compact map of the API for a coding agent to read before it integrates.

/llms.txt

Full LLM context

The long-form context: endpoints, pricing rules, and examples in one file.

/llms-full.txt

Hosted MCP server

Point a remote-MCP-compatible agent at the hosted server and it gets read-only X data tools — search, profiles, tweet context — on the same credits.

/docs/mcp

Getting X data into an AI pipeline

DimensionOfficial X APIScrapers & DIYxfetch
Ingestion-ready outputOfficial envelopes — join, paginate, and retry across callsRaw page-shaped payloads you parse and dedupeOne call returns normalized tweets + deduped authors[]
Agent integrationOpenAPI + official SDKsVaries by vendor; often none/openapi.json + /llms.txt + hosted MCP server tools
Pricing modelTiered contractsPer-request or per-resultCredits — a base plus per-item, shown in meta.credits
MaintenanceTrack API changesFix breakage when pages changeStable contract, opaque pagination tokens

Copy-paste starter

A dependency-free TypeScript starter: query enriched search and emit one normalized record per tweet, ready for a vector store.

ingest.ts
/**
 * Minimal X/Twitter -> RAG ingestion with xfetch. No dependencies.
 * Run: XFETCH_API_KEY=xf_... npx tsx ingest.ts
 */
const API = "https://api.xfetch.io";
const KEY = process.env.XFETCH_API_KEY;
const QUERY = '("ai agents" OR "llm app" OR rag) min_faves:50 lang:en -filter:replies';

async function main() {
  if (!KEY) throw new Error("Set XFETCH_API_KEY");

  const url = new URL("/v1/search/recent/enriched", API);
  url.searchParams.set("query", QUERY);
  url.searchParams.set("limit", "20");

  const res = await fetch(url, { headers: { Authorization: `Bearer ${KEY}` } });
  if (!res.ok) throw new Error(`xfetch ${res.status}`);
  const body = await res.json();

  const data = body.data ?? { tweets: [], authors: [] };
  const authors = new Map();
  for (const a of data.authors) authors.set(a.id, a);

  // One normalized record per tweet — ready for embeddings or a vector store.
  const records = data.tweets.map((t) => ({
    id: t.id,
    text: t.text,
    author: authors.get(t.author_id)?.username ?? t.author_id,
    url: `https://x.com/i/web/status/${t.id}`,
    created_at: t.created_at
  }));

  console.log(JSON.stringify(records, null, 2));
  console.log("Credits charged:", body.meta?.credits?.charged);
}

main().catch((e) => { console.error(e); process.exit(1); });

Related

Twitter API alternative

How xfetch compares to the official X API for read workflows.

Read →

Bitcoin social intelligence

A vertical example: track narratives, key voices, and tweet context on X.

Read →

Account monitors

When the job is one account, skip polling — a monitor pushes new posts to your webhook or Discord the moment they're posted.

Read →

API reference

Every /v1 and /2 read endpoint, with request and response shapes.

Read →

FAQ

What is xfetch for AI agents?
xfetch is a self-serve X/Twitter data API that returns normalized JSON for AI. One call to /v1/search/recent/enriched gives you matched tweets and a deduped authors[] array, ready for RAG, embeddings, and agents — with a machine-readable contract (/openapi.json, /llms.txt) and a hosted MCP server agents can connect to directly. Read-only over public data — safe to hand to an agent — and priced in credits.
How do I get X/Twitter data into a RAG or LLM pipeline?
Call GET /v1/search/recent/enriched for a query and you get matched tweets plus a deduped authors[] array as normalized JSON — drop the records straight into embeddings or a vector store. Add X-style operators such as min_faves:, lang:, and -filter:replies to the query so the pipeline ingests high-signal posts, not the raw firehose. No client-side join and no scraper to maintain.
Does xfetch return normalized JSON for LLMs and agents?
Yes. /v1 returns clean, named blocks — tweets, authors, and workflow responses such as { user, recent_tweets } — so agents reason over the data instead of parsing raw payloads.
Can an AI coding agent discover the xfetch API automatically?
Yes. /openapi.json describes every endpoint, and /llms.txt plus /llms-full.txt give a coding agent a machine-readable map of the API, its pricing rules, and examples to read before integrating. MCP-capable agents can use six hosted tools for search, profiles, tweet context, timelines, and the follow graph without writing those HTTP calls — see /docs/mcp.
How much does it cost to ingest tweets for AI?
You pay in credits per returned item: enriched search costs a base credit plus 2 credits per returned tweet (a full 20-tweet page is 41 credits), and single-object lookups are 1 credit. Pulling 20 enriched tweets every hour runs about 29,520 credits a month, roughly $4.43 at the pay-as-you-go rate — a fraction of the $19 Starter plan's 180,000 monthly credits. New accounts start with free credits, failed or rate-limited calls are never charged, and /pricing has the full table.
Can I use xfetch with my agent framework?
Yes — two ways in. Point any remote-MCP-compatible client at xfetch's hosted MCP server with your API key to get read-only tools for search, profiles, tweet context, timelines, and the follow graph. Or call the REST API from any language with bearer-token auth; /openapi.json and /llms.txt help coding agents wire it up.
Is this scraping, and do credits expire?
You code against xfetch's stable, provider-neutral API contract, not a brittle scraper — responses are normalized and pagination tokens are opaque. Free and pay-as-you-go credits do not expire; monthly-plan credits renew each period.

Start in 60 seconds
with Google.

Sign in, mint an API key, and call the workflow your product needs. 1,000 credits free to start. Failed calls, rate limits, and service-side errors are never charged.