/api/v1.
Endpoints Overview
GET /
Returns a simple welcome message, translated based on the Accept-Language header.
- Description: Provides a localized welcome message to the API.
- Query Parameters: None.
-
Headers:
Accept-Language(Optional): Specifies preferred language(s) for the welcome message (e.g.,es-ES,fr,en-US;q=0.9). Defaults to English (‘en’).
-
Success Response (200):
(Message content varies by language)
-
Errors:
- 500: Internal Server Error (if translation fails unexpectedly).
-
Curl Example:
GET /all
Retrieves a list of all countries. Supports filtering, sorting, and flattening.
- Description: Returns an array containing all country objects from the dataset.
-
Query Parameters:
- Headers: None specific.
-
Success Response (200):
-
Default: Array of full country objects.
-
With
?fields=name.common,population: -
With
?fields=name.common&flatten=true:
-
Default: Array of full country objects.
-
Errors:
- 400: Invalid query parameter format (handled by
zValidator). - 500: Internal Server Error.
- 400: Invalid query parameter format (handled by
-
Curl Example:
GET /name/:name
Retrieves one or more countries matching the provided name (common, official, native, translation). Search is case-insensitive and ignores accents/diacritics.
-
Description: Finds countries by matching the
:nameparameter against various name fields. Can return multiple countries if the name is ambiguous (e.g., “kongo”). -
Path Parameters:
-
Query Parameters: Same as
GET /all(fields,sort,flatten). -
Headers:
Accept-Language(Optional): For localized “Not Found” error message.
-
Success Response (200): Array containing the found country/countries matching the structure defined by
fields/flatten. -
Errors:
-
400: Invalid query parameters or missing/empty
:nameparameter. -
404: Country not found (localized message).
- 500: Internal Server Error.
-
400: Invalid query parameters or missing/empty
-
Curl Example:
GET /regions
Retrieves a list of all available regions present in the dataset, along with country counts and subregions.
- Description: Returns a summary list of distinct regions.
- Query Parameters: None supported on this specific endpoint by default (schema not applied).
- Headers: None specific.
-
Success Response (200):
-
Errors:
- 500: Internal Server Error.
-
Curl Example:
GET /region/:name
Retrieves all countries belonging to the specified region. Search is case-insensitive and ignores accents/diacritics.
-
Description: Finds countries by matching the
:nameparameter against the normalized region name. -
Path Parameters:
-
Query Parameters: Same as
GET /all(fields,sort,flatten). -
Headers:
Accept-Language(Optional): For localized “Not Found” error message.
-
Success Response (200): Array containing the countries in the specified region, matching the structure defined by
fields/flatten. -
Errors:
-
400: Invalid query parameters or missing/empty
:nameparameter. -
404: Region not found (localized message).
- 500: Internal Server Error.
-
400: Invalid query parameters or missing/empty
-
Curl Example: