api-ninjas-com Country API

The Country API provides key geographic, demographic, and economic statistics about every country in the world.

Operations 2

GET /v1/allcountries List 2-letter ISO country codes for all supported countries (premium only) #
GET /v1/country Get country data from given parameters #

Work with this as data

Every API here is available over the APIs.io API and to AI agents over MCP.

MCP server

One button, every client — Claude, Cursor, VS Code and the rest.

https://apis.io/mcp

Tools for apis

7 MCP tools reach this
  • find_apisBrowse and filter every API in the catalog.
  • get_api_artifactsOne API's artifacts, grouped by type.
  • get_openapiThe primary OpenAPI for this API.
  • find_similar_apisAPIs that look like this one.
  • apis_io_searchSTART HERE — APIs, providers and tags for one query, each with its total.
  • resolveTurn a domain, URL or GitHub org into the provider it belongs to.
  • find_cohortsEvery scored population of providers in the catalog.
All 92 tools →

Call it yourself

curl for this page
This API
curl "https://apis.io/api/v1/apis/api-ninjas-com:api-ninjas-com-country-api"
All apis
curl "https://apis.io/api/v1/apis?limit=25"

Discovery needs no key. Ratings and market analysis are Pro.

Get an API key

Free tier, no form to fill in. Signing in shares your email address with us — we store it to create your key and to recognise you if you sign in with another provider. See our Privacy Policy and Terms.

A second provider on the same verified email joins the account you already have.

OpenAPI Specification

api-ninjas-com-country-api-openapi.yml Raw ↑
openapi: 3.2.0
info:
  title: Ninjas Country API
  description: 'Combined OpenAPI specification for every API Ninjas endpoint. Requests go to https://api.api-ninjas.com with an `X-Api-Key` header; get a free key at https://api-ninjas.com/register. Human-readable docs: https://api-ninjas.com/api. Index for LLMs: https://api-ninjas.com/llms.txt.'
  version: 1.0.0
  contact:
    name: API Ninjas
    url: https://api-ninjas.com
  license:
    name: Proprietary
servers:
- url: https://api.api-ninjas.com
  description: API Ninjas Production
security:
- ApiKeyAuth: []
tags:
- name: Country
  description: The Country API provides key geographic, demographic, and economic statistics about every country in the world.
paths:
  /v1/allcountries:
    get:
      tags:
      - Country
      summary: List 2-letter ISO country codes for all supported countries (premium only)
      description: Returns the 2-letter ISO codes of every supported country. For statistics about a specific country use /country. Requires a premium subscription.
      operationId: getAllCountries
      responses:
        '200':
          description: 'Successful response: an array of 2-letter ISO-3166 alpha-2 country codes.'
          content:
            application/json:
              schema:
                type: array
                items:
                  type: string
                  example: US
        '401':
          description: Unauthorized
        '500':
          description: Internal Server Error
      security:
      - ApiKeyAuth: []
  /v1/country:
    get:
      summary: Get country data from given parameters
      description: Returns geographic, demographic, and economic statistics for countries matching filters such as name, currency, GDP, population, area, or unemployment rate.
      operationId: getCountryData
      parameters:
      - name: name
        in: query
        description: Plain English name, 2-letter ISO-3166 alpha-2, or 3-letter ISO-3166 alpha-3 code of country.
        required: false
        schema:
          type: string
      - name: currency
        in: query
        description: 3-letter currency code of country (e.g. USD).
        required: false
        schema:
          type: string
      - name: min_gdp
        in: query
        description: Minimum gross domestic product (GDP) of country, in US Dollars.
        required: false
        schema:
          type: string
      - name: max_gdp
        in: query
        description: Maximum gross domestic product (GDP) of country, in US Dollars.
        required: false
        schema:
          type: string
      - name: min_population
        in: query
        description: Minimum population of country (in thousands).
        required: false
        schema:
          type: string
      - name: max_population
        in: query
        description: Maximum population of country (in thousands).
        required: false
        schema:
          type: string
      - name: min_area
        in: query
        description: Minimum surface area of country in km2.
        required: false
        schema:
          type: string
      - name: max_area
        in: query
        description: Maximum surface area of country in km2.
        required: false
        schema:
          type: string
      - name: min_unemployment
        in: query
        description: Minimum unemployment rate in %.
        required: false
        schema:
          type: string
      - name: max_unemployment
        in: query
        description: Maximum unemployment rate in %.
        required: false
        schema:
          type: string
      - name: min_gdp_growth
        in: query
        description: Minimum GDP growth rate in %.
        required: false
        schema:
          type: string
      - name: max_gdp_growth
        in: query
        description: Maximum GDP growth rate in %.
        required: false
        schema:
          type: string
      - name: min_infant_mortality
        in: query
        description: Minimum infant mortality rate per 1,000 live births.
        required: false
        schema:
          type: string
      - name: max_infant_mortality
        in: query
        description: Maximum infant mortality rate per 1,000 live births.
        required: false
        schema:
          type: string
      - name: min_fertility
        in: query
        description: Minimum fertility rate (average number of children per woman).
        required: false
        schema:
          type: string
      - name: max_fertility
        in: query
        description: Maximum fertility rate (average number of children per woman).
        required: false
        schema:
          type: string
      - name: min_urban_pop_rate
        in: query
        description: Minimum urban population rate in %.
        required: false
        schema:
          type: string
      - name: max_urban_pop_rate
        in: query
        description: Maximum urban population rate in %.
        required: false
        schema:
          type: string
      - name: limit
        in: query
        description: How many results to return. Must be between 1 and 30. Default is 5.
        required: false
        schema:
          type: integer
          default: 5
          minimum: 1
          maximum: 30
      responses:
        '200':
          description: A list of country statistics.
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/CountryResponse'
        '400':
          description: Bad Request
        '401':
          description: Unauthorized
        '500':
          description: Internal Server Error
      security:
      - ApiKeyAuth: []
      tags:
      - Country
components:
  schemas:
    CountryResponse:
      type: object
      properties:
        gdp:
          type: number
        sex_ratio:
          type: number
        surface_area:
          type: number
        life_expectancy_male:
          type: number
        unemployment:
          type: number
        imports:
          type: number
        homicide_rate:
          type: number
        currency:
          type: object
          properties:
            code:
              type: string
            name:
              type: string
        iso2:
          type: string
        gdp_growth:
          type: number
        employment_services:
          type: number
        urban_population_growth:
          type: number
        secondary_school_enrollment_female:
          type: number
        employment_agriculture:
          type: number
        capital:
          type: string
        co2_emissions:
          type: number
        forested_area:
          type: number
        tourists:
          type: number
        exports:
          type: number
        life_expectancy_female:
          type: number
        post_secondary_enrollment_female:
          type: number
        post_secondary_enrollment_male:
          type: number
        primary_school_enrollment_female:
          type: number
        infant_mortality:
          type: number
        secondary_school_enrollment_male:
          type: number
        threatened_species:
          type: number
        population:
          type: number
        urban_population:
          type: number
        employment_industry:
          type: number
        name:
          type: string
        pop_growth:
          type: number
        region:
          type: string
        pop_density:
          type: number
        internet_users:
          type: number
        gdp_per_capita:
          type: number
        fertility:
          type: number
        refugees:
          type: number
        primary_school_enrollment_male:
          type: number
        telephone_country_codes:
          type: array
          items:
            type: string
        flag_url:
          type: string
          format: uri
          description: URL to the country's flag image (4:3 rectangle, SVG).
        flag_square_url:
          type: string
          format: uri
          description: URL to the country's flag image (1:1 square, SVG).
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-Api-Key
externalDocs:
  description: API Ninjas documentation
  url: https://api-ninjas.com/api