Country State City

Get information about countries, states, and cities

Get State by Code

AI-generated

Overview

This node retrieves detailed geographical information related to countries, states, and cities based on specified codes. It supports operations such as getting country details by ISO2 or ISO3 codes, fetching all states of a country, obtaining detailed information about a specific state by country and state code, and listing all cities within a state. This node is useful for applications requiring standardized location data, such as address validation, regional analysis, or location-based services.

Use Case Examples

  1. Get detailed information about the United States using its ISO2 code 'US'.
  2. Retrieve all states within Brazil using the country code 'BR'.
  3. Fetch detailed information about the state of California in the US using country code 'US' and state code 'CA'.
  4. List all cities in the state of New York, US, using country code 'US' and state code 'NY'.

Properties

Name Meaning
Country Code ISO 3166-1 alpha-2 country code (2 letters) used to specify the country for operations like getting country details, states, or cities.
State Code State or province ISO code used to specify the state for operations like getting state details or cities within a state.

Output

JSON

  • json
    • data - Contains the retrieved data which can be a single object or an array of objects representing countries, states, or cities depending on the operation.

Dependencies

  • country-state-city library for geographical data

Troubleshooting

  • Invalid ISO3 country code error occurs if the provided ISO3 code does not map to a valid ISO2 code. Ensure the ISO3 code is correct and supported.
  • Empty or null results may occur if the specified country or state codes do not exist in the data source. Verify the codes before use.

Links

Discussion