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

  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 four tools: find, describe, call 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 {{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 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.

Updated 2026-11-12