World Bank API

Beginner's Pick Science & Math / No Auth Required Beginner HTTPS
Free to Use
85 A
Measured Score 0 50 100 Speed 25/30 Consistency 17/20 Security 20/20 Browser access 15/15 Transparency 8/15 TESTED 2026-08-10

Overview

The World Bank API provides access to thousands of development indicators covering economics, education, health, and infrastructure for over 200 countries spanning decades. It is completely free with no authentication required, making it one of the best APIs for data science, economics research, and visualization projects. You can query individual indicators for specific countries or retrieve bulk data for cross-country comparisons.

Beginner Tip

Start by querying a single well-known indicator like NY.GDP.MKTP.CD for GDP in current USD for a specific country code — the response is straightforward and gives you a feel for the data structure. Use format=json in your URL to avoid getting XML by default.

Measurement Record

What actually happened when we called this API from our own infrastructure. Every value below was recorded by the request, not copied from the provider's documentation.

Request
GET https://api.worldbank.org/v2/country/US/indicator/NY.GDP.MKTP.CD?format=json&per_page=5
Result
HTTP 200 · application/json · 1,146 bytes · compressed
Response time
43 ms (median of 3) · fastest 38 ms
Transport
TLSv1.3 · TLS_AES_256_GCM_SHA384 · certificate issued by Google Trust Services
Browser CORS
Allowed — Access-Control-Allow-Origin: *
Served by
cloudflare
Recorded
2026-08-10

Fields Returned

Top-level fields present in the response we captured, with the type and value we actually received.

Field Type Value received
page integer 1
pages integer 14
per_page integer 5
total integer 66
sourceid string 2
lastupdated string (date) 2026-07-13

Captured Response

Captured from a real request to https://api.worldbank.org/v2/country/US/indicator/NY.GDP.MKTP.CD?format=json&per_page=5 on 2026-08-10. Long arrays and nested objects are truncated to keep the shape readable.

JSON Response · Captured
[
  {
    "page": 1,
    "pages": 14,
    "per_page": 5,
    "total": 66,
    "sourceid": "2",
    "lastupdated": "2026-07-13"
  }
]

Implementation Example

Calls a real endpoint of this API. Replace any placeholder credentials with your own key.

Request
const url = "https://api.worldbank.org/v2/country/US/indicator/NY.GDP.MKTP.CD?format=json&per_page=5";
const response = await fetch(url);
if (!response.ok) throw new Error(`Request failed: ${response.status}`);
const data = await response.json();
console.log(data);

What Can You Build?

Note: These code examples are AI-generated and unverified. Always refer to the official API documentation for accurate usage.

How This API Fails

We deliberately sent this API a broken request and recorded exactly what came back on 2026-08-10. Knowing the shape of an error before you hit it makes error handling much easier to write.

HTTP 404 Requesting a path that does not exist text/html

Returned an HTML error page rather than JSON — worth knowing if your client assumes every response can be parsed as JSON.

Common Errors & Troubleshooting

Generated guidance based on this API's documentation, not observed by us. Treat it as a starting point and check against the provider's own error reference.

XML response instead of JSON The format=json parameter was omitted from the URL.
Always append format=json to your request URL; the World Bank API returns XML by default.
Empty data array with valid response Data for the requested indicator or country may not be available for the specified year range.
Omit date filters first to see what years are available, then narrow your range. Some indicators only cover specific decades.
Indicator code not found World Bank indicator codes are case-sensitive and must match exactly.
Look up the exact indicator code at data.worldbank.org/indicator — codes like NY.GDP.MKTP.CD must be typed precisely including dots and uppercase.

Measured Score Breakdown

Live HTTP request to the API endpoint

Speed 25/30
Consistency 17/20
Security 20/20
Browser access 15/15
Transparency 8/15
Endpoint Response Time 43ms

Fully tested on Aug 10, 2026

Technical Specifications

Auth No Auth
HTTPS REQUIRED
CORS NO
Category Science & Math
Difficulty Beginner
Endpoint last called: 2026-08-10

Related Tags

Similar APIs

View All →