Skip to main content
Use n8n when you want Twexapi research results to trigger database writes, Slack alerts, CRM updates, or scheduled follow-up jobs.

Prerequisites

  • A Twexapi API key
  • n8n Cloud or self-hosted n8n
  • A webhook URL for MCP handoff recipes
  • Optional Slack, Google Sheets, Airtable, or database credentials

API key credential

Create a reusable n8n credential for Twexapi REST calls:
FieldValue
AuthenticationHeader Auth
Header nameAuthorization
Header valueBearer YOUR_API_KEY
Base URLhttps://api.twexapi.io
For MCP-capable AI Agent nodes, configure the MCP Client Tool with https://api.twexapi.io/mcp and header x-api-key: YOUR_API_KEY.

Pattern

  1. Create an n8n Webhook trigger.
  2. Ask an MCP-capable agent to return strict Twexapi handoff JSON.
  3. POST the JSON to the n8n webhook.
  4. Use Set, IF, Split Out, and HTTP Request nodes to process rows.

Webhook payload

{
  "query": "AI agents",
  "route_used": "/twitter/advanced_search",
  "has_more": true,
  "next_cursor": "cursor_123",
  "tweets": [
    {
      "tweet_id": "1803006263529541838",
      "author_username": "openai",
      "created_at": "2026-07-02T10:00:00Z",
      "text": "Example tweet text"
    }
  ]
}

Suggested n8n nodes

StepNodePurpose
1WebhookReceive MCP handoff JSON.
2IFStop if tweets is empty.
3Split OutProcess each tweet row.
4Database or SheetsUpsert by tweet_id.
5HTTP RequestContinue through Twexapi REST if the workflow owns the next API call.

Result handoff

Use an Edit Fields node after each MCP or HTTP Request step when the next node only needs stable fields.
SourceStore as
Tweet IDtweet_id
Texttext
Author usernameauthor_username
Created timecreated_at
Pagination cursornext_cursor
MCP routeroute_used

Recipe 1: AI agent X research with MCP

1

Add an AI Agent node

Use your preferred chat model.
2

Add an MCP Client Tool

Configure https://api.twexapi.io/mcp with x-api-key.
3

Prompt the agent

Ask it to call explore, then twexapi_request, and return only JSON.
4

Route rows

Split tweets and write each row to your destination.
Suggested prompt:
Find recent posts about AI agents in fintech, group them by theme, and list 5 accounts worth monitoring.
Return only JSON with route_used, tweets, has_more, and next_cursor.

Recipe 2: Monitor-style Slack alert

Use this when the workflow should alert a Slack channel after receiving a row from an MCP agent or a scheduled REST job.
NodePurpose
Webhook TriggerReceive Twexapi handoff JSON.
Split OutIterate over tweets.
SetFormat author_username, text, and public_url.
SlackPost the alert.
Slack message template:
@{{$json.author_username}}
{{$json.text}}
{{$json.public_url || "https://x.com/i/web/status/" + $json.tweet_id}}

Recipe 3: Extraction to Google Sheets

For larger follower or reply exports, let the agent choose the endpoint with MCP, then run the repeated pages through REST.
Sheet columnTwexapi field
Tweet IDtweet_id
Authorauthor_username
Texttext
Created Atcreated_at
URLpublic_url or https://x.com/i/web/status/{tweet_id}

Direct REST continuation

GET https://api.twexapi.io/twitter/global-trending/tweets
Authorization: Bearer YOUR_API_KEY
Keep MCP for agent discovery and handoff. Use REST for scheduled, deterministic n8n jobs.

Testing checklist

  • Use n8n Test Step on every HTTP Request node.
  • Confirm every REST request includes Authorization: Bearer YOUR_API_KEY.
  • Confirm every MCP Client Tool request includes x-api-key.
  • Confirm webhooks receive JSON, not prose.
  • On 429, pause before retrying and preserve next_cursor.