# Instagram 国家下的城市 API (instagram.location_cities)

- Canonical page: [https://everyinfra.com/instagram-api/location_cities](https://everyinfra.com/instagram-api/location_cities?utm_medium=ai_doc&utm_campaign=page_md)
- Endpoint: POST https://api.everyinfra.com/api/v1/social with {"platform": "instagram", "action": "location_cities", "params": {...}}
- Price: $0.000556 per call ($0.56 per 1,000 requests); failed calls and empty results are not charged
- Returns: list, one page of 96 per call (limit is ignored; pass the top-level next_page_token from the response as page_token for the next page)
- Pagination: pass next_page_token back as page_token for the next page, other params unchanged; one call per page, tokens last 24 hours
- Mode: sync; add "mode": "async" for slow tasks

## Health

- Live health (24h percent, hourly and daily trends): https://api.everyinfra.com/api/v1/social/availability?platform=instagram&action=location_cities

## Parameters

| name | type | required | default | description |
|---|---|---|---|---|
| country_code | not declared | yes | not declared | 国家代码，两个字母（ISO 3166-1），如 US、JP、GB，大小写都行。返回 Instagram 地点目录里这个国家下的城市，一页 96 个。 |
| page_token | not declared | no | not declared | 翻页令牌：把上一次响应里的 next_page_token 原样传回，拿下一页；不传是第一页。翻页时其他参数要和第一页一样。令牌 24 小时有效，每页算一次调用。没有 next_page_token 就是翻不下去了。 |

## Response fields (items in `results`)

| field | meaning |
|---|---|
| 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 | 名称。用于账号/商品/商家类能力，指该对象本身的名字。 |
| slug | Instagram 地点目录链接里的那段名字，如 st-patricks-cathedral。 |
| url | 该记录在原平台上的可访问链接。 |
| country_code | 国家代码，两个大写字母（ISO 3166-1），如 US。 |
| country_name | 国家的英文名，如 United States。 |
| platform | 数据来源平台标识，与请求里的 platform 一致（如 xiaohongshu、tiktok）。 |

## Example

```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"
  }
}'
```

```python
import os
import requests

response = requests.post(
    "https://api.everyinfra.com/api/v1/social",
    headers={"Authorization": f"Bearer {os.environ['EVERYINFRA_API_KEY']}"},
    json={
        "platform": "instagram",
        "action": "location_cities",
        "params": {
            "country_code": "US",
        },
    },
    timeout=120,
)
print(response.status_code)
print(response.json())
```

## Response example

Real response to the example request above, captured 2026-11-21T07:18:47Z. `results` and `count` are real with personal information (names, handles, avatars, profile links, contact details) removed; the list keeps the first 2 of 96. `id`, `billing` and `quota` differ on every call, so only their shape is shown.

```text
{
  "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": { … }
}
```

## Also

- Capability catalog (no key): https://api.everyinfra.com/api/v1/social/catalog?platform=instagram
- OpenAPI: https://everyinfra.com/openapi.json · Agents guide: https://everyinfra.com/agents.md
