For AI

Use okdata in Dify: MCP server or Swagger API tool

Add okdata to Dify as an MCP server or as a Swagger API tool, so your agents and workflows can read hot lists, posts and comments from 17 platforms.

Updated 2026-11-12

By the end, a Dify app on your team can pull live social data. One we like: a topic-ideas assistant for the content team. Someone types "what's hot on Bilibili and Douyin today? give me three video ideas for a coffee brand", and the agent reads both hot lists, checks a few videos, and answers with ideas and links. Dify offers two ways in. The MCP server is quicker and gives the agent every endpoint; the Swagger API tool lets you hand-pick endpoints for a fixed workflow.

Before you start

  • Dify Cloud, or a self-hosted Dify recent enough to have custom headers on MCP servers (1.9 or later).
  • An API key from okdata, starting with okd_. New keys come with $0.10 of credit. The quickstart explains how to get one.

On our other pages the key lives in the OKDATA_API_KEY environment variable. In Dify you paste it into the tool's settings instead, where it's stored with the workspace. Everyone who can run apps using that tool spends your balance, so use a key meant for this workspace.

Way 1: add the MCP server

  1. Go to Integrations > Tools and open the MCP tab.
  2. Add an MCP server over HTTP:
    • Server URL: https://api.okdata.online/mcp
    • Name: okdata, and a Server Identifier such as okdata. Apps refer to the server by this identifier, so pick one you won't need to change.
  3. Under the advanced options, add a custom header: name Authorization, value Bearer okd_... with your full key.
  4. Save. Dify connects and imports five tools: find, describe, call, read_more and account.

Then open your Agent app (or an Agent node in a workflow), add the okdata tools, and put a budget into the instructions, for example "never make more than three paid calls per question".

Way 2: a Swagger API tool from the OpenAPI file

Use this when a workflow should always call the same endpoint, such as one hot list every morning.

  1. Go to Integrations > Tools, open the Swagger API tab and create a new custom tool.
  2. Import the schema from the URL https://okdata.online/openapi.json. Dify lists every operation as a tool.
  3. Set the authorization method to API Key, in the Header, with auth type Bearer, key Authorization, and your key as the value. With Bearer selected, Dify adds the Bearer prefix itself, so paste only okd_....
  4. Save, then add only the operations you need to your app or workflow, for example bilibili_trends_list and douyin_trends_list.

A first prompt to try

What's on the Bilibili popular board and the Douyin hot search list right now?
Suggest three short-video ideas for a coffee brand, each tied to one trending
topic, with the link. Tell me what the okdata calls cost.

What it costs

Looking up endpoints and prices with find and describe is free, and so is account. The prompt above needs two hot lists, $0.002 for Bilibili and $0.002 for Douyin, so $0.004. If the agent also searches, a page of Douyin video search is $0.02 and a page of Xiaohongshu note search is $0.02. Failed calls are free.

When something goes wrong

  • 401 unauthorized. MCP server: the header name must be Authorization and the value must start with Bearer . Swagger tool: with auth type Bearer, paste the key without Bearer, or Dify sends it twice.
  • 402 insufficient_balance. Not enough balance for the call. Nothing was charged. Top up and run again; prices are on the pricing page.
  • 429 rate_limited. Too many calls in a short time, often a loop in a workflow. The response includes retry_after_seconds; wait that long before the next call. No charge.
  • No tools after adding the MCP server. Check that the URL ends in /mcp and that your Dify can reach https://api.okdata.online; a self-hosted Dify behind a strict firewall may not. Then refresh the server's tool list.
  • The Swagger import fails. Paste the file's contents instead of the URL and read the error. If it still fails, use way 1.

Check it works

“List the okdata tools.”

okdata is connected with 5 tools: find describe the data you need in words; get up to five capabilities with what they need, the price and a ready call. It never offers another platform in place of the one asked for; describe read the full contract of one to five capabilities: parameters, links taken, price and the most a call can cost, paging, fields and an example item; call fetch one page of data as text: the first lines say what it cost, the balance left and how to get the next page. Failed calls are free; max_price caps a call; read_more read the rest of an answer that was cut at about 20 KB, or the same result in another view, for 24 hours; account balance and the key’s spending limits, a receipt for one call, usage by day or capability; which capabilities are up, even without a key. Only call costs money. The catalog has 214 endpoints on 17 platforms.

None of this costs anything.

A first conversation

“What is on Weibo hot search right now?”

Tool callResultCost
find {"query":"weibo hot search"}weibo.trends.list · $0.002 per call · about 50 board entries per pageFree
call {"capability":"weibo.trends.list"}One page of about 50 entries$0.002

2 tool calls · 1 charged · $0.002

If something is off

What you seeWhyFix
Dify does not list the okdata toolsIt was started before the server was added, or the address differs from the one above.Check the entry, then restart Dify or start a new chat.
find works, call says unauthorizedThe key did not arrive. find and describe need none, so they still answer.Check the header is Authorization with Bearer and a key starting with okd_, then restart.
call says insufficient_balanceThe balance does not cover the most this call can cost. Nothing was charged.Ask it to run account, then top up in the console.

Connect once, then just ask.

Every new key comes with $0.10 to try it. One sentence connects your agent.

Start free
Connect your AI

Paste this into your agent

Read https://okdata.online/agents.md and set up okdata for me; my key is in the OKDATA_API_KEY environment variable.

Claude Code, Cursor, Codex and other agents that can open a link set themselves up from it.

MCP serverhttps://api.okdata.online/mcp