TMDB API 错误码与解决办法
amodb 的 TMDB API 错误码沿用 TMDB 响应体:success 为 false,附 status_code 和 status_message。共 10 组,从 7(密钥无效)到 36(套餐到期)。只重试 429、500、504。
amodb 的调用失败时,先看 HTTP 状态,再看响应体里的 status_code。https:/ 上的每个错误都使用 TMDB 的响应体,success 为 false。只有 429、500 和 504 值得重试:下表中的其他 7 个代码,在你改动请求、密钥或套餐之前,都会再次失败。
TMDB 风格的错误响应是什么样的?
https:/ 的每个错误都与 TMDB 有相同的 JSON 结构:
{
"success": false,
"status_code": 34,
"status_message": "The resource you requested could not be found."
}amodb 会返回哪些 TMDB API 错误码?
| HTTP | status_code | status_message | 是否重试 | 怎么做 |
|---|---|---|---|---|
| 400 | 22 | Invalid page: Pages start at 1 and max at 500. They are expected to be an integer. | 否 | 把 page 作为 1 到 500 的整数发送。 |
| 401 | 7 | Invalid API key: You must be granted a valid key. | 否 | 检查密钥和发送方式。 |
| 401 | 10 | Suspended API key: Access to your account has been suspended, contact amodb. | 否 | 写信给 support@amodb.dev。 |
| 402 | 36 | Your plan has expired. Renew at https://amodb.dev/pricing/ | 否 | 支付新的周期。 |
| 403 | 3 | The all in one endpoint is available on the Pro+ plan. See https://amodb.dev/pricing/ | 否 | 升级到 Pro+,或调用标准接口。 |
| 404 | 34 | The resource you requested could not be found. | 否 | 检查 ID 或路径。 |
| 405 | 37 | This method is not offered by amodb. | 否 | 使用读取接口。 |
| 429 | 25 | Your request count (N) is over the allowed limit of (L). | 是 | 等待 Retry-After 秒。 |
| 500 | 11 | Internal error: Something went wrong, contact amodb. | 是 | 几秒后重试。 |
| 504 | 24 | Your request to the backend server timed out. Try again. | 是 | 几秒后重试。 |
403 来自 GET /,这是只有 Pro+ 才有的一站式接口。除 page 之外的错误参数同样返回 status_code 22,消息以 Invalid parameters 开头。
为什么我的 TMDB API key 不起作用?
按下表从上往下排查。大多数失败是前三项之一。
| 你看到的现象 | 可能的原因 | 解决办法 |
|---|---|---|
401,status_code 7,密钥来自 TMDB | TMDB 的 API key 或读取访问令牌不是 amodb 密钥 | 在账户的 API 密钥下创建 amodb 密钥 |
401,status_code 7,密钥来自 amodb | 密钥被截断、混入多余字符或已被删除 | 粘贴全部 32 个十六进制字符;弄丢了就创建新密钥 |
401,status_code 7,密钥看起来没问题 | 请求里的第二个密钥优先:api_key 优先于 apikey,apikey 又优先于 Bearer 请求头 | 删除多余的参数 |
401,status_code 10 | 密钥已被停用 | 写信给 support@amodb.dev |
402,status_code 36 | 套餐周期已结束;银行卡付款是预付的,不会自动续费 | 在 amodb 定价页支付新的周期 |
403,status_code 3 | 这个路径需要 Pro+ | 使用 Pro+ 或标准接口 |
429,status_code 25 | 账户超过了每分钟请求数 | 等待 Retry-After 秒 |
| 没有响应,或超时 | 你这一侧的网络或 DNS 问题 | 打开 https:/,它不需要密钥 |
两个快速检查。如果 /plans 能打开,但带密钥的调用失败,问题出在密钥上。如果 /plans 也打不开,问题出在网络路径上,请看状态页。认证页说明了发送密钥的三种方式。
客户端应该重试哪些错误?
| 类别 | 示例 | 是否重试 | 等待 |
|---|---|---|---|
| 你的请求有误 | 400、404、405 | 否 | 先修正请求 |
| 你的密钥或套餐有误 | 401、402、403 | 否 | 先修正密钥或套餐 |
| 速率限制 | 429 | 是 | Retry-After 秒,与 X-RateLimit-Reset 的数值相同 |
| amodb 一侧 | 500、504 | 是 | 1、2 和 4 秒,然后停止 |
每个带密钥的响应都带有 X-RateLimit-Limit、X-RateLimit-Remaining 和 X-RateLimit-Reset。各套餐的数字见速率限制页。
OMDb 风格的错误是什么样的?
兼容 OMDb 的接口保留 OMDb 的结构和措辞:
带 r=xml 的 OMDb 调用返回 HTTP 400。请使用 r=json,或者不传 r。
| HTTP | 错误文本 | 原因 |
|---|---|---|
| 401 | No API key provided. | 请求里没有 apikey |
| 401 | Invalid API key! | 密钥格式错误或不存在 |
| 402 | Your plan has expired. Renew at https://amodb.dev/pricing/ | 套餐周期已结束 |
| 429 | Request limit reached! | 超过了账户的每分钟请求数 |
| 400 | Only r=json is supported. | 调用要求了 r=xml |
| 400 | Incorrect request. | 某个参数有误 |
参数列表见 OMDb API 文档页。
{
"Response": "False",
"Error": "Movie not found!"
}const res = await fetch("https://api.amodb.dev/3/movie/550", {
headers: { Authorization: `Bearer ${process.env.AMODB_KEY}` },
});
if (!res.ok) {
const err = await res.json();
if (res.status === 429) {
// wait Retry-After seconds, then retry
}
throw new Error(`amodb ${res.status} code ${err.status_code}: ${err.status_message}`);
}res = requests.get(url, headers=headers, timeout=10)
if not res.ok:
err = res.json()
raise RuntimeError(f"amodb {res.status_code} code {err['status_code']}: {err['status_message']}")