电影院排片 API:按国家和电影查询场次

电影院排片 API 是 GET /3/movie/{movie_id}/showtimes?country=RU,返回某国的影院、带日期的场次和订票链接,每次最多 1,500 个场次。不带 country 只返回各国数量,results 为空表示未知。

更新于 以 Markdown 查看

怎样获取一部电影的影院场次?

用两位国家代码调用 GET /3/movie/{movie_id}/showtimes?country=RU。响应列出该国放映这部电影的影院,每个影院带有日期的场次、格式,影院提供时还有订票链接。每次调用最多返回 1,500 个场次,results 数组为空表示这部作品在该国没有已知数据。

amodb 在 TMDB v3 的基础 URL https://api.amodb.dev/3 下提供这个接口,套餐 $5.19 一个月起,见 amodb 定价。TMDB 没有场次数据,所以这是加在 v3 结构上的额外内容。想了解可以用它做什么,见电影排片 API页面。

country 参数接受两位国家代码,大小写均可。各国家和作品的覆盖情况不同,所以已知的地方有数据,未知的地方没有。只返回从今天起的日期。

示例请求 Fight Club 在俄罗斯的场次,并处理空的响应。

bashjspyphpgo
curl -sf "https://api.amodb.dev/3/movie/550/showtimes?country=RU" \
  -H "Authorization: Bearer $AMODB_KEY"
const url = 'https://api.amodb.dev/3/movie/550/showtimes?country=RU';
const res = await fetch(url, { headers: { Authorization: `Bearer ${process.env.AMODB_KEY}` } });
if (!res.ok) throw new Error(`amodb returned ${res.status}`);
const data = await res.json();
if (data.results.length === 0) console.log('no showtimes known');
for (const venue of data.results) {
  for (const s of venue.showtimes) {
    console.log(venue.name, venue.city, s.start, s.formats.join(','), s.booking_url);
  }
}
import os
import requests

r = requests.get(
    "https://api.amodb.dev/3/movie/550/showtimes",
    params={"country": "RU"},
    headers={"Authorization": f"Bearer {os.environ['AMODB_KEY']}"},
    timeout=10,
)
r.raise_for_status()
results = r.json()["results"]
if not results:
    print("no showtimes known")
for venue in results:
    for s in venue["showtimes"]:
        print(venue["name"], venue["city"], s["start"], ",".join(s["formats"]))
<?php
$url = 'https://api.amodb.dev/3/movie/550/showtimes?country=RU';
$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");
}
$results = json_decode($body, true)['results'];
if (!$results) {
    echo 'no showtimes known', PHP_EOL;
}
foreach ($results as $venue) {
    foreach ($venue['showtimes'] as $s) {
        echo $venue['name'], ' ', $s['start'], ' ', implode(',', $s['formats']), PHP_EOL;
    }
}
package main

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

type Venue struct {
	Name      string `json:"name"`
	City      string `json:"city"`
	Showtimes []struct {
		Start      string   `json:"start"`
		Formats    []string `json:"formats"`
		BookingURL string   `json:"booking_url"`
	} `json:"showtimes"`
}

func main() {
	url := "https://api.amodb.dev/3/movie/550/showtimes?country=RU"
	req, _ := http.NewRequest("GET", url, 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 body struct {
		Results []Venue `json:"results"`
	}
	if err := json.NewDecoder(res.Body).Decode(&body); err != nil {
		panic(err)
	}
	if len(body.Results) == 0 {
		fmt.Println("no showtimes known")
	}
	for _, v := range body.Results {
		for _, s := range v.Showtimes {
			fmt.Println(v.Name, v.City, s.Start, strings.Join(s.Formats, ","))
		}
	}
}

参数

  • movie_id路径必填
    数字形式的电影 id,例如 550。
  • country查询
    两位国家代码,如 RU。不带它只得到各国汇总。region 是它的别名。
  • api_key查询二选一
    你的密钥。用它,或者用 Authorization: Bearer 请求头。

响应字段

字段类型说明
id整数电影 id。
country字符串或 null你请求的大写代码;country 缺失或不是两位字母时为 null。
results数组每个影院一个对象,按影院排序。没有已知数据或没有传国家时为空。总共最多 1500 个场次。
results[].id整数影院 id,与 GET /3/cinema/{cinema_id} 中的相同。
results[].name字符串影院名称。
results[].chain对象id 是院线 id,用于影院搜索的 chain_id,name 是院线名称或 null。
results[].city字符串或 null城市。
results[].region字符串或 null地区。
results[].address字符串或 null街道地址。
results[].postal_code字符串或 null邮政编码。
results[].country字符串影院所在国家的代码。
results[].timezone字符串或 nullIANA 时区,如 Europe/Moscow。
results[].latitude、results[].longitude数字或 null影院位置。
results[].phone字符串或 null电话号码。
results[].url字符串或 null影院页面。
results[].showtimes数组该影院的放映场次,按开场时间排序。
results[].showtimes[].date字符串日期,如 2026-10-18。
results[].showtimes[].start字符串影院当地时间的开场时间,如 2026-10-18T21:40,不带 UTC 偏移。
results[].showtimes[].end字符串或 null影院当地时间的结束时间。
results[].showtimes[].auditorium字符串或 null放映厅名称。
results[].showtimes[].formats字符串数组格式,如 2D。
results[].showtimes[].tags字符串数组附加标签。常常为空。
results[].showtimes[].audio、subtitles、language字符串或 null已知时的音轨、字幕和语言信息。
results[].showtimes[].price数字或 null票价。
results[].showtimes[].currency字符串或 nullprice 的货币。
results[].showtimes[].prices任意类型或 null影院有多种票价时的价格详情。
results[].showtimes[].booking_url字符串或 null订座链接。
results[].showtimes[].sold_out布尔值场次售罄时为 true。
countries数组各国汇总,见下文。

请按名称读取你用到的键,忽略影院或场次对象里多出来的键。目前许多字段是 null,因为不是每个影院都会提供。

示例响应

JSON
{
  "id": 550,
  "country": "RU",
  "results": [
    {
      "id": 59144183,
      "name": "Мираж Синема НА БОЛЬШОМ",
      "chain": {
        "id": 1806967684,
        "name": "Мираж Синема"
      },
      "city": "Санкт-Петербург",
      "region": null,
      "address": "Большой пр. П.С., д. 35А",
      "postal_code": null,
      "country": "RU",
      "timezone": "Europe/Moscow",
      "latitude": null,
      "longitude": null,
      "phone": null,
      "url": "https://www.mirage.ru/spb/cinema/1/",
      "showtimes": [
        {
          "date": "2026-10-18",
          "start": "2026-10-18T21:40",
          "end": null,
          "auditorium": null,
          "formats": ["2D"],
          "tags": [],
          "audio": null,
          "subtitles": null,
          "language": null,
          "price": null,
          "currency": null,
          "prices": null,
          "booking_url": "https://www.mirage.ru/ticket_new/aca7b114-d587-4fc5-9df6-28568e8fa9b3/",
          "sold_out": false
        },
        {
          "date": "2026-10-19",
          "start": "2026-10-19T22:20",
          "end": null,
          "auditorium": "Зал №4",
          "formats": ["2D"],
          "tags": [],
          "audio": null,
          "subtitles": null,
          "language": null,
          "price": null,
          "currency": null,
          "prices": null,
          "booking_url": "https://www.mirage.ru/ticket_new/0c32e190-890a-4c81-a754-3300fefc4d5e/",
          "sold_out": false
        }
      ]
    }
  ],
  "countries": [
    {
      "country": "RU",
      "name": "Russia",
      "venues": 2,
      "cities": 1,
      "showtimes": 7,
      "first_day": "2026-10-18",
      "last_day": "2026-10-21"
    }
  ]
}

列表从 2 个影院中截取了 1 个,从 4 个场次中截取了 2 个。场次只存在于尚未过去的日期,所以这个响应每天都会变化。

哪些国家有一部作品的场次?

不传 country,响应里只有数量。results 保持为空,country 为 null。countries 数组列出最多 60 个仍有放映的国家,场次最多的排最前。在请求影院之前,先用它了解作品在哪里上映。

curl
curl -sf "https://api.amodb.dev/3/movie/550/showtimes" \
  -H "Authorization: Bearer $AMODB_KEY"
JSON
{
  "id": 550,
  "country": null,
  "results": [],
  "countries": [
    {
      "country": "RU",
      "name": "Russia",
      "venues": 2,
      "cities": 1,
      "showtimes": 7,
      "first_day": "2026-10-18",
      "last_day": "2026-10-21"
    }
  ]
}
字段类型说明
countries[].country字符串两位代码,可直接作为 country 参数使用。
countries[].name字符串英文国家名。
countries[].venues整数有放映的影院数。
countries[].cities整数有放映的城市数。
countries[].showtimes整数从今天起的放映场次数。
countries[].first_day、countries[].last_day字符串有放映的第一天和最后一天。

没有数据的国家代码,例如对这部电影传 country=US,响应里的 country 为 US,results 为空,countries 列表相同。在任何地方都没有场次的作品,如剧集 1396,返回 "countries": []。

怎样把场次加到电影页面上?

append_to_response=showtimes 会把同样的块合并进详情响应的 showtimes 键下。请在同一个请求里传 country 代码。这个块保留自己的 id、country、results 和 countries 键。

请求结果
/3/movie/550?append_to_response=showtimes&country=RU电影记录,加上俄罗斯的 showtimes 块
/3/movie/550?append_to_response=credits,showtimes&country=RU在同一个调用里再加上演职员

它算一次请求,所以同时显示演员表和场次的电影页面只需要一个调用。剧集有同样的接口:GET /3/tv/{tv_id}/showtimes。

怎样列出正在上映的电影及其场次?

正在上映的列表给你作品,场次接口给你一部作品的放映场次。在你的代码里把它们连起来。

步骤请求结果
1GET /3/movie/now_playing?region=RU&page=1每页最多 20 部电影,缓存 30 分钟
2对每个 id 调用 GET /3/movie/{id}/showtimes?country=RU影院和时间,已知时返回

下面的循环在达到套餐限制时重试一两次,等待 Retry-After 给出的秒数。

JavaScript
const base = 'https://api.amodb.dev/3';
const headers = { Authorization: `Bearer ${process.env.AMODB_KEY}` };

async function get(path, retries = 2) {
  const res = await fetch(base + path, { headers });
  if (res.status === 429 && retries > 0) {
    const wait = Number(res.headers.get('Retry-After') ?? 60);
    await new Promise((resolve) => setTimeout(resolve, wait * 1000));
    return get(path, retries - 1);
  }
  if (!res.ok) throw new Error(`amodb returned ${res.status} for ${path}`);
  return res.json();
}

const playing = await get('/movie/now_playing?region=RU&page=1');
for (const movie of playing.results) {
  const data = await get(`/movie/${movie.id}/showtimes?country=RU`);
  if (data.results.length > 0) console.log(movie.title, data.results.length, 'venues');
}

一页 20 部作品要 20 次场次请求。在每分钟 20 次的套餐上,这会用满整个窗口,所以请在你这边缓存结果。列表参数见 TMDB 热门 API。

一个场次页面要多少次请求?

每个调用都按你套餐的速率算一次请求,由边缘缓存返回的响应也算。下表列出一个典型页面需要的调用,以及它们能否放进一个 60 秒窗口。

任务请求数能否放进一个窗口:Lite(20)、Pro(40)、Pro+(120)
一部电影在一个国家的场次1三个套餐都可以
一部电影的国家汇总1三个套餐都可以
附加了 showtimes 的电影详情1三个套餐都可以
一页 20 部正在上映的作品,再为每部取场次21Lite 不行,Pro 和 Pro+ 可以

三个套餐允许每分钟 20、40 和 120 次请求,价格是每月 $5.19、$6.19 和 $7.19。滑动窗口和 Retry-After 响应头见速率限制,正在上映的列表请按它在边缘缓存的 30 分钟来缓存。

错误

错误体遵循 TMDB:success、status_code 和 status_message。密钥错误时 status_code 为 7。

HTTPstatus_code何时出现
4017密钥缺失或错误。
40236套餐期限已结束。
40434没有这个 id 的电影。
42925超出每分钟请求数。请等待 Retry-After 给出的秒数。

没有场次不是错误:预期返回状态 200 和空的 results 数组。缺少或无效的 country 同样不是错误。见错误码和速率限制。

实用提示

  • 覆盖情况因国家和作品而异。把空的 results 数组当作未知,而不是没有上映。
  • 原样显示 start。它是影院的当地时间,不带 UTC 偏移,访客期待看到的就是影院自己的时钟。
  • 场次在边缘缓存 30 分钟。不要在每次页面浏览时都请求,并保持你自己的缓存较短。
  • 一个地区的所有访客复用同一份正在上映的列表。它在边缘同样缓存 30 分钟。
  • 用 booking_url 把访客送到影院的订票页面。影院没有提供链接时它是 null。
  • 影院的 id 可以配合 GET /3/cinema/{cinema_id}/showtimes 打开该影院的完整排期,影院参考可按城市、街道或位置查找影院。
  • 想了解使用场景,见电影排片 API页面,电影上的其他数据见电影详情 API。
  • 还有其他提供场次数据的服务,如 MovieGlu 和 International Showtimes。当前条款请到它们的网站查看。
  • 上面的循环是普通的 JavaScript。包含密钥、重试和缓存的完整设置见用 JavaScript 调用 TMDB API教程,其他所有接口见 API 参考。