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

# County Lookups

> List counties by country or state, inspect a county and find its source-linked cities

County endpoints use the usual API key and count toward your request quota. Basic
lookups are available on every standard REST plan. Supporter+ adds coordinates,
source classification, population, translations and Wikidata fields.

| Method | Path | Result |
| - | - | - |
| GET | `/v1/countries/{country}/counties` | All counties in the country |
| GET | `/v1/countries/{country}/states/{state}/counties` | Counties linked to that state |
| GET | `/v1/countries/{country}/counties/{id}` | One county, scoped to its country |
| GET | `/v1/countries/{country}/counties/{id}/cities` | Cities with that explicit source county link |

Use an ISO2 country code (for example `NZ`) or numeric country ID. State paths use
the state's code. County IDs must be positive safe integers. Unknown country,
state or county details return `404`; a valid country/state with no counties
returns an empty array. REST lists return complete arrays, ordered by name then ID
unless you request another supported sort.

```bash theme={null}
curl 'https://api.countrystatecity.in/v1/countries/NZ/counties/14024' \
  -H 'X-CSCAPI-KEY: YOUR_API_KEY'
```

## Counties spanning several states

A county may have no single primary state. Preserve `state_id: null` and
`state_code: null` and use its `states` array, which contains every known source
membership as `{id, name, code}`. An empty array means no state link is recorded.
Filtering by one state still returns the complete membership array.

For example, the source release installed on 24 November 2026 links **Taupō
District** (`14024`, New Zealand) to four states. It appears in all four state
lists; it is not duplicated within any one list. Do not assign it a primary state
based on the first array item. Source state/region terminology varies by country.

## Fields and access

| Access level | Fields |
| - | - |
| Basic (all standard plans) | `id`, `name`, `country_id`, `country_code`, `state_id`, `state_code`, `states` |
| Coordinates (custom plans) | Basic + `type`, `type_local`, `level`, `parent_id`, `latitude`, `longitude`, `native`, `population`, `timezone` |
| Full (Supporter+) | Coordinates + `translations`, `wikiDataId`; `localized_name` and `matched_locale` when localization is requested |

IDs and population counts are serialized as strings; coordinates are nullable
strings. Translations use the existing JSON-encoded string format. Use
[`?locale=` and `?include_translations=true`](https://docs.countrystatecity.in/api/localization) for localized output.

[`?fields=` and `?sort=`](https://docs.countrystatecity.in/api/field-filtering-and-sorting) require Starter+.
County sortable fields are `id`, `name`, `country_code`, `state_code`, `type`,
`population`, `latitude` and `longitude`, subject to your field access.
Substring search `?q=` also requires Starter+ (2–100 characters) and matches
county names. Search, field selection and sort do not change the source membership array.

```bash theme={null}
curl 'https://api.countrystatecity.in/v1/countries/US/counties?fields=name,state_code&sort=name' \
  -H 'X-CSCAPI-KEY: YOUR_API_KEY'
```

## City relationships

City responses at coordinates/full access include nullable `county_id`, including
city lists, nearby/fuzzy results and GraphQL. Basic city responses keep `id`,
`name` and `kind`. A missing county link stays `null`; the API does not infer it
from a city name, postcode or location.

County city lists return the existing city shape with its tier rules and support
`?kind=`, eligible `?type=`, `?q=`, `?fields=`, `?sort=` and localization. A county
with no linked cities returns `[]`. County coverage is country-dependent and not
an exhaustive worldwide administrative boundary service.

Responses include `ETag`, `X-Cache` and `Cache-Control`; conditional requests with
`If-None-Match` can return `304`. Data-only source updates refresh these caches
through the same geographic import process.

## GraphQL

On Professional+ (or a custom plan with GraphQL enabled), use `counties`, `county`
and `countyCities`. Root lists default to 1,000 rows and support `limit`/`offset`;
`County.states` defaults to 20 items and accepts the same paging arguments.
The existing [GraphQL resource budget](https://docs.countrystatecity.in/api/graphql.md#query-budget) applies.

```graphql theme={null}
{
  county(country: "NZ", id: "14024") {
    id
    name
    state_id
    states { id name code }
  }
  countyCities(country: "NZ", county: "14024", limit: 10) {
    id
    name
    county_id
  }
}
```

> [!NOTE]
>
> The [change feed](https://docs.countrystatecity.in/api/endpoints/get-data-changes.md) still tracks countries,
> states and cities. City `county_id` participates in city snapshots on subsequent
> publication; county entity changes are not included in that feed.


## OpenAPI

````yaml GET /countries/{ciso}/counties
openapi: 3.0.3
info:
  title: Country State City API
  description: >-
    Geographic data API providing countries, states, counties, cities,
    postcodes, timezones, currencies, and phone dial codes with tiered access
    levels.


    ## Authentication

    All endpoints require an API key passed via the `X-CSCAPI-KEY` header. Get
    your free key at [app.countrystatecity.in](https://app.countrystatecity.in).


    ## Pricing & Limits

    The fields returned, endpoints available, and request quotas depend on your
    plan. See current tiers and limits at:


    **[countrystatecity.in/pricing](https://countrystatecity.in/pricing)**


    ## Data Access Levels

    Each plan includes a data access level that controls which fields are
    returned:


    - **Basic** — Core fields: id, name, iso2, iso3, phonecode, capital,
    currency, coordinates, region, timezones, emoji

    - **Coordinates** — Basic + extended metadata (population, tld, nationality,
    currency details, postal codes, etc.)

    - **Full** — All fields including translations (18+ languages) and
    wikiDataId


    Fields restricted to higher tiers are marked in each schema below.


    ## Feature Gating

    Some endpoints require a minimum tier. Restricted endpoints return `403`
    with an `upgradeUrl` when accessed on a lower plan. Check the [pricing
    page](https://countrystatecity.in/pricing) for current feature availability.


    ## Rate Limiting

    Requests exceeding your daily or monthly quota receive a `429` response with
    your current limit, period, tier, and an upgrade URL.


    ## Caching

    Cacheable geographic responses include `Cache-Control`, `ETag`, and
    `X-Cache` (HIT/MISS) headers; send `If-None-Match` on them to receive `304
    Not Modified`. Phone number parsing is never cached (`Cache-Control:
    no-store`, no `ETag`); see each endpoint for exceptions.


    ## Usage Headers

    All `/v1/*` responses include usage and plan headers:

    - `X-CSC-Plan` — your current tier

    - `X-CSC-Daily-Used` / `X-CSC-Daily-Limit` — today's usage vs limit

    - `X-CSC-Monthly-Used` / `X-CSC-Monthly-Limit` — this month's usage vs limit


    Use these to monitor consumption without a separate API call.
  contact:
    name: Darshan Gada (dr5hn)
    email: gadadarshan@gmail.com
    url: https://countrystatecity.in
  license:
    name: Creative Commons Attribution 4.0
    url: https://creativecommons.org/licenses/by/4.0/
  version: 2.5.0
servers:
  - url: https://api.countrystatecity.in/v1
    description: Production API
security: []
tags:
  - name: Countries
    description: Country data — 250+ countries with metadata, coordinates, and translations
  - name: States
    description: State/province/region data — 5,000+ subdivisions
  - name: Cities
    description: City data — 150,000+ cities worldwide
  - name: Counties
    description: >-
      Country/state county lists, multi-state source memberships and explicitly
      linked cities. Basic lookups on all plans.
  - name: Postcodes
    description: >-
      Postcode and ZIP code lookup and search. Informational data, not address
      verification.
  - name: Regions
    description: Geographic regions and subregions — continental groupings of countries
  - name: Timezones
    description: >-
      IANA timezone lookup by country, state, or city — includes UTC offset and
      DST status
  - name: Currencies
    description: ISO 4217 currency data — list all currencies or look up by country
  - name: Phone
    description: >-
      International dial codes — list, lookup by country, and E.164 phone number
      parsing
  - name: ISO
    description: >-
      ISO 3166 code lookup and conversion — country (alpha-2/3/numeric) and
      state (ISO 3166-2)
  - name: Search
    description: Typo-tolerant fuzzy search across cities, states, and countries
  - name: Changes
    description: >-
      Data change feed — track additions, removals, and updates to place records
      over time. **Professional and Business plans only.**
  - name: Meta
    description: Information about the dataset release currently served
paths:
  /countries/{ciso}/counties:
    get:
      tags:
        - Counties
      summary: Get counties of a country
      description: >-
        All standard REST plans can read Basic county fields. Supporter+ adds
        rich fields. Lists return all matches. State memberships preserve
        multi-state counties and unknown primary state links.
      operationId: getCountryCounties
      parameters:
        - name: ciso
          in: path
          description: ISO2 country code or numeric country ID.
          required: true
          schema:
            type: string
            example: NZ
        - name: q
          in: query
          description: >-
            Case-insensitive substring match on the English name. Requires
            Starter+, 2–100 characters.
          required: false
          schema:
            type: string
            minLength: 2
            maxLength: 100
        - name: fields
          in: query
          description: >-
            Comma-separated list of fields to include in the response. `id` is
            always included. **Requires Starter+ plan.**
          required: false
          schema:
            type: string
        - name: sort
          in: query
          description: >-
            County sort: id, name, country_code, state_code, type, population,
            latitude, longitude. Starter+; fields must be available on your data
            access level.
          required: false
          schema:
            type: string
        - name: locale
          in: query
          description: >-
            BCP 47 locale code (e.g. `pt-BR`) to request a localized name. Adds
            `localized_name` (resolved via exact locale → base language → native
            name → English name fallback) and `matched_locale` (which tier
            matched) to each result; `name` is unaffected. **Supporter+ plans
            only** — silently omitted (not an error) on lower tiers. A malformed
            value is rejected with a `400` on every tier.
          required: false
          schema:
            type: string
            minLength: 2
            maxLength: 7
            pattern: ^[a-zA-Z]{2}(-[a-zA-Z]{2,4})?$
        - name: include_translations
          in: query
          description: >-
            When `true`, includes the full `translations` field (JSON string
            keyed by language code). **Supporter+ plans only** — silently
            omitted (not an error) on lower tiers. Note that an explicit
            `fields=translations` also returns the field and takes precedence
            over this flag.
          required: false
          schema:
            type: boolean
            default: false
      responses:
        '200':
          description: Get counties of a country
          headers:
            Cache-Control:
              $ref: '#/components/headers/CacheControl'
            ETag:
              $ref: '#/components/headers/ETag'
            X-Cache:
              $ref: '#/components/headers/XCache'
            X-CSC-Plan:
              $ref: '#/components/headers/XCSCPlan'
            X-CSC-Daily-Used:
              $ref: '#/components/headers/XCSCDailyUsed'
            X-CSC-Daily-Limit:
              $ref: '#/components/headers/XCSCDailyLimit'
            X-CSC-Monthly-Used:
              $ref: '#/components/headers/XCSCMonthlyUsed'
            X-CSC-Monthly-Limit:
              $ref: '#/components/headers/XCSCMonthlyLimit'
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/County'
        '400':
          description: Invalid `kind` value, or `type` used on a plan below Supporter
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StatusError'
              example:
                status: error
                message: Field "type" is not available on your current plan.
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/FeatureRestricted'
        '404':
          description: >-
            Country, state or county not found. A valid parent with no matching
            list rows returns an empty array.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StatusError'
        '429':
          $ref: '#/components/responses/RateLimited'
      security:
        - ApiKeyAuth: []
components:
  headers:
    CacheControl:
      description: Cache directive
      schema:
        type: string
        example: public, max-age=3600
    ETag:
      description: Entity tag for conditional requests (use with `If-None-Match`)
      schema:
        type: string
        example: '"a3f2b8c1d4e5f6a7b8c9d0e1f2a3b4c5"'
    XCache:
      description: Whether the response was served from cache
      schema:
        type: string
        enum:
          - HIT
          - MISS
        example: HIT
    XCSCPlan:
      description: Your current pricing tier
      schema:
        type: string
        enum:
          - community
          - starter
          - supporter
          - professional
          - business
          - legacy
          - custom
        example: supporter
    XCSCDailyUsed:
      description: Number of requests used today
      schema:
        type: integer
        example: 42
    XCSCDailyLimit:
      description: Your daily request limit (or 'unlimited' for custom plans)
      schema:
        type: string
        example: '1000'
    XCSCMonthlyUsed:
      description: Number of requests used this month
      schema:
        type: integer
        example: 850
    XCSCMonthlyLimit:
      description: Your monthly request limit (or 'unlimited' for custom plans)
      schema:
        type: string
        example: '30000'
  schemas:
    County:
      type: object
      description: >-
        Source county. Basic fields include identity, country/primary-state
        links and complete states membership. Geographic operational columns are
        never exposed.
      required:
        - id
        - name
        - country_id
        - country_code
        - states
      properties:
        id:
          type: string
          pattern: ^[0-9]+$
          example: '14024'
        name:
          type: string
          example: Taupō District
        country_id:
          type: string
          pattern: ^[0-9]+$
        country_code:
          type: string
          example: NZ
        state_id:
          type: string
          nullable: true
          pattern: ^[0-9]+$
          description: >-
            Primary source state ID; can be null, including for counties
            spanning multiple states.
        state_code:
          type: string
          nullable: true
          description: >-
            Primary state code; preserve null instead of choosing the first
            state.
        states:
          type: array
          items:
            $ref: '#/components/schemas/CountyState'
          description: >-
            Complete source state memberships, including on state-filtered
            results. Empty when no state link is known.
        type:
          type: string
          nullable: true
          description: Coordinates/full access.
        type_local:
          type: string
          nullable: true
          description: Coordinates/full access.
        native:
          type: string
          nullable: true
          description: Coordinates/full access.
        timezone:
          type: string
          nullable: true
          description: Coordinates/full access.
        level:
          type: integer
          nullable: true
          description: Coordinates/full access.
        parent_id:
          type: string
          nullable: true
          pattern: ^[0-9]+$
          description: Coordinates/full access.
        population:
          type: string
          nullable: true
          pattern: ^[0-9]+$
          description: Coordinates/full access.
        latitude:
          type: string
          nullable: true
          description: Numeric coordinate serialized as a string. Coordinates/full access.
        longitude:
          type: string
          nullable: true
          description: Numeric coordinate serialized as a string. Coordinates/full access.
        translations:
          type: string
          nullable: true
          description: >-
            Full access; localization/translation output follows the geographic
            endpoint query flags.
        wikiDataId:
          type: string
          nullable: true
          description: >-
            Full access; localization/translation output follows the geographic
            endpoint query flags.
        localized_name:
          type: string
          nullable: true
          description: >-
            Full access; localization/translation output follows the geographic
            endpoint query flags.
        matched_locale:
          type: string
          nullable: true
          description: >-
            Full access; localization/translation output follows the geographic
            endpoint query flags.
    StatusError:
      type: object
      description: Error envelope used by the postcode and meta endpoints.
      properties:
        status:
          type: string
          example: error
        message:
          type: string
        details:
          type: object
          nullable: true
          properties:
            reason:
              type: string
              description: >-
                Machine-readable reason. Check this instead of parsing
                `message`.
          additionalProperties: true
      required:
        - status
        - message
    CountyState:
      type: object
      required:
        - id
        - name
        - code
      properties:
        id:
          type: string
          pattern: ^[0-9]+$
        name:
          type: string
        code:
          type: string
          nullable: true
    Error:
      type: object
      properties:
        error:
          type: string
          description: Error message
      required:
        - error
    FeatureError:
      type: object
      properties:
        status:
          type: string
          enum:
            - error
        message:
          type: string
          example: This feature is not available on your current plan.
        details:
          type: object
          properties:
            feature:
              type: string
              description: The feature flag that was denied
              example: bulkStates
            currentTier:
              type: string
              example: community
            requiredTier:
              type: string
              nullable: true
              description: >-
                Lowest plan that unlocks the feature; null when it cannot be
                determined
              example: starter
            upgradeUrl:
              type: string
              format: uri
              example: https://countrystatecity.in/pricing
          required:
            - feature
            - currentTier
            - requiredTier
            - upgradeUrl
      required:
        - status
        - message
        - details
    RateLimitError:
      type: object
      properties:
        error:
          type: string
          example: >-
            Daily usage limit exceeded. Please try again tomorrow or contact
            support for higher limits.
        limit:
          type: integer
          description: Your plan's limit for the exceeded period
          example: 100
        period:
          type: string
          enum:
            - daily
            - monthly
          example: daily
        tier:
          type: string
          description: Your current tier
          example: community
        upgradeUrl:
          type: string
          description: URL to upgrade your plan
          example: https://countrystatecity.in/pricing
      required:
        - error
  responses:
    Unauthorized:
      description: Missing or invalid API key
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: Unauthorized. You shouldn't be here.
    FeatureRestricted:
      description: >-
        Feature not available on your current plan. Upgrade to access this
        endpoint. `details.feature` names the denied feature and
        `details.requiredTier` the lowest plan that includes it (the example is
        for `/states`).
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/FeatureError'
          example:
            status: error
            message: This feature is not available on your current plan.
            details:
              feature: bulkStates
              currentTier: community
              requiredTier: starter
              upgradeUrl: https://countrystatecity.in/pricing
    RateLimited:
      description: Daily or monthly usage limit exceeded
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/RateLimitError'
          example:
            error: >-
              Daily usage limit exceeded. Please try again tomorrow or contact
              support for higher limits.
            limit: 100
            period: daily
            tier: community
            upgradeUrl: https://countrystatecity.in/pricing
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      description: >-
        API key for authentication. Get your free key at
        [app.countrystatecity.in](https://app.countrystatecity.in).
      name: X-CSCAPI-KEY
      in: header

````

## Related topics

- [Country State City API](https://docs.countrystatecity.in/api/introduction.md)
- [GraphQL API](https://docs.countrystatecity.in/api/graphql.md)
- [Get Cities by State](https://docs.countrystatecity.in/api/endpoints/get-cities-by-state.md)
- [Get Cities by Country](https://docs.countrystatecity.in/api/endpoints/get-cities-by-country.md)
- [Use Cases](https://docs.countrystatecity.in/tools/export-tool/use-cases.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.