Twitter API — Getting Started — FetchLayer Docs
Documentation menu
FetchLayer FetchLayer API

Getting Started

Get your first Twitter/X API call working in under two minutes.

1. Get your API key

Sign up for a FetchLayer account and generate an API key from the dashboard. Free tier included — no credit card required.

2. Make your first request

Call any endpoint with curl, or use the TypeScript SDK.

curl

bash
curl -X POST https://api.fetchlayer.dev/twitter/search \
  -H "Authorization: Bearer ss-your-key" \
  -H "Content-Type: application/json" \
  -d '{"query":"openai","product":"Latest","count":5}'

TypeScript SDK

npm install @fetchlayer/twitter

typescript
import { FetchLayer } from '@fetchlayer/twitter';

const client = new FetchLayer({ apiKey: 'ss-your-key' });

const { results } = await client.search({
  query: 'openai',
  product: 'Latest',
  count: 5,
});

Tip

Use "product": "Top" instead of "Latest" to bias results toward high-engagement tweets rather than strictly reverse-chronological ones.

3. Understand the response

Every endpoint returns structured JSON. The response shape varies by endpoint, but request and authentication patterns stay consistent across the Twitter surface.

json
{
  "results": [
    {
      "id": "1942939879222220800",
      "text": "Example search result from X/Twitter",
      "author": "example_user",
      "createdAt": "2026-07-02T11:25:00.000Z",
      "url": "https://x.com/example_user/status/1942939879222220800"
    }
  ]
}

Next steps