电视剧集 API 返回什么?
电视剧集 API 返回一部剧的各集,带名称、播出日期和片长。在 amodb 里,一次调用 GET / 返回一季的全部集,GET /3/tv/{tv_id} 里的 next_episode_to_air 保存下一个播出日期。10 季的剧要 11 个请求,套餐 $5.19 一个月起,商业使用不额外收费。
每一集有 episode_number、name、overview、air_date、runtime 和 still_path。剧集 ID 是数字,例如 Breaking Bad 是 1396。文本字段随 language 参数提供 14 种语言,没有译文时简介为空。路径和 JSON 与 TMDB v3 相同,所以 TMDB 客户端把基础 URL 改成 https:/ 并换上密钥就能用。
怎么获取下一集的播出日期?
从 GET /3/tv/{tv_id} 读取 next_。它是 YYYY-MM-DD 字符串,旁边是 season_number 和 episode_number。没有排期的集时,next_episode_to_air 是 null,而 last_episode_to_air 仍然保存最近一集。
curl -s "https://api.amodb.dev/3/tv/1396?language=en-US" \
-H "Authorization: Bearer $AMODB_KEY" \
| jq '{status, next: .next_episode_to_air.air_date, last: .last_episode_to_air.air_date}'Breaking Bad 已经完结,所以下一个日期是 null:
{
"status": "Ended",
"next": null,
"last": "2013-09-29"
}一个小函数,返回下一个播出日期,没有时返回原因:
async function nextAirDate(tvId) {
const res = await fetch(`https://api.amodb.dev/3/tv/${tvId}?language=en-US`, {
headers: { Authorization: `Bearer ${process.env.AMODB_KEY}` },
});
if (!res.ok) throw new Error(`amodb returned ${res.status}`);
const show = await res.json();
const next = show.next_episode_to_air;
if (next && next.air_date) {
return { date: next.air_date, season: next.season_number, episode: next.episode_number };
}
return { date: null, reason: show.status === 'Returning Series' ? 'not scheduled yet' : show.status };
}next_episode_to_air 和 last_episode_to_air 字段相同。下表用 Breaking Bad 的 last_episode_to_air(剧集大结局)的值来展示。
| 字段 | 类型 | 示例 |
|---|---|---|
air_date | 字符串或 null | "2013-09-29" |
season_number | 整数 | 5 |
episode_number | 整数 | 16 |
episode_type | 字符串 | "standard" |
id | 整数 | 62161 |
show_id | 整数 | 1396 |
name | 字符串 | 随 language 本地化 |
overview | 字符串 | 已本地化,可能为空 |
runtime | 整数或 null | 56 |
still_path | 字符串或 null | "/ |
把这个对象与 status 结合起来选标签。Returning Series 且 next_episode_to_air 为 null,表示预计有新的一季但还没定日期。Ended 和 Canceled 表示不会再有新集。air_date 是不带具体时间和时区的日历日期,所以与今天的日期比较,不要精确到分钟倒计时。状态值的说明见电视剧 API。
你能得到哪些数据
| 接口 | 返回 |
|---|---|
GET /3/tv/{tv_id} | seasons 摘要、number_of_seasons、status、next_episode_to_air、last_episode_to_air |
GET / | 一季及其全部 episodes |
GET / | 一集,带 crew 和 guest_stars |
GET / | 该剧定义的每种其他排序的名称、type 和集数 |
GET /3/tv/airing_today 和 GET /3/tv/on_the_air | 今天或未来 7 天内有集播出的剧 |
一集的字段:
| 字段 | 类型 | 说明 |
|---|---|---|
id、show_id | 整数 | 集 ID 和剧集 ID。show_id 出现在季列表和 next_episode_to_air 里,不在单集路径上 |
episode_number、season_number | 整数 | 在季里的位置 |
episode_type | 字符串 | 例如 standard |
name、overview | 字符串 | 随 language 本地化 |
air_date | 字符串或 null | YYYY-MM-DD,未公布时为空或 null |
runtime | 整数或 null | 分钟 |
still_path | 字符串或 null | 拼接到 https:/ |
vote_average、vote_count | 数字、整数 | 目前集上为 0 |
production_code | 字符串 | 制片厂代码,常为空 |
crew、guest_stars | 数组 | 该集署名的人员,字段与演员相同 |
完整参考见季与集 API,剧集字段见 TMDB 电视剧 API。
三步开始
- 在 amodb 定价选一个套餐:每分钟 20、40 或 120 个请求。每个套餐都包含全部兼容 TMDB v3 的接口、兼容 OMDb 的接口、图片、14 种语言和扩展。
- 输入邮箱并付款,然后用 amodb 发到邮箱的 6 位验证码登录。第一把密钥会被创建并只显示一次,把它存进环境变量。
- 请求
/3/tv/{tv_id}/season/1,把密钥放在 Bearer 请求头里或api_key里。
请求示例
这个示例用英语获取 Breaking Bad(剧集 ID 1396)的第 1 季。Go 程序把它解码成带类型的结构体,每集打印一行,含播出日期、片长和剧照 URL。更多 Go 写法见 Go 调用 TMDB API。
curl -s "https://api.amodb.dev/3/tv/1396/season/1?language=en-US" \
-H "Authorization: Bearer $AMODB_KEY"package main
import (
"encoding/json"
"fmt"
"net/http"
"os"
"time"
)
type Episode struct {
EpisodeNumber int `json:"episode_number"`
Name string `json:"name"`
AirDate string `json:"air_date"`
Runtime int `json:"runtime"`
StillPath *string `json:"still_path"`
}
type Season struct {
Name string `json:"name"`
SeasonNumber int `json:"season_number"`
Episodes []Episode `json:"episodes"`
}
func main() {
client := &http.Client{Timeout: 10 * time.Second}
url := "https://api.amodb.dev/3/tv/1396/season/1?language=en-US"
req, err := http.NewRequest("GET", url, nil)
if err != nil {
panic(err)
}
req.Header.Set("Authorization", "Bearer "+os.Getenv("AMODB_KEY"))
res, err := client.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
if res.StatusCode != http.StatusOK {
panic(fmt.Sprintf("amodb returned %s", res.Status))
}
var season Season
if err := json.NewDecoder(res.Body).Decode(&season); err != nil {
panic(err)
}
fmt.Println(season.Name)
for _, e := range season.Episodes {
still := "no still"
if e.StillPath != nil {
still = "https://img.amodb.dev/t/p/w300" + *e.StillPath
}
fmt.Printf("S%02dE%02d %s %3d min %s %s\n",
season.SeasonNumber, e.EpisodeNumber, e.AirDate, e.Runtime, e.Name, still)
}
}精简后的响应:7 集中的 2 集,每集带一名工作人员和一名客串演员。
{
"air_date": "2008-01-20",
"episodes": [
{
"air_date": "2008-01-20",
"episode_number": 1,
"episode_type": "standard",
"id": 62085,
"name": "Pilot",
"overview": "When an unassuming high school chemistry teacher discovers he has a rare form...",
"production_code": "",
"runtime": 59,
"season_number": 1,
"show_id": 1396,
"still_path": "/ydlY3iPfeOAvu8gVqrxPoMvzNCn.jpg",
"vote_average": 0,
"vote_count": 0,
"crew": [
{
"department": "Camera",
"job": "Director of Photography",
"credit_id": "52b7029219c29533d00dd2c1",
"adult": false,
"gender": 2,
"id": 2483,
"known_for_department": "Camera",
"name": "约翰·托尔",
"original_name": "约翰·托尔",
"popularity": 1.1957,
"profile_path": "/cfL9A6tC7L5Ps5fq1o3WpVKGMb1.jpg"
}
],
"guest_stars": [
{
"character": "Steven Gomez",
"credit_id": "5271b489760ee35b3e0881a7",
"order": 8,
"adult": false,
"gender": 2,
"id": 61535,
"known_for_department": "Acting",
"name": "史蒂文·迈克尔·奎扎达",
"original_name": "史蒂文·迈克尔·奎扎达",
"popularity": 1.7511,
"profile_path": "/pVYrDkwI6GWvCNL2kJhpDJfBFyd.jpg"
}
]
},
{
"air_date": "2008-01-27",
"episode_number": 2,
"episode_type": "standard",
"id": 62086,
"name": "Cat's in the Bag...",
"overview": "Walt and Jesse attempt to tie up loose ends. The desperate situation gets mor...",
"production_code": "",
"runtime": 49,
"season_number": 1,
"show_id": 1396,
"still_path": "/AbMoecO0ZZio0LcgeLxlzdyGs6X.jpg",
"vote_average": 0,
"vote_count": 0,
"crew": [
{
"department": "Camera",
"job": "Director of Photography",
"credit_id": "52b7049c19c2953b63015013",
"adult": false,
"gender": 2,
"id": 17948,
"known_for_department": "Camera",
"name": "Reynaldo Villalobos",
"original_name": "Reynaldo Villalobos",
"popularity": 0.904,
"profile_path": "/4YlfhHDRZWhbRgeqT2Bwl1u5p9j.jpg"
}
],
"guest_stars": [
{
"character": "Krazy-8",
"credit_id": "52725845760ee3046b09426e",
"order": 504,
"adult": false,
"gender": 2,
"id": 1046460,
"known_for_department": "Acting",
"name": "Max Arciniega",
"original_name": "Max Arciniega",
"popularity": 1.4399,
"profile_path": "/eqKAJKPpt41KpsLIkkBnAY4HMAL.jpg"
}
]
}
],
"name": "Season 1",
"overview": "High school chemistry teacher Walter White's life is suddenly transformed by...",
"id": 3572,
"poster_path": "/91EIXdWxmp2mHNRsSuDW3WyDJLj.jpg",
"season_number": 1,
"vote_average": 0
}这个响应里有些人名是中文,尽管请求的是英语,所以当名称与你的显示语言不一致时,回退到 original_name,或改用 en-US 请求。
怎么获取一整部剧?
amodb 不接受 append_to_response 里 season/1 这样的值,所以季调用要分开发。先从电视剧详情读取 number_of_seasons 和 seasons 列表,再循环请求每一季。
const base = 'https://api.amodb.dev/3';
const headers = { Authorization: `Bearer ${process.env.AMODB_KEY}` };
async function get(path) {
const res = await fetch(base + path, { headers });
if (!res.ok) throw new Error(`amodb returned ${res.status} for ${path}`);
return res.json();
}
const show = await get('/tv/1396');
for (const { season_number } of show.seasons) {
const season = await get(`/tv/1396/season/${season_number}`);
console.log(season.name, season.episodes.length);
}seasons 在剧有特别篇时包含第 0 季,所以 Breaking Bad 要 1 次详情调用加 6 次季调用。10 季的剧要 11 个请求。详情在边缘缓存 6 小时,所以把结果存下来,按计划刷新。
| 剧的规模 | 取完整指南的请求数 | 在 Lite 上(每分钟 20 个) | 在 Pro+ 上(每分钟 120 个) |
|---|---|---|---|
| 1 季 | 2 | 每分钟 10 份指南 | 每分钟 60 份指南 |
| 5 季加特别篇 | 7 | 每分钟约 3 份指南 | 每分钟约 17 份指南 |
| 10 季 | 11 | 每分钟约 2 份指南 | 每分钟约 11 份指南 |
| 关注 200 部剧,只查状态 | 200 | 10 分钟 | 不到 2 分钟 |
有些季在没有集数据时返回空的 episodes 数组,所以你收集到的集数可能少于 number_of_episodes。429 加 status_code 25 表示这一分钟的额度用完了;等待 Retry-After 秒。各套餐的限制见速率限制。
有没有查询今天和本周播出内容的电视节目表 API?
有。两个列表接口可以回答“有什么在播”,不用逐个遍历你追踪的剧。
| 调用 | 返回 | 参数 | 边缘缓存 |
|---|---|---|---|
GET /3/tv/airing_today | 今天有集播出的剧 | page、language、timezone | 30 分钟 |
GET /3/tv/on_the_air | 未来 7 天内有集播出的剧 | page、language、timezone | 30 分钟 |
GET /3/tv/{tv_id} | 一部剧的 next_episode_to_air | language | 6 小时 |
timezone 是 IANA 名称,如 Europe/Rome。它决定哪个日历日算今天,所以 airing_today 对 Asia/Tokyo 返回的集合与对 Pacific/Auckland 返回的不同。每 30 分钟请求一次,每天是 48 个,足够做一个“今晚”栏。把返回的 ID 与用户关注的剧匹配,再读取 next_episode_to_air 得到集数。这些列表见 TMDB 热门 API。
剧照和片长
列表行用 w185 或 w300,完整尺寸用 original。剧照的尺寸有 w92、w185、w300 和 original。一集可能没有剧照,所以 still_path 为 null 时要渲染占位图。图片主机不需要密钥,文件保留 30 天,见 TMDB 图片 URL。
runtime 以分钟计,可能为 null。要显示一季的刷剧时长,把 episodes 里的 runtime 加起来,null 按 0 算:Breaking Bad 第 1 季开头是 59 分钟和 49 分钟的两集。在单集路径上加 append_,会得到 credits 对象和 stills 列表。单集的 cast 数组为空,人员在 crew 和 guest_stars 里。详情见演职员 API。
用剧集分组获取其他排序
有些剧的观看顺序不同于播出顺序。GET / 列出一部剧定义的各种排序。每条有 id、name、description、type、episode_count、group_count 和 network。没有定义时 results 数组为空。
type | 排序 |
|---|---|
| 1 | 原始播出日期 |
| 2 | 绝对顺序 |
| 3 | DVD |
| 4 | 数字版 |
| 5 | 故事线 |
| 6 | 制作顺序 |
| 7 | 电视 |
amodb 只返回这份列表。它不提供 GET /,所以分组里的具体集拿不到。集数据请用季接口。
和其他做法比较
| 能力 | 抓取剧集页面 | 免费档元数据 API | amodb |
|---|---|---|---|
| 整季 | 每季抓取一个页面 | 请查看其文档 | 一次调用,已含 episodes 数组 |
| 整部剧 | 抓取每一季 | 请查看其文档 | 每季一次调用,季列表在 seasons 里 |
| 播出日期 | 解析文本 | 请查看其文档 | air_date 加 next_episode_to_air |
| 剧照 | 下载再缩放 | 请查看其文档 | img.amodb.dev 上的固定尺寸,不需要密钥 |
| 其他剧集排序 | 没有 | 请查看其文档 | episode_groups 列表,不提供分组内容 |
| 语言 | 每个网站一个区域设置 | 请查看其文档 | 14 种语言,用 language |
有免费的剧集数据:TheTVDB v4 在年营收低于 $50,000 时免费,需署名和直接链接,Trakt 的 Standard API 每 5 分钟允许 500 个 GET 请求。TVmaze 是另一个选择;条款请查看其网站。详情见 TVDB API、Trakt API和 TVmaze API。
电视剧集 API 要花多少钱?
amodb 是 $5.19、$6.19 或 $7.19 一个月,对应每分钟 20、40 或 120 个请求。套餐可预付 1、3、6、12 或 24 个月,较长的周期分别减 0、10、20、30 或 40%,所以 Lite 套餐 24 个月是 $74.74,即 $3.11 一个月。银行卡、Apple Pay 和 Google Pay 的付款不会自动续费;Patreon 只按月,在 Patreon 上续费,直到你在那里取消。每个套餐都包含全部兼容 TMDB v3 的接口、兼容 OMDb 的接口、图片、14 种语言和扩展,本页的所有接口也在其中。刷新一部剧要一次详情请求加每季一次请求。没有免费额度。在 amodb 定价选一个套餐。
资料来源
读取于 2026-10-19。
- TheTVDB API 信息:年营收低于 $50,000 免费,需署名和直接链接。
- Trakt Premium API:Standard API 免费,每 5 分钟 500 个 GET 请求。