World Bank Countries API

The Countries API from World Bank — 2 operation(s) for countries.

OpenAPI Specification

worldbank-countries-api-openapi.yml Raw ↑
openapi: 3.0.0
info:
  version: 2.0.0
  title: World Bank Indicators Classifications Countries API
  description: 'The World Bank Indicators API provides programmatic access to nearly 16,000 time series development indicators. These indicators include data such as total population, gross domestic product, energy use, poverty rates, health metrics, education statistics, and demographic data across countries and regions. Most data series date back over 50 years. No authentication is required. Supports filtering by date range, country, region, income level, and lending type. Returns data in JSON format with pagination support.

    '
  contact:
    name: World Bank Data Help Desk
    url: https://datahelpdesk.worldbank.org
    email: data@worldbank.org
  license:
    name: Creative Commons Attribution 4.0
    url: https://creativecommons.org/licenses/by/4.0/
servers:
- url: https://api.worldbank.org/v2
  description: World Bank API v2
tags:
- name: Countries
paths:
  /country:
    get:
      summary: List countries
      description: 'Returns a list of countries with geographical and economic classification information. Supports filtering by country code, region, income level, and lending type.

        '
      operationId: listCountries
      tags:
      - Countries
      parameters:
      - name: format
        in: query
        description: Response format
        required: false
        schema:
          type: string
          enum:
          - json
          - xml
          - jsonp
          default: json
      - name: page
        in: query
        description: Page number for pagination
        required: false
        schema:
          type: integer
          default: 1
      - name: per_page
        in: query
        description: Number of records per page (max 1000)
        required: false
        schema:
          type: integer
          default: 50
          maximum: 1000
      - name: region
        in: query
        description: Filter by region code (e.g., EAS, ECS, LCN, MEA, NAC, SAS, SSF)
        required: false
        schema:
          type: string
      - name: incomeLevel
        in: query
        description: Filter by income level (e.g., HIC, UMC, LMC, LIC)
        required: false
        schema:
          type: string
      - name: lendingType
        in: query
        description: Filter by lending type (e.g., IBD, IDA, IDX, LNX)
        required: false
        schema:
          type: string
      responses:
        '200':
          description: List of countries
          content:
            application/json:
              schema:
                type: array
                items:
                  oneOf:
                  - $ref: '#/components/schemas/PaginationData'
                  - type: array
                    items:
                      $ref: '#/components/schemas/Country'
  /country/{country_code}:
    get:
      summary: Get country details
      description: Returns details for a specific country identified by its ISO 3166-1 alpha-2 or alpha-3 code.
      operationId: getCountry
      tags:
      - Countries
      parameters:
      - name: country_code
        in: path
        description: ISO 3166-1 country code (2 or 3 characters, e.g., US, USA, CN, CHN)
        required: true
        schema:
          type: string
      - name: format
        in: query
        description: Response format
        required: false
        schema:
          type: string
          enum:
          - json
          - xml
          default: json
      responses:
        '200':
          description: Country details
          content:
            application/json:
              schema:
                type: array
                items:
                  oneOf:
                  - $ref: '#/components/schemas/PaginationData'
                  - type: array
                    items:
                      $ref: '#/components/schemas/CountryDetail'
components:
  schemas:
    CountryDetail:
      allOf:
      - $ref: '#/components/schemas/Country'
    PaginationData:
      type: object
      description: Pagination metadata returned as the first element of the response array
      properties:
        page:
          type: integer
          description: Current page number
          example: 1
        pages:
          type: integer
          description: Total number of pages
          example: 10
        per_page:
          type: integer
          description: Records per page
          example: 50
        total:
          type: integer
          description: Total number of records
          example: 500
        sourceid:
          type: string
          nullable: true
          description: Source identifier
          example: '2'
        sourcename:
          type: string
          nullable: true
          description: Source name
          example: World Development Indicators
        lastupdated:
          type: string
          nullable: true
          description: Date of last data update
          example: '2024-06-28'
    Country:
      type: object
      description: World Bank country classification data
      properties:
        id:
          type: string
          description: ISO 3166-1 alpha-3 country code
          example: USA
        iso2Code:
          type: string
          description: ISO 3166-1 alpha-2 country code
          example: US
        name:
          type: string
          description: Country name
          example: United States
        region:
          $ref: '#/components/schemas/ClassificationRef'
        adminregion:
          $ref: '#/components/schemas/ClassificationRef'
        incomeLevel:
          $ref: '#/components/schemas/ClassificationRef'
        lendingType:
          $ref: '#/components/schemas/ClassificationRef'
        capitalCity:
          type: string
          description: Capital city name
          example: Washington D.C.
        longitude:
          type: string
          description: Country centroid longitude
          example: '-95.7129'
        latitude:
          type: string
          description: Country centroid latitude
          example: '37.0902'
    ClassificationRef:
      type: object
      description: Reference to a World Bank classification category
      properties:
        id:
          type: string
          description: Classification code
          example: NAC
        iso2code:
          type: string
          description: ISO 2-character code
          example: XU
        value:
          type: string
          description: Human-readable classification name
          example: North America