Skip to main content
A caching proxy endpoint that retrieves country information from the RestCountries API. This endpoint exists to provide consistent caching behavior for country lookups.

Endpoint

Query parameters

code
string
required
The ISO 3166-1 alpha-2 or alpha-3 country code (e.g., “PL” or “POL”).

Response

Returns the raw response from RestCountries API v3.1. The response is an array containing country data.
[0]
object
required
Country data object from RestCountries API

Caching

This endpoint uses Next.js’s force-cache strategy:
From app/api/country/route.ts:11-13 Country data is cached indefinitely to reduce external API calls and improve performance.

Example request

Example response

The response includes many additional fields beyond what’s shown above. Refer to the RestCountries API documentation for the complete schema.

Error responses

Missing country code:
Status: 400 Failed to fetch from RestCountries:
Status: 500

Code example

Use cases

This endpoint is primarily used by:
  • Country search/autocomplete components
  • Guess validation in the game interface
  • Displaying country details after user selection