Country State City

Get information about countries, states, and cities

Get States by Country

AI-generated

Overview

This node provides information about countries, states, and cities based on ISO codes. Specifically, the 'Get States by Country' operation retrieves all states or provinces within a specified country using its ISO 3166-1 alpha-2 country code. This is useful for applications needing geographic subdivisions of countries, such as location-based services, address validation, or regional data analysis.

Use Case Examples

  1. Retrieve all states in the United States by providing the country code 'US'.
  2. Get provinces of Brazil by using the country code 'BR'.

Properties

Name Meaning
Country Code ISO 3166-1 alpha-2 country code (2 letters) used to specify the country for which states are to be retrieved.

Output

JSON

  • json
    • data - Array of state or province objects for the specified country, each containing details about a state.

Dependencies

  • Uses the 'country-state-city' npm package to fetch country, state, and city data.
  • Uses an internal ISO3 to ISO2 country code mapping for some operations.

Troubleshooting

  • Ensure the country code is a valid ISO 3166-1 alpha-2 code; invalid codes will result in no data or errors.
  • If no states are returned, verify that the country code corresponds to a country with defined states or provinces in the data source.

Links

Discussion