Instagram 国家下的城市 API

按两位 country_code(如 US)列出 Instagram 地点目录里这个国家下的城市:city_id、name、slug、url,每千次 $0.56。

  • city_id 接 city_locations
  • 大小写都行
  • 失败和空结果不收费
免费开始

接口健康状态

24h 健康值
正常
  • 健康 / 正常
  • 可用
  • 少量可用
  • 基本不可用
正常

24 小时趋势

30 天趋势

  1. 1请求

    POST /api/v1/social
    {
      "platform": "instagram",
      "action": "location_cities",
      "params": {
        "country_code": "US"
      }
    }
  2. 2JSON 响应

    {
      "results": [
        {
          "rank": 1,
          "city_id": "c2753900",
          "name": "Downtown-PennQuarter-Chinatown",
          "slug": "downtown-pennquarter-chinatown-united-states"
        },
        …
      ],
      "count": 96
    }
  3. 3表格行

    rankcity_idnameslug
    1c2753900Downtown-PennQuarter-Chinatowndowntown-pennquarter-chinatown-united-states
    2c2728343CivicCenterciviccenter-united-states
  4. 4CSV

    instagram-location_cities-sample.csv rank,city_id,name,slug,url,country_code,country_name,platform

请求带 country_code,同一个响应里回来这个国家在地点目录里的一页城市,每行有 city_id、name、slug,再变成表格行和 CSV。

能拿到什么数据

表里是一次真实调用的结果:国家代码 US,2026年11月21日 15:18(UTC)采集,返回 96 行。你自己调用时,按字段表返回这些字段。

rankcity_idnameslugurlcountry_codecountry_nameplatform
1c2753900Downtown-PennQuarter-Chinatowndowntown-pennquarter-chinatown-united-stateshttps://www.instagram.com/explore/locations/c2753900/downtown-pennquarter-chinatown-united-states/USUnited Statesinstagram
2c2728343CivicCenterciviccenter-united-stateshttps://www.instagram.com/explore/locations/c2728343/civiccenter-united-states/USUnited Statesinstagram

用途

  • 列出一个国家的城市

    给一个 country_code,读地点目录里这个国家下的城市。

  • 接着往下找地点

    把 city_id 交给 city_locations,列出城市下的地点。

  • 对回目录页

    用 slug 和 url 对回 Instagram 地点目录里的页面。

  • 逐国铺开

    换不同的 country_code,一个国家一个国家地列城市。

Instagram Graph API 与 EveryInfra 对比

下面从平台范围、接入审核两方面,比 Instagram 官方 Graph API 和 EveryInfra location_cities。

对比项Instagram Graph APIEveryInfra
平台范围"The Instagram Platform is a collection of APIs that allows your app to access data for Instagram professional accounts, including business and creator accounts."读的是 Instagram 地点目录里的城市,不是哪个专业账号的数据;不用先把 Instagram 账号接到你的应用上。
接入审核Advanced Access:"Advanced Access is the access level required if your app serves Instagram professional accounts that you don’t own or manage" 以及 "This access level requires App Review and Business Verification."一把 EveryInfra API Key 放在 Authorization: Bearer 请求头里,不用提交 Meta 应用审核,也不用登录 Instagram。

引文出自 Meta 开发者文档,2026-11-22 核对;这里只比接入条件。 官方出处: Instagram Platform overview (更新于 2026-10-29)

限制和注意事项

  • country_code 必填,两位字母(ISO 3166-1),如 US、JP、GB,大小写都行。
  • 返回的是 Instagram 地点目录里这个国家下的城市;国家不在目录里时返回空结果,不扣费。
  • 一次返回一页。响应有 next_page_token 就原样作 page_token 传回,其他参数和第一页一样;令牌 24 小时有效,每页算一次调用;没有 next_page_token 就翻不下去了。
  • 最后一页可能不满。
  • country_name 是国家的英文名,如 United States。
  • city_id 是 c 加数字,如 c2728325,拿去调 city_locations。

价格

每次调用 $0.000556,按次计费,不按行数算。每翻一页算一次调用。失败和空结果不收费。

调用次数费用
10,000$5.56
100,000$55.56
1,000,000$555.56

合计按每次调用的标价算。

代码示例

#
bash
curl -X POST 'https://api.everyinfra.com/api/v1/social' \
  -H "Authorization: Bearer $EVERYINFRA_API_KEY" \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "platform": "instagram",
  "action": "location_cities",
  "params": {
    "country_code": "US"
  }
}'

OpenAPI 定义 (JSON)示例从环境变量 EVERYINFRA_API_KEY 读取 Key,复制出去的代码不含你的 Key。

API 参考

下面是 location_cities 的参数、响应字段、错误和计费,可以复制整页,或用 Markdown 打开后交给 AI 助手。

POST

AI 提示词

#
请帮我用 EveryInfra 的「Instagram 国家下的城市」接口(instagram/location_cities)写一个数据采集脚本。

接口约定:
- 请求:POST https://api.everyinfra.com/api/v1/social,请求头 Authorization: Bearer <API Key>;Key 从环境变量 EVERYINFRA_API_KEY 读取,不要写进代码。
- 请求体里 platform 填 instagram,action 填 location_cities,参数放在 params 里。
- 必填参数:
  - country_code:国家代码,两个字母(ISO 3166-1),如 US、JP、GB,大小写都行。返回 Instagram 地点目录里这个国家下的城市,一页 96 个。
- 可选参数:
  - page_token:翻页令牌:把上一次响应里的 next_page_token 原样传回,拿下一页;不传是第一页。翻页时其他参数要和第一页一样。令牌 24 小时有效,每页算一次调用。没有 next_page_token 就是翻不下去了。
- 返回一组记录,每条记录的主要字段:rank(名次)、city_id(城市编号)、name、slug(Instagram 地点目录链接里…)、url、country_code(国家代码)、country_name(国家的英文名)。
- 示例请求体:
{
  "platform": "instagram",
  "action": "location_cities",
  "params": {
    "country_code": "US"
  }
}
- 计费:$0.56 / 千次;失败和空结果不扣费。
- 一次要采几十上百个时,在请求体加 "mode": "async":先拿到 job_id,再轮询 GET https://api.everyinfra.com/api/v1/jobs/{job_id} 取结果。
- 返回 422 时,按错误信息里的候选参数和允许值修正;返回 429 或 503 时,按 Retry-After 等待后重试。

写代码前,先问清楚我要采哪些对象、一共多少个、需要哪些字段、结果存成什么格式,再把方案和大概花费讲给我确认。

请求参数

#
参数名位置类型必填默认值说明
Authorizationheaderstring是-Bearer 加你的 API Key。在控制台创建;不要放进网址或代码仓库。
platformbodystring是instagram平台标识,固定值。
actionbodystring是location_cities能力标识,固定值。
country_codebody.paramsstring是-国家代码,两个字母(ISO 3166-1),如 US、JP、GB,大小写都行。返回 Instagram 地点目录里这个国家下的城市,一页 96 个。
page_tokenbody.paramsstring否-翻页令牌:把上一次响应里的 next_page_token 原样传回,拿下一页;不传是第一页。翻页时其他参数要和第一页一样。令牌 24 小时有效,每页算一次调用。没有 next_page_token 就是翻不下去了。

响应示例

#
2026年11月21日 15:18(北京时间)用上方代码示例的参数真实调用所得。results 与 count 是那次的真实返回,已隐去名字、账号、头像、主页链接、联系方式等个人信息,列表只保留前 2 条;id、billing、quota 每次调用都不同,只给结构。
json
{  "id": "req_…",  "platform": "instagram",  "action": "location_cities",  "results": [    {      "rank": 1,      "city_id": "c2753900",      "name": "Downtown-PennQuarter-Chinatown",      "slug": "downtown-pennquarter-chinatown-united-states",      "url": "https://www.instagram.com/explore/locations/c2753900/downtown-pennquarter-chinatown-united-states/",      "country_code": "US",      "country_name": "United States",      "platform": "instagram"    },    {      "rank": 2,      "city_id": "c2728343",      "name": "CivicCenter",      "slug": "civiccenter-united-states",      "url": "https://www.instagram.com/explore/locations/c2728343/civiccenter-united-states/",      "country_code": "US",      "country_name": "United States",      "platform": "instagram"    }  ],  "next_page_token": …,  "pagination": { … },  "count": 96,  "billing": {    "charged": …,    "charged_usd": …,    "balance_after_usd": …,    …  },  "quota": { … }}

返回字段

#

业务数据在 results 里;下表是每条记录可能包含的字段,平台没有提供的值不会被编造。

字段含义
rank名次,从 1 开始,是这一行在这次结果里的顺序。user_search:先是 Instagram 搜索框给的账号(matched_by 为 search_box),按搜索框的顺序;后面是用这个关键词搜到的帖子的作者,用来补足条数(matched_by 为 post_author);没有 matched_by 的结果是 Instagram 给这个关键词排的账号位置。similar_profiles:相似账号的名次,按粉丝数从多到少。likers:点赞名单里的顺序。
city_id城市编号,c 加数字,如 c2728325。拿去调 city_locations 看这个城市下的地点。
name名称。用于账号/商品/商家类能力,指该对象本身的名字。
slugInstagram 地点目录链接里的那段名字,如 st-patricks-cathedral。
url该记录在原平台上的可访问链接。
country_code国家代码,两个大写字母(ISO 3166-1),如 US。
country_name国家的英文名,如 United States。
platform数据来源平台标识,与请求里的 platform 一致(如 xiaohongshu、tiktok)。

错误与计费

#
401
缺少 Key 或 Key 无效。
402
余额不足,先充值。
422
参数名或取值不对,按错误信息给的候选改;不扣费。
429
超过每分钟请求上限,按 Retry-After 等待后再试。
503
暂时无法完成,预扣的费用退回;结果未知时先核对,不要直接重发。
200 空结果
没有数据,不扣费。

错误码

官方资料参照

#

只用于核对对象与术语,不表示平台对 EveryInfra 的授权或背书。

  • Instagram 地点目录:国家页下的城市 ↗

    Instagram 公开的地点目录先列国家,点进国家页(路径里是两位国家码,如 SG)会列出该国的城市,城市链接里的编号是 c 加数字(如 c2160986)。可证明「国家下的城市」是 Instagram 自己的目录结构,country_code 是两位国家码、city_id 是 c 加数字;这是目录页本身,不是接口文档,不证明每页 96 个、分页方式、rank 的含义或目录是否完整。

    核对于 2026-11-21

常见问题

Instagram 国家下的城市接口返回什么?

每行一个城市:city_id、name、slug、url、country_code、country_name,还有 rank。

country_code 怎么写?

两位字母的国家代码(ISO 3166-1),如 US、JP、GB,大小写都行。

怎么取下一页?

响应有 next_page_token 时,原样作 page_token 传回,其他参数不变。没有 next_page_token 就翻不下去了。

读一页城市要多少钱?

每次 $0.000556,每千次 $0.56,每页算一次调用,不按行数算。失败和空结果不收费。

要登录 Instagram 吗?

不用。请求头里放一把 EveryInfra API Key(Authorization: Bearer),请求只带 country_code,不需要 Instagram 登录或访问令牌。

同一把 Key 还能调用 Instagram 的其他能力,比如用 city_locations 列出某个城市下的地点。

Google Analytics 同意才加载 隐私