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 10 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 four tools:
find,describe,callandaccount.
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 {{cost:bilibili.trends.list1+douyin.trends.list1}}. 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 four tools and what to tell the agent.
- Douyin hot search: fields and price.
Updated 2026-11-12