Actions5
Get States by Country
AI-generatedOverview
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
- Retrieve all states in the United States by providing the country code 'US'.
- 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
jsondata- 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
- country-state-city npm package - The underlying library used to fetch country, state, and city data.