Use okdata in n8n: HTTP Request and MCP Client Tool

Build an n8n workflow that pulls Xiaohongshu, Douyin or X data from okdata on a schedule, or give an n8n AI Agent the whole catalog through MCP.

Here is the workflow this page builds: every morning at nine, n8n searches Xiaohongshu for your brand name, newest first, and drops the new notes into your team's chat channel. Nobody has to remember to check. The second half shows how to give an n8n AI Agent all 51 endpoints at once, so it can answer questions like "what is trending on Bilibili today?" by itself.

Before you start

  • n8n, cloud or self-hosted. The MCP part needs version 1.104 or later; 1.114 or later is easier, because the right transport is the default there.
  • An API key from okdata, starting with okd_. New keys come with $0.10 of credit. The quickstart explains how to get one.

Elsewhere we keep the key in the OKDATA_API_KEY environment variable. In n8n the right place is a credential: n8n stores it encrypted, and it stays out of the workflow when you export or share it.

Step 1: save the key as a credential

  1. Create a new credential and pick Bearer Auth.
  2. Paste your key into Bearer Token (just okd_..., without the word Bearer; n8n adds it).
  3. Name it okdata and save.

If your n8n has no Bearer Auth option, use Header Auth instead: Name Authorization, Value Bearer okd_....

Step 2: a scheduled search with the HTTP Request node

  1. Start with a Schedule Trigger set to every day at 09:00.
  2. Add an HTTP Request node:
    • Method: GET
    • URL: https://api.okdata.online/v1/xiaohongshu/notes/search
    • Authentication: Generic Credential Type, then Generic Auth Type: Bearer Auth, and choose the okdata credential.
    • Turn on Send Query Parameters, choose Using Fields Below, and add two: query = your brand name, sort = latest.
  3. Run the node once. The notes are in data.items; what the call cost is in meta.billing.amount.
  4. Add a Split Out node on data.items, then your Slack, Feishu, email or Google Sheets node.

Every endpoint works the same way: the URL is https://api.okdata.online/v1/ plus the endpoint id with dots turned into slashes, and the parameters go in the query string. Each endpoint page lists them.

Step 3 (optional): give an AI Agent the whole catalog

Add an AI Agent node with a chat model, then attach an MCP Client Tool as its tool:

  • Endpoint: https://api.okdata.online/mcp
  • Server Transport: HTTP Streamable
  • Authentication: Bearer Auth, with the same okdata credential
  • Tools to Include: All

The agent now sees four tools: find and describe to look up endpoints and prices for free, call to fetch data, and account for the balance. Put a budget into the agent's system message, for example "never make more than three paid calls per request".

If you only need one endpoint as a tool, you can attach the HTTP Request node from step 2 to the agent instead, and let the model fill the keyword with {{ $fromAI('query', 'keywords to search for') }} in the query field.

A first prompt to try

Open the chat on the AI Agent and type:

What is on the Bilibili popular board right now? Give me the top ten with their
heat and links, and tell me what the okdata calls cost.

What it costs

The scheduled search in step 2 makes one call a day. Xiaohongshu note search is $0.02 per page, so that's about $0.60 a month. The Bilibili prompt above costs $0.002. The agent's find, describe and account calls are free, and failed calls never cost anything.

Watch loops: an n8n workflow that pages through results until page.has_more is false can run longer than you expect. Cap it with a fixed number of pages.

When something goes wrong

  • 401 unauthorized. The credential is missing, or the token has a stray space or the word Bearer twice. Open the credential and paste the key again.
  • 402 insufficient_balance. Not enough balance for the call. Nothing was charged. Top up and run it again; prices are on the pricing page.
  • 429 rate_limited. Too many calls in a short burst, often from a loop. The response includes retry_after_seconds. In the HTTP Request node's settings, turn on Retry On Fail with a wait at least that long, or slow the loop down. Rate-limited calls are free.
  • The MCP Client Tool shows no tools. Check the n8n version, that Server Transport is HTTP Streamable, and that the endpoint ends in /mcp. A node added on an older n8n may still show an "SSE Endpoint" field; delete it and add a fresh MCP Client Tool.

Updated 2026-11-12