> ## Documentation Index
> Fetch the complete documentation index at: https://docs.keyapi.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Get cities by country

> Get a list of cities/regions for a specified country.

<div className="inline-flex items-center gap-2 px-4 py-2 bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-lg">
  <span className="text-base">🪙</span>
  <span className="text-sm font-medium text-yellow-900 dark:text-yellow-100"><span className="font-semibold">2 credits</span><span className="text-yellow-700 dark:text-yellow-300 ml-1">per request</span></span>
</div>

## Copy for AI

<div className="my-6 rounded-xl border border-gray-200 bg-gray-50 p-5 dark:border-gray-800 dark:bg-gray-900/40">
  <div className="min-w-0">
    <p className="text-base font-semibold text-gray-900 dark:text-gray-100">🤖 Why Code When AI Can Do It For You?</p>
    <p className="mt-1 text-sm text-gray-700 dark:text-gray-300">Stop writing code like it's 1970! Let AI do the heavy lifting - click the sparkles to copy a perfectly formatted prompt for ChatGPT, Claude, or your favorite AI assistant.</p>
  </div>

  <div className="mt-4">
    <button
      type="button"
      className="inline-flex items-center gap-2 rounded-md border border-emerald-300 bg-emerald-50 px-3 py-2 text-sm font-medium text-emerald-800 hover:bg-emerald-100 dark:border-emerald-700 dark:bg-emerald-900/30 dark:text-emerald-100 dark:hover:bg-emerald-900/50"
      onClick={() => navigator.clipboard.writeText(`I want to make an API call to https://api.keyapi.ai/v1/instagram/fetch_cities.

Please help me write code to make this API call and handle the response appropriately. Include error handling and best practices.

Here are the details:

Endpoint: GET https://api.keyapi.ai/v1/instagram/fetch_cities

Description: Get a list of cities/regions for a specified country.

Required Headers:
--header 'Authorization: Bearer <YOUR_API_KEY>'

Parameters:
- country_code (Required): Country code, e.g., US, CN, JP. Example: US
- page (Optional): Page number, default is 1. Example: 1

Example Response:
{
"code": 0,
"message": "success",
"data": {
"country_info": {
  "id": "US",
  "name": "United States",
  "slug": "united-states"
},
"city_list": [
  {
    "id": "c2753900",
    "name": "Downtown-PennQuarter-Chinatown",
    "slug": "downtown-pennquarter-chinatown-united-states"
  },
  {
    "id": "c2728343",
    "name": "CivicCenter",
    "slug": "civiccenter-united-states"
  },
  {
    "id": "c2420379",
    "name": "LosAngeles",
    "slug": "losangeles-united-states"
  },
  {
    "id": "c2767424",
    "name": "Discovery",
    "slug": "discovery-united-states"
  },
  {
    "id": "c2438177",
    "name": "Chicago",
    "slug": "chicago-united-states"
  },
  {
    "id": "c2728325",
    "name": "MidtownEast",
    "slug": "midtowneast-united-states"
  },
  {
    "id": "c2728328",
    "name": "TheaterDistrict",
    "slug": "theaterdistrict-united-states"
  },
  {
    "id": "c2513785",
    "name": "United",
    "slug": "united-united-states"
  },
  {
    "id": "c2728320",
    "name": "GarmentDistrict",
    "slug": "garmentdistrict-united-states"
  },
  {
    "id": "c2731353",
    "name": "TheStrip",
    "slug": "thestrip-united-states"
  },
  {
    "id": "c2728334",
    "name": "FinancialDistrict",
    "slug": "financialdistrict-united-state
... (truncated)`)}
    >
      <span>✨</span>
      <span>Copy for AI</span>
    </button>
  </div>
</div>


## OpenAPI

````yaml en/instagram.openapi.json GET /v1/instagram/fetch_cities
openapi: 3.0.1
info:
  title: Instagram API english documentation
  description: >-
    The english reference documentation of the Instagram API includes the
    interface's purpose, parameter description, response status, and sample
    structure.
  version: 1.0.0
servers:
  - url: https://api.keyapi.ai
    description: Production
security:
  - JWT Bearer: []
tags: []
paths:
  /v1/instagram/fetch_cities:
    get:
      tags: []
      summary: Get cities by country
      description: Get a list of cities/regions for a specified country.
      parameters:
        - name: country_code
          in: query
          description: Country code, e.g., US, CN, JP
          required: true
          example: US
          schema:
            type: string
        - name: page
          in: query
          description: Page number, default is 1
          required: false
          example: 1
          schema:
            type: integer
            minimum: 1
            default: 1
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties: {}
              example:
                code: 0
                message: success
                data:
                  country_info:
                    id: US
                    name: United States
                    slug: united-states
                  city_list:
                    - id: c2753900
                      name: Downtown-PennQuarter-Chinatown
                      slug: downtown-pennquarter-chinatown-united-states
                    - id: c2728343
                      name: CivicCenter
                      slug: civiccenter-united-states
                    - id: c2420379
                      name: LosAngeles
                      slug: losangeles-united-states
                    - id: c2767424
                      name: Discovery
                      slug: discovery-united-states
                    - id: c2438177
                      name: Chicago
                      slug: chicago-united-states
                    - id: c2728325
                      name: MidtownEast
                      slug: midtowneast-united-states
                    - id: c2728328
                      name: TheaterDistrict
                      slug: theaterdistrict-united-states
                    - id: c2513785
                      name: United
                      slug: united-united-states
                    - id: c2728320
                      name: GarmentDistrict
                      slug: garmentdistrict-united-states
                    - id: c2731353
                      name: TheStrip
                      slug: thestrip-united-states
                    - id: c2728334
                      name: FinancialDistrict
                      slug: financialdistrict-united-states
                    - id: c2791472
                      name: LosAngelesCounty
                      slug: losangelescounty-united-states
                    - id: c2527622
                      name: Houston
                      slug: houston-united-states
                    - id: c2728134
                      name: Koreatown,Manhattan
                      slug: koreatownmanhattan-united-states
                    - id: c2731060
                      name: NearNorthSide
                      slug: nearnorthside-united-states
                    - id: c2728404
                      name: Harlem
                      slug: harlem-united-states
                    - id: c2490299
                      name: NewYork
                      slug: newyork-united-states
                    - id: c2728378
                      name: Chelsea
                      slug: chelsea-united-states
                    - id: c2750043
                      name: WashingtonMall
                      slug: washingtonmall-united-states
                    - id: c2732907
                      name: Hollywood
                      slug: hollywood-united-states
                    - id: c2731968
                      name: DowntownLosAngeles
                      slug: downtownlosangeles-united-states
                    - id: c2728335
                      name: UpperEastSide
                      slug: uppereastside-united-states
                    - id: c2728409
                      name: NoMad
                      slug: nomad-united-states
                    - id: c2731049
                      name: TheLoop
                      slug: theloop-united-states
                    - id: c2740811
                      name: DowntownAustin
                      slug: downtownaustin-united-states
                    - id: c2732983
                      name: Williamsburg
                      slug: williamsburg-united-states
                    - id: c2767920
                      name: SouthDowntown
                      slug: southdowntown-united-states
                    - id: c2417987
                      name: BeverlyHills
                      slug: beverlyhills-united-states
                    - id: c2733038
                      name: DupontCircle
                      slug: dupontcircle-united-states
                    - id: c2732822
                      name: FinancialDistrict
                      slug: financialdistrict-united-states
                    - id: c2728345
                      name: UpperWestSide
                      slug: upperwestside-united-states
                    - id: c2728405
                      name: MurrayHill
                      slug: murrayhill-united-states
                    - id: c2733075
                      name: DowntownDenver
                      slug: downtowndenver-united-states
                    - id: c2526493
                      name: Dallas
                      slug: dallas-united-states
                    - id: c2774689
                      name: DowntownLasVegas
                      slug: downtownlasvegas-united-states
                    - id: c2763505
                      name: WilshireCenter-Koreatown
                      slug: wilshirecenter-koreatown-united-states
                    - id: c3003304
                      name: GovernmentCenter
                      slug: governmentcenter-united-states
                    - id: c3004281
                      name: CentralBusinessDistrict
                      slug: centralbusinessdistrict-united-states
                    - id: c2731130
                      name: WestTown
                      slug: westtown-united-states
                    - id: c2728402
                      name: SoHo
                      slug: soho-united-states
                    - id: c2486989
                      name: Astoria
                      slug: astoria-united-states
                    - id: c2728411
                      name: FlatironDistrict
                      slug: flatirondistrict-united-states
                    - id: c2488566
                      name: Flushing
                      slug: flushing-united-states
                    - id: c2529068
                      name: Palestine
                      slug: palestine-united-states
                    - id: c2728399
                      name: WestVillage
                      slug: westvillage-united-states
                    - id: c2728363
                      name: HellsKitchen,Manhattan
                      slug: hellskitchenmanhattan-united-states
                    - id: c2733115
                      name: CivicCenter
                      slug: civiccenter-united-states
                    - id: c2422042
                      name: ShermanOaks
                      slug: shermanoaks-united-states
                    - id: c2734060
                      name: DowntownSanAntonio
                      slug: downtownsanantonio-united-states
                    - id: c2727918
                      name: Paradise
                      slug: paradise-united-states
                    - id: c2732375
                      name: LincolnPark
                      slug: lincolnpark-united-states
                    - id: c2728415
                      name: UnionSquare
                      slug: unionsquare-united-states
                    - id: c2734409
                      name: AvenueoftheArtsSouth
                      slug: avenueoftheartssouth-united-states
                    - id: c2464828
                      name: Boston
                      slug: boston-united-states
                    - id: c2443073
                      name: Morocco
                      slug: morocco-united-states
                    - id: c2731115
                      name: NearWestSide
                      slug: nearwestside-united-states
                    - id: c2703669
                      name: LongIslandCity
                      slug: longislandcity-united-states
                    - id: c2422816
                      name: WestHollywood
                      slug: westhollywood-united-states
                    - id: c2542527
                      name: Seattle
                      slug: seattle-united-states
                    - id: c2427178
                      name: WashingtonD.C.
                      slug: washingtondc-united-states
                    - id: c2413713
                      name: Phoenix
                      slug: phoenix-united-states
                    - id: c2733705
                      name: CrownHeights
                      slug: crownheights-united-states
                    - id: c2422661
                      name: VanNuys
                      slug: vannuys-united-states
                    - id: c2998972
                      name: NewYorkCounty
                      slug: newyorkcounty-united-states
                    - id: c2418269
                      name: CaliforniaCity
                      slug: californiacity-united-states
                    - id: c2732895
                      name: Pinedale
                      slug: pinedale-united-states
                    - id: c2732382
                      name: DowntownDetroit
                      slug: downtowndetroit-united-states
                    - id: c2728365
                      name: WashingtonHeights,Manhattan
                      slug: washingtonheightsmanhattan-united-states
                    - id: c2732440
                      name: EastHollywood
                      slug: easthollywood-united-states
                    - id: c2492610
                      name: Woodside
                      slug: woodside-united-states
                    - id: c2418944
                      name: Downey
                      slug: downey-united-states
                    - id: c2505639
                      name: Portland
                      slug: portland-united-states
                    - id: c2703980
                      name: Manhattan
                      slug: manhattan-united-states
                    - id: c2731254
                      name: Midwood
                      slug: midwood-united-states
                    - id: c2728327
                      name: GreenwichVillage
                      slug: greenwichvillage-united-states
                    - id: c2756885
                      name: SouthBeach
                      slug: southbeach-united-states
                    - id: c2421002
                      name: Northridge
                      slug: northridge-united-states
                    - id: c2728412
                      name: NoHo
                      slug: noho-united-states
                    - id: c2732408
                      name: SunsetPark
                      slug: sunsetpark-united-states
                    - id: c2743520
                      name: DoralPlaza
                      slug: doralplaza-united-states
                    - id: c2732071
                      name: Sawtelle
                      slug: sawtelle-united-states
                    - id: c2732172
                      name: DowntownHouston
                      slug: downtownhouston-united-states
                    - id: c2731105
                      name: BoroughPark
                      slug: boroughpark-united-states
                    - id: c2731768
                      name: Waikiki
                      slug: waikiki-united-states
                    - id: c2764510
                      name: WoodlandHills-WarnerCenter
                      slug: woodlandhills-warnercenter-united-states
                    - id: c2421846
                      name: SanJose
                      slug: sanjose-united-states
                    - id: c2728344
                      name: Tribeca
                      slug: tribeca-united-states
                    - id: c2769818
                      name: DowntownSantaMonica
                      slug: downtownsantamonica-united-states
                    - id: c2731957
                      name: Gulfton
                      slug: gulfton-united-states
                    - id: c2732198
                      name: Greenpoint
                      slug: greenpoint-united-states
                    - id: c2757578
                      name: Westchase
                      slug: westchase-united-states
                    - id: c2498913
                      name: Columbus
                      slug: columbus-united-states
                    - id: c2419135
                      name: Encino
                      slug: encino-united-states
                    - id: c2732837
                      name: KearnyMesa
                      slug: kearnymesa-united-states
                    - id: c2772370
                      name: DowntownSanFrancisco
                      slug: downtownsanfrancisco-united-states
                    - id: c2527654
                      name: Humble
                      slug: humble-united-states
                  next_page: 2
                  status: ok
                  attempts: '1'
                requestId: c4c6d2e8-da04-4c82-9240-ae6edf85e181
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                type: object
                example:
                  code: 400
                  data: null
                  message: 'Missing required parameter: handle'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                example:
                  code: 401
                  data: null
                  message: apiKey is null
        '402':
          description: Payment Required
          content:
            application/json:
              schema:
                type: object
                example:
                  code: 402
                  data: null
                  message: apiKey quota is not enough
        '429':
          description: Too Many Requests
          content:
            application/json:
              schema:
                type: object
                example:
                  code: 429
                  data: null
                  message: qps limit exceeded
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                type: object
                example:
                  code: 500
                  data: null
                  message: Internal server error
      deprecated: false
      security:
        - JWT Bearer: []
      x-codeSamples:
        - lang: curl
          label: cURL
          source: |-
            curl --request GET \
              --url 'https://api.keyapi.ai/v1/instagram/fetch_cities?country_code=US&page=1' \
              --header 'Authorization: Bearer <YOUR_API_KEY>'
        - lang: python
          label: Python
          source: |-
            import requests

            response = requests.get(
                'https://api.keyapi.ai/v1/instagram/fetch_cities',
                params={"country_code": "US", "page": 1},
                headers={'Authorization': 'Bearer <YOUR_API_KEY>'}
            )
            print(response.json())
        - lang: javascript
          label: JavaScript
          source: >-
            const params = new URLSearchParams({"country_code": "US", "page":
            1});


            const response = await
            fetch(`https://api.keyapi.ai/v1/instagram/fetch_cities?${params}`, {
              method: 'GET',
              headers: { 'Authorization': 'Bearer <YOUR_API_KEY>' }
            });

            const data = await response.json();

            console.log(data);
components:
  securitySchemes:
    JWT Bearer:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: |-
        API key for authentication. Format: `sk_live_xxxxxxxxxxxxx`
        Get your API key from the [Dashboard](http://keyapi.ai/app/dashboard).

````