Country Flag API
The Country Flag API provides SVG flag images for any country, territory, or area of special interest (over 250 supported). The small file sizes are perfect for displaying flag icons on your website or populating a dropdown menu.
For a list of all countries, see the /v1/allcountryflags endpoint.
For geographic, demographic and economic statistics on countries, check out the Country API instead.
/v1/countryflag GET
https://api.api-ninjas.com/v1/countryflag
Get a country's flag as an SVG image in base64 format. Both 1:1 and 4:3 aspect ratios are supported and returned in the response.
Parameters
- countryrequired- 2-letter ISO-3166 alpha-2 country code (e.g. - US,- CA,- FR). For countries in the United Kingdom, use- GBfor Great Britain,- GB-ENGfor England,- GB-SCTfor Scotland,- GB-WLSfor Wales,- GB-NIRfor Northern Ireland.
Headers
- X-Api-Keyrequired- API Key associated with your account. 
Sample Request Live Demo!
https://api.api-ninjas.com/v1/countryflag?country=USHeaders
X-Api-KeyLog in or sign up to get your API KeySample Response
1
2
3
4
5
{
  "country": "US",
  "square_image_url": "https://api-ninjas-data.s3.us-west-2.amazonaws.com/flags/1x1/KoHP0ZTO/us.svg",
  "rectangle_image_url": "https://api-ninjas-data.s3.us-west-2.amazonaws.com/flags/4x3/8L07WqeX/us.svg"
}Code Examples
1
2
curl -X GET "https://api.api-ninjas.com/v1/countryflag?country=United%20States" \
  -H "X-Api-Key: YOUR_API_KEY"If your programming language is not listed in the Code Example above, you can still make API calls by using a HTTP request library written in your programming language and following the above documentation.
/v1/allcountryflags GETPremium Only
https://api.api-ninjas.com/v1/allcountryflags
Get flag images for all countries. Returns an list of countries and their flag URLs.
Headers
- X-Api-Keyrequired- API Key associated with your account. 
Sample Request
https://api.api-ninjas.com/v1/allcountryflagsSample Response
1
2
3
4
5
6
7
8
9
10
11
12
13
[
  {
    "country": "AD",
    "square_image_url": "https://api-ninjas-data.s3.us-west-2.amazonaws.com/flags/1x1/irDOqrgs/ad.svg",
    "rectangle_image_url": "https://api-ninjas-data.s3.us-west-2.amazonaws.com/flags/4x3/kSezcqOa/ad.svg"
  },
  {
    "country": "AE",
    "square_image_url": "https://api-ninjas-data.s3.us-west-2.amazonaws.com/flags/1x1/5RmaAls3/ae.svg",
    "rectangle_image_url": "https://api-ninjas-data.s3.us-west-2.amazonaws.com/flags/4x3/g2IOl3w9/ae.svg"
  },
  ...
]