Getting started
One API key reaches public data from 31 platforms through 273 endpoints, and every platform answers in the same 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 in the form 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 form 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 give each key a spending limit and revoke it in the console the moment it leaks.
Your first request
Export your key as MOFA_API_KEY, then call Note Search v2 (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, and the platform's data is in data. On 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 in the table 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
A failed call is never billed. For errors marked retryable, wait and retry with exponential backoff, and honour Retry-After when the response carries it.
| 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 when it starts. If it fails, timeouts and data source errors included, the charge is refunded at once. Every call that reaches the data source, successful or not, answers with these headers:
| Header | Meaning |
|---|---|
X-Request-Id | The id of this call, the same as request_id in the body. 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, and a key over its spending limit returns 402 key_budget_exceeded. GET /v1/account shows your balance and what the calling key has spent, for free. Every endpoint's price is on the pricing page.
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 and are not billed. - A slow data source can take a few seconds to tens of seconds, so set your client timeout to about 60 seconds.
- For higher limits, email contact@mofa-ai.com.
Discovery
These need no key (except the last), so programs and AI agents can discover endpoints on their own:
GET /v1/endpoints | Every endpoint with its parameters and price. Add ?platform= and ?lang=zh|en. |
GET /v1/endpoints/{id} | One endpoint with an example response. |
GET /v1/platforms | The list of platforms. |
/openapi.json | The OpenAPI 3.1 document. |
/llms.txt | A summary written for AI agents. |
GET /v1/account | Your balance and the calling key. Needs a key, costs nothing. |
All platforms
Chinese social and contentFrom, per call
WeChat21 endpoints$0.02
RedNote14 endpoints$0.03
Zhihu14 endpoints$0.02
WeChat Channels13 endpoints$0.03
Weibo11 endpoints$0.02
Bilibili9 endpoints$0.02
Douyin9 endpoints$0.02
Kuaishou8 endpoints$0.02
Douban6 endpoints$0.02
Toutiao5 endpoints$0.02
Youku3 endpoints$0.02
Cross-platform search1 endpoint$0.04