Use okdata in Claude Code: social data through MCP
Add the okdata MCP server to Claude Code with one command. Claude can then pull posts, comments and hot lists from 10 platforms and save them as files.
When you finish this page, Claude Code can fetch public data from Xiaohongshu, Douyin, X, YouTube and the other okdata platforms while it works in your folder. Say you want a spreadsheet of this week's Xiaohongshu notes about sunscreen for a Monday meeting. You ask in plain words; Claude picks the right endpoint, tells you the price, fetches two pages and writes notes.csv next to your other files. Nobody writes API code.
Before you start
- Claude Code installed: typing
claudein a terminal opens a session. - An API key from okdata, starting with
okd_. New keys come with $0.10 of credit, enough for several searches. The quickstart explains how to get one. - The key stored in the
OKDATA_API_KEYenvironment variable, so it never appears in a config file or in the chat. On a Mac, add this line to~/.zshrc(on Linux,~/.bashrc) and open a new terminal:
export OKDATA_API_KEY="okd_..."
Add the server
Pick one of the two ways. Both send the same header, Authorization: Bearer <key>, to https://api.okdata.online/mcp.
For yourself, in every project. Run this once:
claude mcp add --transport http --scope user okdata https://api.okdata.online/mcp \
--header 'Authorization: Bearer ${OKDATA_API_KEY}'
Keep the single quotes. They stop your shell from pasting the key itself into Claude Code's settings file; Claude Code saves the variable name and reads the value each time it starts.
For a team, in one project. Put a .mcp.json file in the project root:
{
"mcpServers": {
"okdata": {
"type": "http",
"url": "https://api.okdata.online/mcp",
"headers": { "Authorization": "Bearer ${OKDATA_API_KEY}" }
}
}
}
The file holds no secret, so you can commit it. Each teammate sets their own OKDATA_API_KEY. The first time Claude Code opens the project, it asks whether to use the servers in .mcp.json; approve okdata.
Check that it worked
Run claude mcp list. The okdata line should say Connected. Inside a session, /mcp shows the server with four tools: find, describe, call and account.
Then ask Claude: "Use the okdata account tool and tell me my balance." A balance in the answer means the key arrived. That check costs nothing.
A first prompt to try
Using okdata, find the Xiaohongshu note search endpoint and tell me its price.
Then search "sunscreen", newest first, two pages at most. Save title, author,
likes and url of each note to notes.csv and tell me what it cost.
Claude will usually call find, then describe, then call twice. You can watch each step and approve it.
What it costs
find, describe and account are free. Only call spends money, at the price describe reports. Xiaohongshu note search is $0.02 per page of about 20 notes, so the prompt above costs at most $0.04. A Douyin hot list is $0.002. Failed calls are never charged.
Agents like to be thorough. Give Claude a limit up front: "say what it will cost first, and stop after three pages."
When something goes wrong
unauthorized(401). The key did not reach the server. The server still lists its tools andfindworks without a key, so it can look fine until the firstcall. Run[ -n "$OKDATA_API_KEY" ] && echo set || echo missingin the terminal you start Claude from, fix the variable, and restart Claude Code.insufficient_balance(402). The balance cannot cover the call, so nothing was charged. Ask foraccountto see the balance, top up, and try again. Prices are on the pricing page.rate_limited(429). Too many calls in a short burst. The error includesretry_after_seconds; wait that long and repeat the same call. Rate-limited calls are free.- No tools, or
Failed to connect. Check that the URL ends in/mcpand that your network or proxy lets you reachhttps://api.okdata.online. Opening that URL in a browser shows "Method not allowed"; that is normal, because the server only answers MCP requests. If you typed theclaude mcp addcommand with double quotes, your key was written into the settings file: runclaude mcp remove okdata --scope userand add it again with single quotes.
Read next
- The MCP server: what each tool does and what to tell your agent.
- Xiaohongshu note search: parameters, returned fields and price.
Updated 2026-11-12