Country information

Here is the URL for this API: https://api.worldbank.org/v2/countries?format=json.

With this request, we can get the following:

  • Countries
  • Regions
  • Capitals and their coordinates (latitude and longitude)
  • Income levels

Here's an example response:

[ 
   { 
      "page":1, 
      "pages":7, 
      "per_page":"50", 
      "total":304 
   },
   [ 
      { 
         "id":"AFG", 
         "iso2Code":"AF", 
         "name":"Afghanistan", 
         "region":{ 
            "id":"SAS", 
            "iso2code":"8S", 
            "value":"South Asia" 
         },
         "incomeLevel":{ 
            "id":"LIC", 
            "iso2code":"XM", 
            "value":"Low income" 
         }, 
         "capitalCity":"Kabul", 
         "longitude":"69.1761", 
         "latitude":"34.5228"
... } ... ] ]

Notice that the response contains an array with two objects. The first one contains metadata about the response such as the current page, the total number of pages, and much more. The second one contains the actual data.

It is also possible to retrieve information about a specific country directly by adding the country's ID to the URL: https://api.worldbank.org/v2/countries/be?format=json. In this case, we'll retrieve information about Belgium (that is, id: BE).

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.86.138