Countries
Overview
By default, our API endpoints return the complete data object for a country, ensuring you have immediate access to every available field. However, for production applications, we strongly recommend fetching only the specific fields you need.
While convenient, retrieving the full object when you only require specific data points (e.g., just currencySymbol and tld) creates unnecessary overhead.
Why granular requests matter:
- Network Latency: Smaller payloads travel faster, especially on mobile networks.
- Bandwidth Usage: Reducing the response body size lowers data consumption for both your server and your user.
- Serialization Costs: Massive JSON objects take longer for the API to generate and longer for your client to parse.
GET /v1/geo/countries/all
Request
Query Parameters: The fields parameter is optional. It accepts a comma-separated list of valid property names to include in the response object.
curl -X GET "https://api.geoapi.net/v1/geo/countries/all?fields=iso2,population,currencyCode,isEu" \
-H "X-API-HOST: your_api_host" \
-H "X-API-KEY: your_api_key"
Response
200 OKThe API returns a lightweight array containing only the requested data points:
[
{
"iso2": "AF",
"population": 40218234,
"currencyCode": "AFN",
"isEu": false
},
{
"iso2": "AL",
"population": 2837743,
"currencyCode": "ALL",
"isEu": false
}
...
]
fields parameter is omitted, the API defaults to returning all available details for every country. This results in a massive payload size and is not recommended for production environments unless you specifically require the full dataset.GET /v1/geo/countries/{countryCode}
Request
Path Parameters: The countryCode is a mandatory parameter. It accepts either the ISO 3166-1 alpha-2 (2-letter) or alpha-3 (3-letter) code to identify the resource.
Query Parameters: The fields parameter is optional. It accepts a comma-separated list of valid property names to include in the response object.
curl -X GET "https://api.geoapi.net/v1/geo/countries/AL?fields=countryName,population,currencyCode,isEu" \
-H "X-API-HOST: your_api_host" \
-H "X-API-KEY: your_api_key"
Response
200 OKThe API will return a single JSON object containing strictly the keys requested in your query.
{
"countryName": "Albania",
"population": 2837743,
"currencyCode": "ALL",
"isEu": false
}
Error occurs if you pass non existing country countryCode, or not 2-3 letters long.
{
"status": 404,
"message": "Not Found"
}
fields parameter will return every available data point for that country (including complex objects like geo-coordinates, full translation lists, and regex patterns).
We strongly recommend requesting only the specific properties you need to ensure the fastest possible response time.Query Parameters
| Property | Type | Description | Example (Switzerland) |
|---|---|---|---|
| iso2 | String | ISO 3166-1 alpha-2 code. | "CH" |
| iso3 | String | ISO 3166-1 alpha-3 code. | "CHE" |
| isoNumeric | String | ISO 3166-1 numeric code. | "756" |
| name | String | Common country name in English. | "Switzerland" |
| nativeName | String | Common country name in the local language. | "Schweiz" |
| officialName | String | Official country name in English. | "Swiss Confederation" |
| officialNativeName | String | Official country name in the local language. | "Schweizerische Eidgenossenschaft" |
| capital | String | Primary capital city. | "Bern" |
| currencyCode | String | ISO 4217 currency code. | "CHF" |
| currencyName | String | Full name of the local currency. | "Swiss Franc" |
| currencySymbol | String | Symbol used for pricing. | "CHF" |
| postalCodeFormat | String | The format string (# for digits). | "####" |
| postalCodeRegex | String | Regex string for validation. | "^\d{4}$" |
| callingCodes | String[] | International calling prefixes. | ["+41"] |
| tld | String | Top-level domain. | ".ch" |
| roadSpeedUnit | String | Unit used for speed limits. | "km/h" |
| roadHeightUnit | String | Unit used for height clearances. | "m" |
| roadDistanceUnit | String | Unit used for road distances. | "km" |
| drivingSide | String | Side of the road used for driving. | "right" |
| isEu | Boolean | Part of the European Union? | false |
| isUn | Boolean | Member of the United Nations? | true |
| flagEmoji | String | Unicode flag emoji. | "🇨🇭" |
| flagVector | String | URL path to SVG flag image. | "https://flagcdn.com/ch.svg" |
| continent | String | 2-letter continent code. | "EU" |
| region | String | Geographic region. | "Europe" |
| subregion | String | Geographic subregion. | "Western Europe" |
| areaSqKm | Number | Total area in square kilometers. | 41285 |
| areaSqMi | Number | Total area in square miles. | 15940 |
| population | Number | Estimated total population. | 8715494 |
| latitude | Number | Latitude coordinate. | 46.818 |
| longitude | Number | Longitude coordinate. | 8.227 |
| bbox | Number | Bounding box. | [8.227, 8.227, 8.227, 8.227] |
| languages | String[] | Official language codes. | ["de", "fr", "it", "rm"] |
| alternateNames | Object[] | Name translated into official languages. | [{ "localeCode": "de", "localeName": "German", "name": "Schweiz" }, { "localeCode": "fr", "localeName": "French", "name": "Suisse" }, { "localeCode": "it", "localeName": "Italian", "name": "Svizzera" }, { "localeCode": "rm", "localeName": "Romansh", "name": "Svizra" }] |
| neighbouringCountries | String[] | ISO2 codes of land Neighbours. | ["AT", "DE", "FR", "IT", "LI"] |
Intro
Geo Data is the invisible infrastructure of the modern web. From auto filling forms to formatting prices correctly, understanding the context of your user's location is crucial for a polished User Experience (UX). However, maintaining this database yourself is a nightmare of changing standards and edge cases. We provide APIs to obtain data that belongs to each country, ensuring your application speaks the local language literally and figuratively.
Divisions