电视剧 API

电视剧接口通过 GET /3/tv/{series_id} 按 ID 返回一部剧:名称、简介、状态、季、电视网,以及上一集和下一集的指针。JSON 与 TMDB v3 一致,现有客户端只需更换基础地址。支持 append_to_response。

更新于 以 Markdown 查看

获取电视剧详情

GET /3/tv/{series_id} 返回一部剧的核心记录:名称、简介、状态、类型、电视网、季列表,以及指向上一集和下一集的指针。ID 是 TMDB 的数字电视剧 ID,所以你存为 1396 的剧在这里仍是这个 ID。电影 ID 和电视剧 ID 是各自独立的空间,所以请始终把媒体类型和数字一起保存。

示例用英文请求《绝命毒师》,并在同一次调用中追加它的内容分级和外部评分。

bashjspyphpgo
curl -sSf "https://api.amodb.dev/3/tv/1396?language=en-US&append_to_response=content_ratings,ratings" \
  -H "Authorization: Bearer $AMODB_KEY"
const params = new URLSearchParams({ language: 'en-US', append_to_response: 'content_ratings,ratings' });
const res = await fetch(`https://api.amodb.dev/3/tv/1396?${params}`, {
  headers: { Authorization: `Bearer ${process.env.AMODB_KEY}` },
});
if (!res.ok) throw new Error(`amodb returned ${res.status}`);
const show = await res.json();
const us = show.content_ratings.results.find((r) => r.iso_3166_1 === 'US');
console.log(show.name, show.status, show.number_of_seasons, us?.rating);
import os
import requests

r = requests.get(
    "https://api.amodb.dev/3/tv/1396",
    params={"language": "en-US", "append_to_response": "content_ratings,ratings"},
    headers={"Authorization": f"Bearer {os.environ['AMODB_KEY']}"},
    timeout=10,
)
r.raise_for_status()
show = r.json()
us = next((x for x in show["content_ratings"]["results"] if x["iso_3166_1"] == "US"), None)
print(show["name"], show["status"], show["number_of_seasons"], us and us["rating"])
<?php
$url = 'https://api.amodb.dev/3/tv/1396?' . http_build_query([
    'language' => 'en-US',
    'append_to_response' => 'content_ratings,ratings',
]);
$ch = curl_init($url);
curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_TIMEOUT => 10,
    CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . getenv('AMODB_KEY')],
]);
$body = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($status !== 200) {
    throw new RuntimeException("amodb returned $status");
}
$show = json_decode($body, true);
echo $show['name'], ' ', $show['status'], ' ', $show['number_of_seasons'], PHP_EOL;
package main

import (
	"encoding/json"
	"fmt"
	"net/http"
	"net/url"
	"os"
	"time"
)

type Show struct {
	Name             string `json:"name"`
	Status           string `json:"status"`
	NumberOfSeasons  int    `json:"number_of_seasons"`
	NumberOfEpisodes int    `json:"number_of_episodes"`
	Next             *struct {
		AirDate string `json:"air_date"`
	} `json:"next_episode_to_air"`
}

func main() {
	q := url.Values{"language": {"en-US"}}
	req, _ := http.NewRequest("GET", "https://api.amodb.dev/3/tv/1396?"+q.Encode(), nil)
	req.Header.Set("Authorization", "Bearer "+os.Getenv("AMODB_KEY"))
	client := &http.Client{Timeout: 10 * time.Second}
	res, err := client.Do(req)
	if err != nil {
		panic(err)
	}
	defer res.Body.Close()
	if res.StatusCode != http.StatusOK {
		panic(res.Status)
	}
	var s Show
	if err := json.NewDecoder(res.Body).Decode(&s); err != nil {
		panic(err)
	}
	next := "none scheduled"
	if s.Next != nil {
		next = s.Next.AirDate
	}
	fmt.Println(s.Name, s.Status, s.NumberOfSeasons, s.NumberOfEpisodes, next)
}

参数

  • series_id路径必填
    数字形式的电视剧 ID,例如 1396。
  • api_key查询二选一
    你的密钥。使用它,或使用 Authorization: Bearer 请求头。
  • language查询
    en-US、uk-UA 或 es-ES 这样的 TMDB 标签。提供 14 种基础语言。默认 en-US。
  • append_to_response查询
    用逗号分隔的子资源列表,合并进响应,最多 20 个值。

响应字段

字段类型说明
idinteger电视剧 ID。
name、original_namestring本地化标题和原始标题。日语或韩语的原名保留在 original_name 中。
overview、taglinestring本地化文本,没有译文时为空。
first_air_date、last_air_datestring 或 nullYYYY-MM-DD。
statusstring生命周期,见下表。
in_productionboolean该剧仍在制作时为 true。
number_of_seasons、number_of_episodesinteger总数,按该剧存储的值。
episode_run_timearray典型的单集时长,单位为分钟,可能为空。
seasonsarray每季一条摘要,含 id、season_number、name、overview、episode_count、air_date、poster_path、vote_average。
last_episode_to_air、next_episode_to_airobject 或 null单集摘要,结构与季与单集中的对象相同。
networks、production_companiesarrayid、name、logo_path、origin_country。
production_countries、spoken_languagesarray国家含 iso_3166_1 和 name。语言含 english_name、iso_639_1 和 name。
created_byarray创作者,含 id、name、profile_path 和 credit_id。大多数剧集为空。
genresarray含 id 和 name 的对象。电视剧的类型 ID 与电影不同。
origin_country、original_language、languagesarray、string国家代码和语言代码。
homepagestring官方网站,未知时为空。
poster_path、backdrop_pathstring 或 null拼接到 https://img.amodb.dev/t/p/{size}。见图片。
popularitynumber热门榜单使用的相对分数。
vote_average、vote_countnumber、integer汇总用户评分。
adultboolean始终为 false。成人作品永远不会提供。

示例响应

GET /3/tv/1396?language=en-US&append_to_response=content_ratings,ratings,较长的数组和文本已缩短:

JSON
{
  "adult": false,
  "backdrop_path": "/ycFcYYnzVc8mWw41neszGPMyKc3.jpg",
  "created_by": [],
  "episode_run_time": [
    48,
    49
  ],
  "first_air_date": "2008-01-20",
  "genres": [
    {
      "id": 18,
      "name": "Drama"
    },
    {
      "id": 80,
      "name": "Crime"
    }
  ],
  "homepage": "",
  "id": 1396,
  "in_production": false,
  "languages": [
    "en"
  ],
  "last_air_date": "2013-09-29",
  "last_episode_to_air": {
    "air_date": "2013-09-29",
    "episode_number": 16,
    "episode_type": "standard",
    "id": 62161,
    "name": "פלינה",
    "overview": "הסדרה זוכת הפרסים מגיעה לסיום דרמתי בפרק החותם אותה.",
    "production_code": "",
    "runtime": 56,
    "season_number": 5,
    "show_id": 1396,
    "still_path": "/pA0YwyhvdDXP3BEGL2grrIhq8aM.jpg",
    "vote_average": 0,
    "vote_count": 0
  },
  "name": "Breaking Bad",
  "next_episode_to_air": null,
  "networks": [
    {
      "id": 174,
      "logo_path": "/pmvRmATOCaDykE6JrVoeYxlFHw3.png",
      "name": "AMC",
      "origin_country": "US"
    }
  ],
  "number_of_episodes": 62,
  "number_of_seasons": 5,
  "origin_country": [
    "US"
  ],
  "original_language": "en",
  "original_name": "Breaking Bad",
  "overview": "Walter White, a New Mexico chemistry teacher, is diagnosed with Stage III cancer and given a prognosis of o...",
  "popularity": 268.4968,
  "poster_path": "/anFx9aTOOYqgS3v7x3R84Kz67ly.jpg",
  "production_companies": [
    {
      "id": 2605,
      "logo_path": null,
      "name": "Gran Via Productions",
      "origin_country": "US"
    },
    {
      "id": 11073,
      "logo_path": "/wHs44fktdoj6c378ZbSWfzKsM2Z.png",
      "name": "Sony Pictures Television",
      "origin_country": "US"
    }
  ],
  "production_countries": [
    {
      "iso_3166_1": "US",
      "name": "United States of America"
    }
  ],
  "seasons": [
    {
      "air_date": "2009-02-17",
      "episode_count": 9,
      "id": 3577,
      "name": "特别篇",
      "overview": "",
      "poster_path": "/ikBSCmgG5Z4jequUUAjKpf1QG3T.jpg",
      "season_number": 0,
      "vote_average": 0
    },
    {
      "air_date": "2008-01-20",
      "episode_count": 7,
      "id": 3572,
      "name": "Season 1",
      "overview": "High school chemistry teacher Walter White's life is suddenly transformed by a dire medical diagnosis. Stre...",
      "poster_path": "/91EIXdWxmp2mHNRsSuDW3WyDJLj.jpg",
      "season_number": 1,
      "vote_average": 0
    }
  ],
  "spoken_languages": [
    {
      "english_name": "English",
      "iso_639_1": "en",
      "name": "English"
    },
    {
      "english_name": "Spanish",
      "iso_639_1": "es",
      "name": "Español"
    }
  ],
  "status": "Ended",
  "tagline": "Change the equation.",
  "vote_average": 9,
  "vote_count": 18863,
  "content_ratings": {
    "results": [
      {
        "descriptors": [],
        "iso_3166_1": "AT",
        "rating": "16"
      },
      {
        "descriptors": [],
        "iso_3166_1": "AU",
        "rating": "MA 15+"
      }
    ]
  },
  "ratings": {
    "imdb": {
      "value": 9.5,
      "votes": 2671962
    },
    "kinopoisk": {
      "value": 8.9,
      "votes": null
    },
    "metacritic": null,
    "rotten_tomatoes": {
      "value": 96,
      "votes": null
    },
    "tmdb": {
      "value": 9,
      "votes": 18863
    }
  }
}

content_ratings 和 ratings 数据块来自 append_to_response。seasons、last_episode_to_air 和 next_episode_to_air 里的名称和简介是按记录存储的,可能不遵循 language,上面的希伯来语单集名称就是例子。本地化的季和单集文本请从季接口读取。

状态与单集指针

status 告诉你一部剧处于生命周期的哪个阶段,next_episode_to_air 告诉你何时该再来看看。

status 值含义next_episode_to_air
Returning Series正在播出或处于两季之间。日期已知时有值,否则为 null。
Planned、In Production还不是常规剧集。通常为 null。
Ended已播完。null。
Canceled在计划结束前停播。null。

处于两季之间的在播剧,其 next_episode_to_air 为 null,所以请把 null 理解为没有已知日期,而不是已经完结。

seasons 数组为每一季列出一条摘要,第 0 季存放特别篇。要读取某一季的单集,请调用季与单集接口。

相关的电视剧接口

所有路径共用基础地址 https://api.amodb.dev/3,带本地化文本的接口也接受 language。

方法和路径返回内容额外参数
GET /tv/{series_id}/alternative_titles{id, results},含 iso_3166_1、title、type,通常为空无
GET /tv/{series_id}/content_ratings各国的年龄分级无
GET /tv/{series_id}/episode_groups备选单集顺序列表,例如 DVD 顺序或剧情线无
GET /tv/{series_id}/recommendations20 部推荐剧集的列表无
GET /tv/{series_id}/similar20 部相似剧集的列表无
GET /tv/{series_id}/reviews大多数剧集的 results 为空无
GET /tv/{series_id}/lists包含这部剧的公开片单page
GET /tv/{series_id}/watch/providers各国的流媒体、租赁和购买平台无
GET /tv/latest最新添加的电视剧记录无

推荐和相似列表始终返回第 1 页的 20 条。lists 响应用 page 分页,每页 20 个片单。API 其他位置的分页列表,page 范围为 1 到 500。

内容分级以 results 条目返回,含 iso_3166_1、rating 和 descriptors,所以请选择与访客所在国家匹配的条目。观看平台按国家代码索引,每个国家包含一个 link 以及 flatrate、rent 和 buy 列表,列表项有 provider_id、provider_name、logo_path 和 display_priority。用于筛选的平台 ID 来自类型与查询列表中的查询列表。

单集分组列表返回 id(字符串)、name、description、type、episode_count、group_count 和 network。amodb 会列出这些分组,但不提供返回某个分组单集的接口,也不提供 TMDB 的 changes 路径。

把更多数据合并进一次调用

在 append_to_response 中列出子资源,每个都会出现在各自的键下。整个调用只计入你每分钟 20、40 或 120 个请求中的一个。最多可用 20 个值,未知名称会被忽略且不报错。以下值适用于电视剧:

值添加内容详情
credits演员和幕后人员演职员
external_idsimdb_id、tvdb_id 和 wikidata_id 等 ID按外部 ID 查找
images、videos海报、背景图、预告片图片、视频与预告片
keywords、translations标签和译文关键词、翻译
content_ratings、alternative_titles、episode_groups、lists、watch/providers、similar、recommendations、reviews上表中的子资源本页
ratings、moods、soundtracks、wikidata、showtimesamodb 扩展评分、情绪指数、原声配乐、放映时间

错误

失败的调用返回 TMDB 的错误体。错误的 ID 会给出 status_code 34 和消息 "The resource you requested could not be found."。

HTTPstatus_code何时出现
4017密钥缺失或错误。
40236套餐周期已结束。
40434没有该 ID 的电视剧、成人作品,或不提供的路径。
40537你调用了写入方法,例如给剧集评分。
42925超过每分钟请求数。请等待 Retry-After 秒。

完整列表见错误,各套餐的限制见速率限制。

实用说明

  • 电视剧详情和上面所有子资源缓存 6 小时。轮询 last_episode_to_air 每天不要超过几次。
  • 请求你要展示的语言。overview 为空表示没有译文,所以请用 en-US 重新请求作为回退。
  • 获取每一季时,把 number_of_seasons 用作循环上限,每季一次调用。
  • 要列出剧集而不是读取单部,请见搜索、发现 API和热门与榜单。