Documentation Version 1

Get Started

This documentation is on Version 1 of the call structure of the API. 

Be sure to read the legal information below. To get started, you must first receive a valid API key by registering for access.  Please use the links on the right-hand side of your screen to browse through the API calls, and read through basic request and response formats below.

Tutorial on Using World Bank API

Try a simple tutorial on how to access and query the World Bank API using PHP.

Query Generator

Try our graphical Query Generator.

Request Format

To use the World Bank API, contact http://open.worldbank.org/rest.php.

Requests require the following parameters:

method
  Used to specify which method in the API you wish to call
api_key
  Your API key, given to you when you register for access

For example, to make a request to the wb.test.echo function:

http://open.worldbank.org/rest.php?method=wb.test.echo&param=someValue&api_key=xxxxxxxxxxx

Response Format

By default, all requests will respond with valid XML.  To receive the response in JSON format, you may provide format=json in any request.  Additionally, you may provide the callback parameter to wrap your JSON response in a function call (used with the eval function in JavaScript).  For example, to call a "myFunc" function in JavaScript, you would send format=json&callback=myFunc as parameters in your request.  The callback parameter will be ignored if the response format is not JSON.

Sample API Response

A valid request returns this:

  1. <rsp stat="ok">  
  2.     [xml-payload]  
  3. </rsp>  

An invalid request returns this:

  1. <rsp stat="fail">      
  2.         <err code="[error-code]" msg="[error-message]">    
  3. </err></rsp>   
    
          
 

 

 

Country Calls

The API provides four country based calls that provide lists of countries, regions, country income levels, and the type of World Bank lending for which each country is eligible.

For more information on how the World Bank classifies countries and determines income level and lending eligilibity, see Country Classification.

Data Calls

The World Bank API provides three data calls. 

These data calls tap into the following sources of World Bank Data:

  • The Little Data Book - based on the World Development Indicators, the World Bank's primary database for cross-country comparable development data, the Little Data Book includes 54 basic indicators going back 60 years.
    See: Little Data Book site | Glossary of Indicators
  • World Governance Indicators - includes aggregate and individual governance indicators for 212 countries and territories over the period 1996–2007, for six dimensions of governance
    See: Governance Indicators site | Glossary of Indicators
  • Doing Business - includes objective measures of business regulations and their enforcement across 178 countries and selected cities at the subnational and regional level.
    See: Doing Business site | Data Notes & Methodology

Photo Calls

The API provides three photo calls that tap into the Bank's Photo Library and allow photos to be retrieved based on country, keyword and more:

The Photo Library provides more than 12,000 images that illustrate development through topics such as Agriculture, Education, Environment, Health, Trade and more.  For more information, visit the World Bank Photo Library.

 

Cross Topic Calls

The API provides one topic-based call.

The call can be used with the wb.photos.get and wb.indicators.get calls to query photos and indicators based on topic.

 

Test Calls

The API provides one test call that simply echoes a parameter back to the user: