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.
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
- Go to Integrations > Tools and open the MCP tab.
- Add an MCP server over HTTP:
- Server URL:
https://api.okdata.online/mcp - Name:
okdata, and a Server Identifier such asokdata. Apps refer to the server by this identifier, so pick one you won't need to change.
- Server URL:
- Under the advanced options, add a custom header: name
Authorization, valueBearer okd_...with your full key. - Save. Dify connects and imports five tools:
find,describe,call,read_moreandaccount.
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.
- Go to Integrations > Tools, open the Swagger API tab and create a new custom tool.
- Import the schema from the URL
https://okdata.online/openapi.json. Dify lists every operation as a tool. - 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 theBearerprefix itself, so paste onlyokd_.... - Save, then add only the operations you need to your app or workflow, for example
bilibili_trends_listanddouyin_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 beAuthorizationand the value must start withBearer. Swagger tool: with auth type Bearer, paste the key withoutBearer, 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 includesretry_after_seconds; wait that long before the next call. No charge. - No tools after adding the MCP server. Check that the URL ends in
/mcpand that your Dify can reachhttps://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.
Read next
- The MCP server: the five tools and what to tell the agent.
- Douyin hot search: fields and price.
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 call | Result | Cost |
|---|---|---|
find {"query":"weibo hot search"} | weibo.trends.list · $0.002 per call · about 50 board entries per page | Free |
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 see | Why | Fix |
|---|---|---|
| Dify does not list the okdata tools | It 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 unauthorized | The 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_balance | The balance does not cover the most this call can cost. Nothing was charged. | Ask it to run account, then top up in the console. |