100 free credits. No credit card required. Get a key

How to get X (Twitter) data

Checked Code run live

X’s API is pay-per-use with no free plan: $0.005 for every post you read, so $0.10 for a page of 20. A data API that reads what X shows logged-out visitors returns an account’s latest posts with views, likes and media in the X API v2 shape, 1 credit a page.

The official X API

X sells API access per resource read, from prepaid credits:

  • $0.005 per post read and $0.010 per user read; writes cost more ($0.015 a post, $0.200 with a URL).
  • Pay-per-use is capped at 3 million post reads a month; above that you need an Enterprise contract with unpublished prices.
  • The legacy Basic and Pro plans moved to pay-per-use in 2026. You need a developer account, an app and a saved card before the first call.

Sources: X API pricing, X API rate limits.

Quick start

  1. Get a keySign up with an email code: 100 free credits, no card. An agent can sign itself up with POST https://api.groundsocial.dev/v1/agent/signup.
  2. Set it in your shellexport GROUNDSOCIAL_API_KEY=gs_live_…
  3. Make the callAn account’s latest posts: GET /v1/x/users/NASA/tweets, 1 credit.
curl "https://api.groundsocial.dev/v1/x/users/NASA/tweets" \
  -H "Authorization: Bearer $GROUNDSOCIAL_API_KEY"

Sample response

Trimmed from the real response on 27 November 2026: lists cut to their first items and long strings shortened. Every field is described in the tutorial.

json
{
  "data": [
    {
      "id": "2126050028032872522",
      "text": "RT @astro_anil: From space to Earth: wishing you a happy thanksgiving.  From this vantage…",
      "created_at": "2026-11-26T20:26:41.000Z",
      "author_id": "11348282",
      "conversation_id": "2126050028032872522",
      "lang": "en",
      "source": "Twitter for iPhone",
      "edit_history_tweet_ids": [
        "2126050028032872522"
      ]
    }
  ],
  "includes": {
    "users": [
      {
        "id": "11348282",
        "name": "NASA",
        "username": "NASA",
        "created_at": "2007-12-19T20:20:32.000Z",
        "description": "Making the seemingly impossible, possible. ✨",
        "location": "Pale Blue Dot",
        "url": "https://t.co/9NkQJKAnuU",
        "protected": false
      }
    ],
    "tweets": [
      {
        "id": "2125971502923129200",
        "text": "From space to Earth: wishing you a happy thanksgiving.  From this vantage point there is s…",
        "created_at": "2026-11-26T15:14:39.000Z",
        "author_id": "1456357980216066048",
        "conversation_id": "2125971502923129200",
        "lang": "en",
        "possibly_sensitive": false
      }
    ],
    "media": [
      {
        "type": "video",
        "width": 1080,
        "height": 1920,
        "duration_ms": 108466
      }
    ]
  },
  "meta": {
    "result_count": 20,
    "newest_id": "2126050028032872522",
    "oldest_id": "2123798314843787300",
    "next_token": "11i1jiz63kysz34d",
    "view": "timeline"
  }
}

Get every page

/v1/x/users/NASA/tweets returns posts a page at a time, and each page costs 1 credit. Pass the response’s meta.next_token back as after to /v1/x/users/NASA/tweets/next until it runs out.

// Collect up to 3 pages of posts.
const first = 'https://api.groundsocial.dev/v1/x/users/NASA/tweets'
const next = 'https://api.groundsocial.dev/v1/x/users/NASA/tweets/next'
const items: unknown[] = []
let cursor: string | undefined
for (let page = 0; page < 3; page++) {
  const url = new URL(cursor ? next : first)
  if (cursor) url.searchParams.set('after', cursor)
  const res = await fetch(url, {
    headers: { Authorization: `Bearer ${process.env.GROUNDSOCIAL_API_KEY}` },
  })
  if (!res.ok) throw new Error((await res.json()).error.hint)
  const data = await res.json()
  items.push(...(data.data ?? []))
  cursor = data.meta?.next_token ?? undefined
  if (!cursor) break
}
console.log(items.length, 'posts')

What else you can get from X

What you getEndpointCredits
An account’s latest postsGET /v1/x/users/NASA/tweets1
A profile with follower countsGET /v1/x/users/NASA1
One post with views and top repliesGET /v1/x/tweets/15853419846794690561
A video post’s transcriptGET /v1/x/tweets/1585341984679469056/transcript2
Trending postsGET /v1/x/trends/tweets1

Each row links to its tutorial. Every X endpoint and price: X API.

Tips

  • Field names follow the X API v2 (data, includes.users, public_metrics.impression_count), so code written for the official API needs few changes.
  • Keyword search, full reply threads and follower lists are not switched on yet: those endpoints answer 503 upstream_unavailable and are never charged.
  • To watch an account, keep meta.newest_id and treat any post with a higher id as new.

Use it from Claude or Cursor (MCP)

Every endpoint is also an MCP tool on the remote server https://api.groundsocial.dev/mcp. The ?platforms=x below loads only the X tools. The client signs in with OAuth, or send your key as a Bearer token. Tools used in this guide: x_user_tweets, x_user_get, x_tweet_get, x_tweet_transcript, x_trends_tweets.

claude mcp add --transport http groundsocial "https://api.groundsocial.dev/mcp?platforms=x"

Setup for ChatGPT, VS Code, Windsurf, n8n and others: MCP client setup.

Pricing

Pay per call from prepaid credits; no subscription. 100 free credits cover the examples on this page. Costs below are at the credit packs’ highest and lowest rates.

JobCreditsCost
Latest posts of 1,000 accounts1,000$1.00 → $0.40
1,000 single posts with metrics1,000$1.00 → $0.40
1,000 profiles1,000$1.00 → $0.40

FAQ

How does that compare with X’s own price?

A page of 20 posts is $0.10 on X’s pay-per-use and 1 credit here. X’s API can do things this can’t, such as full-archive search and posting.

Why do some accounts return only a few posts?

For some accounts X shows logged-out visitors only their latest originals. Then meta.view is recent_originals and there is no next page.

Can I post or like?

No. It is read-only.

Are failed calls charged?

No. A target that does not exist answers 404 target_not_found, an upstream failure answers 503, and neither costs anything. Credits never expire.

Is Groundsocial official?

No. Groundsocial is an independent API that reads what the platform shows a logged-out visitor. X is a trademark of X Corp. We are not affiliated with or endorsed by X Corp.

Go deeper

X is a trademark of X Corp. We are not affiliated with or endorsed by X Corp.

Try it on your own data

One key for X and every other platform, over REST or MCP. Free credits on signup, no card.