Documentation
Getting started
MOFA Data API serves public data from 31 platforms through 273 endpoints, with one API key and one JSON envelope. You pay per successful call (from $0.01); failed calls are free.
Base URL
https://api.mofa-ai.com
Every endpoint lives under /v1, over HTTPS only. Each one has an ID (platform.name, such as xiaohongshu.search_note_v2) and a matching path (/v1/platform/name).
Authentication
Create an API key in the console (it starts with mk_live_) and send it in a request header, either way works:
Authorization: Bearer mk_live_…
X-API-Key: mk_live_…
A key spends your balance, so keep it on your server and out of browser or app code. You can revoke a key in the console at any time and give each key a spending limit.
Your first request
Export your key as MOFA_API_KEY, then call Note Search (xiaohongshu.search_note_v2, $0.03 per call):
curl -G "https://api.mofa-ai.com/v1/xiaohongshu/search_note_v2" \
-H "Authorization: Bearer $MOFA_API_KEY" \
--data-urlencode 'keyword=咖啡' \
--data-urlencode 'page=1' \
--data-urlencode 'sort=general' \
--data-urlencode 'note_type=_0' \
--data-urlencode 'note_time=ONE_DAY'
import os
import requests
resp = requests.get(
"https://api.mofa-ai.com/v1/xiaohongshu/search_note_v2",
headers={"Authorization": f"Bearer {os.environ['MOFA_API_KEY']}"},
params={
"keyword": "咖啡",
"page": "1",
"sort": "general",
"note_type": "_0",
"note_time": "ONE_DAY",
},
timeout=60,
)
body = resp.json()
if body["success"]:
print(body["cost_usd"], body["data"])
else:
print(body["error"], body["message"])
const url = new URL("https://api.mofa-ai.com/v1/xiaohongshu/search_note_v2");
url.search = new URLSearchParams({
keyword: "咖啡",
page: "1",
sort: "general",
note_type: "_0",
note_time: "ONE_DAY",
});
const resp = await fetch(url, {
headers: { Authorization: `Bearer ${process.env.MOFA_API_KEY}` },
});
const body = await resp.json();
if (body.success) console.log(body.cost_usd, body.data);
else console.error(body.error, body.message);
GET and POST
Every endpoint can be called three equivalent ways, with the same parameters:
# 1. GET with a query string
GET /v1/xiaohongshu/search_note_v2?keyword=咖啡
# 2. POST with a JSON (or form) body
POST /v1/xiaohongshu/search_note_v2
Content-Type: application/json
{"keyword": "咖啡"}
# 3. POST /v1/call with the endpoint ID
POST /v1/call
Content-Type: application/json
{"endpoint": "xiaohongshu.search_note_v2", "params": {"keyword": "咖啡"}}
- Parameter values are strings; numbers and booleans are converted for you.
- A missing required parameter returns
400 missing_parameterand is not billed. - Parameters an endpoint doesn't take are ignored and listed in
ignored_params. - GET is simplest; POST with JSON is handier for long values or special characters.
Response envelope
Every endpoint answers with the same envelope; the platform data is in data. Success:
{
"success": true,
"code": 0,
"message": "success",
"request_id": "req_5f1c2a9be04d7c3a81f6e2d0",
"endpoint": "xiaohongshu.search_note_v2",
"cost_usd": 0.03,
"data": { … }
}
On failure success is false, code is the HTTP status and error is one of the codes below:
{
"success": false,
"code": 402,
"error": "insufficient_balance",
"message": "Your balance is too low for this call. Top up at https://api.mofa-ai.com/console/billing."
}
Errors
Failed calls are never billed. For errors marked retryable, wait and retry with exponential backoff, honouring Retry-After when present.
| Error | HTTP | Meaning | Retry |
|---|---|---|---|
invalid_api_key | 401 | Missing or invalid API key. Send it as 'Authorization: Bearer mk_live_…'. | No |
account_suspended | 403 | This account is suspended. Contact contact@mofa-ai.com. | No |
unknown_endpoint | 404 | Unknown endpoint. See GET /v1/endpoints or https://api.mofa-ai.com/docs. | No |
missing_parameter | 400 | A required parameter is missing. | No |
invalid_parameter | 400 | A parameter value is invalid. | No |
invalid_body | 400 | The request body must be a JSON object or a form. | No |
insufficient_balance | 402 | Your balance is too low for this call. Top up at https://api.mofa-ai.com/console/billing. | No |
key_budget_exceeded | 402 | This API key reached its spending limit. Raise it in the console. | No |
rate_limited | 429 | Too many requests for this API key. Slow down and retry. | Yes |
too_many_concurrent | 429 | Too many calls in flight for this account. Retry when some finish. | Yes |
upstream_rejected | 422 | The data source rejected the request (not billed). | No |
upstream_error | 502 | The data source failed (not billed). Retry shortly. | Yes |
upstream_timeout | 504 | The data source timed out (not billed). Retry shortly. | Yes |
service_unavailable | 503 | The data service is temporarily unavailable (not billed). Retry shortly. | Yes |
internal_error | 500 | Internal error (not billed). | Yes |
Billing headers
Each call reserves the endpoint's price from your balance before it runs; if the call fails (including timeouts and data source errors) the charge is refunded at once. Every response carries these headers:
| Header | Meaning |
|---|---|
X-Request-Id | The id of this call. Quote it when you contact support. |
X-MOFA-Cost-USD | What this call cost in USD; 0 when it was not billed. |
X-MOFA-Balance-USD | Your account balance in USD after this call. |
A call your balance can't cover returns 402 insufficient_balance; a key over its spending limit returns 402 key_budget_exceeded. GET /v1/account shows your balance for free.
Rate limits
- Each API key can make up to 300 requests per minute; beyond that you get
429 rate_limited. - Each account can have up to 15 calls in flight; beyond that you get
429 too_many_concurrent. - Both 429s carry a
Retry-Afterheader. Some calls take a few seconds, so set your client timeout to about 60 seconds. - For higher limits, email contact@mofa-ai.com.
Discovery
These need no key, so programs and AI agents can discover endpoints on their own:
GET /v1/endpoints· every endpoint with params and price; add ?platform= and ?lang=zh|enGET /v1/endpoints/{id}· one endpoint with an example responseGET /v1/platforms· platforms/openapi.json· OpenAPI 3.1/llms.txt· a summary for AI agentsGET /v1/account· balance and key info (key required, free)
All platforms
Social & content
-
WeChat 21 endpoints
-
RedNote 14 endpoints
-
Zhihu 14 endpoints
-
WeChat Channels 13 endpoints
-
Weibo 11 endpoints
-
Bilibili 9 endpoints
-
Douyin 9 endpoints
-
Kuaishou 8 endpoints
-
Douban 6 endpoints
-
Toutiao 5 endpoints
-
Youku 3 endpoints
- Cross-platform search 1 endpoint
Commerce
Other
-
Douyin Xingtu 32 endpoints
-
IMDb 18 endpoints
-
Shopee 18 endpoints
-
RED Pugongying 16 endpoints
-
Taobao / Tmall 13 endpoints
-
Instagram 8 endpoints
-
YouTube 7 endpoints
-
Douyin E-commerce 6 endpoints
-
QQ Huxuan 6 endpoints
-
TikTok 6 endpoints
-
Amazon 5 endpoints
-
Facebook 5 endpoints
-
JD.com 5 endpoints
-
X 4 endpoints
-
Reddit 3 endpoints
-
1688 2 endpoints
-
TikTok Shop 2 endpoints
-
Xianyu 2 endpoints