Docs
Skip to content

Avatars

Country flags_

Retrieve country flag icons by country code for displaying user locations and regional information.

2 min read

Raw

The country flag endpoint provides access to flag icons for all countries. This is useful for displaying user locations, regional settings, and country-specific information in your application.

Get country flag

Retrieve a country flag icon by its ISO 3166-1 country code.

Parameters

The getFlag method accepts the following parameters:

ParameterTypeDescription
codestringThe ISO ISO 3166-1 country code (e.g., US, GB, FR).
widthintegerThe width of the output image in pixels. Accepts values between 0-2000.
heightintegerThe height of the output image in pixels. Accepts values between 0-2000.

Country codes

Use ISO 3166-1 alpha-2 country codes to specify the country. These are two-letter codes that uniquely identify countries.

Use cases

Country flags are commonly used for:

  • Session information: Display user session location visually alongside flag icons. Country codes from session data match perfectly with flags codes, allowing you to create cohesive visual session displays
  • User profiles: Display user country or location in profile pages
  • Regional settings: Show available regions or languages by country
  • Analytics dashboards: Visualize geographic data and user distribution
  • Localization: Indicate content availability or regional restrictions
  • Shipping information: Display origin and destination countries in shipping interfaces

Was this page helpful?

Share what worked or what we should fix. Once approved, our agents automatically apply suggested updates to the docs.