# World Bank Indicators Scraper — GDP, Population & More (`devilscrapes/world-bank-indicators-scraper`) Actor

Fetch World Bank Open Data indicators (GDP, population, CO2, poverty and 20,000+ others) across any countries and years, flattened into one clean row per country, indicator and year.

- **URL**: https://apify.com/devilscrapes/world-bank-indicators-scraper.md
- **Developed by:** [DevilScrapes](https://apify.com/devilscrapes) (community)
- **Categories:** Developer tools, Business
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per event

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/platform/actors/running/actors-in-store#pay-per-event

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

<div align="center">
  <img src=".actor/icon.svg" width="160" alt="Devil Scrapes mark" />

## World Bank Indicators Scraper — GDP, Population & More

**💰 $2.05 / 1 000 results**  ·  pay only for results  ·  no credit card to try

*We do the dirty work so your dataset stays clean.* 😈

Fetch World Bank Open Data indicators — GDP, population, CO2, poverty and 20,000+ others — across any countries and years, flattened into one clean row per country, indicator and year.

</div>

***

### 🎯 What this scrapes

The World Bank's Open Data API is free and keyless, but its wire format is
built for the World Bank's own tooling, not for a spreadsheet. A successful
response is a two-element array — pagination metadata bolted onto a row
list, not a normal JSON object — and an invalid indicator code answers with
HTTP 200 and a silent error block instead of a 404. This Actor fetches any
mix of indicator codes across any countries and any date range, and hands
back one flat row per country/indicator/year — ready for a pivot table, not
a parser rewrite.

### 🔥 What we handle for you

- We parse the API's two-shape response envelope so a paging bug or a bad indicator code never corrupts your dataset.
- We skip an invalid indicator code or an empty country series with a clear warning — one bad code never kills the rest of your run.
- We retry `429`/`5xx` responses with exponential backoff and honour `Retry-After`.
- We keep every null observation — most (country, year) pairs genuinely have no reported value, and we ship that as a real `null`, not a dropped row.

### 💡 Use cases

- Build a "GDP + population + CO2 for 200 countries × 25 years" master table for a macro research note.
- Pull a development-finance dashboard's underlying indicators without hand-copying from the World Bank's website.
- Feed an ESG or country-risk model with the World Bank's own reported figures, refreshed on a schedule.
- Fact-check a journalism piece against the official series instead of a secondary aggregator.

### ⚙️ How to use it

1. Click **Try for free** at the top of the page.
2. List the indicator codes you need (e.g. `NY.GDP.MKTP.CD` for GDP) — codes are on `data.worldbank.org/indicator`.
3. Set country codes (`all` or a `;`-separated ISO list) and an optional date range.
4. Click **Start**. Output streams into the run's dataset as it's fetched.
5. Export from **Storage → Dataset** as JSON, CSV, or Excel — or fetch via the API.

### 📥 Input

| Field | Type | Required | Default | Notes |
|---|---|:--:|---|---|
| `indicatorCodes` | `array` | no | `["NY.GDP.MKTP.CD"]` | World Bank indicator codes to fetch, one paginated series per code. |
| `countryCodes` | `string` | no | `"all"` | `all` or a `;`-separated ISO list, e.g. `US;CN;DE`. |
| `dateRange` | `string` | no | *(none)* | Optional `YYYY` or `YYYY:YYYY` range, e.g. `2000:2024`. |
| `includeSourceNote` | `boolean` | no | `false` | Attach each indicator's methodology note and source organization to every row. |
| `maxResults` | `integer` | no | `5000` | Stop after this many rows. Each row is one billed result event. |
| `proxyConfiguration` | `object` | no | `{"useApifyProxy": false}` | World Bank's API is public and keyless; proxy is opt-in. |

#### Example input

```json
{
  "indicatorCodes": ["NY.GDP.MKTP.CD", "SP.POP.TOTL"],
  "countryCodes": "US;CN;DE",
  "dateRange": "2015:2024",
  "includeSourceNote": false,
  "maxResults": 200,
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}
```

### 📤 Output

Every row is one dataset item — one (country, indicator, year) observation.

| Field | Type | Notes |
|---|---|---|
| `country_id` | `string` | Country ISO3 code, falling back to the API's alpha-2 id. |
| `country_iso3` | `string` | ISO alpha-3 country code. |
| `country_name` | `string` | Country display name. |
| `region` | `string` | World Bank region — not enriched in v1, always `null` today. |
| `income_level` | `string` | World Bank income level — not enriched in v1, always `null` today. |
| `indicator_id` | `string` | World Bank indicator code. |
| `indicator_name` | `string` | Indicator display name. |
| `year` | `integer` | Observation year. |
| `value` | `number` | Observed value — `null` for most rows; that's the API's own data, not a bug. |
| `unit` | `string` | Unit of measure, when the API provides one. |
| `obs_status` | `string` | Observation status flag, when present. |
| `decimal` | `integer` | Decimal precision of `value`. |
| `scale` | `string` | Value scale, when the API provides one. |
| `source_note` | `string` | Indicator methodology note (only when `includeSourceNote` is on). |
| `source_organization` | `string` | Source organization (only when `includeSourceNote` is on). |

#### Example output

```json
{
  "country_id": "USA",
  "country_iso3": "USA",
  "country_name": "United States",
  "region": null,
  "income_level": null,
  "indicator_id": "NY.GDP.MKTP.CD",
  "indicator_name": "GDP (current US$)",
  "year": 2022,
  "value": 25462700000000.0,
  "unit": "",
  "obs_status": "",
  "decimal": 0,
  "scale": null,
  "source_note": null,
  "source_organization": null
}
```

### 💰 Pricing

Pay-Per-Event — you pay only when these events fire:

| Event | USD | What it is |
|---|---:|---|
| `actor-start` | $0.05 | One-off warm-up charge per run |
| `result` | $0.002 | Per dataset item |

Example: 1 000 results at the rates above ≈ **$2.05**. No subscription, no minimum, no card to start — Apify gives every new account $5 of free credit.

### 🚧 Limitations

- `region` and `income_level` are not enriched from the country-metadata endpoint in this version — both ship as `null`. A future version will cross-reference `/v2/country` to fill them in.
- This is a current snapshot, not a historical-revision tracker — the World Bank periodically restates past years, and we fetch whatever the API reports at run time.
- We pass through the API's raw `value` and `unit` as-is — no currency conversion or unit normalization.

### ❓ FAQ

**Do I need an API key?**

No. The World Bank's Open Data API is free and keyless. We still send a
polite, identifiable User-Agent so runs stay good API citizens.

**Why is `value` null for so many rows?**

Most countries don't report every indicator for every year — that's a real
gap in the underlying data, not something we dropped. We ship the null so
your analysis sees the true coverage.

**What happens if I typo an indicator code?**

The API answers a typo'd code with HTTP 200 and a hidden error block — we
detect that, skip the code with a warning, and keep fetching every other
code you asked for.

### 💬 Your feedback

Spotted a bug, hit a weird edge case, or need a new field? Open an
issue on the Actor's **Issues** tab on Apify Console — we ship
fixes weekly and we read every report.

***

<div align="center">

Built by **[Devil Scrapes](https://apify.com/DevilScrapes)** 😈 — a small fleet of
opinionated public-data Actors. Honest pricing, real engineering, zero fine print.

</div>

# Actor input Schema

## `indicatorCodes` (type: `array`):

World Bank indicator codes to fetch (one paginated series per code), e.g. <code>NY.GDP.MKTP.CD</code>, <code>SP.POP.TOTL</code>, <code>EN.ATM.CO2E.PC</code>. Look codes up at <code>data.worldbank.org/indicator</code>.

## `countryCodes` (type: `string`):

<code>all</code> for every country, or a <code>;</code>-separated ISO list, e.g. <code>US;CN;DE</code>.

## `dateRange` (type: `string`):

Optional <code>YYYY</code> or <code>YYYY:YYYY</code> range, e.g. <code>2000:2024</code>. Leave empty for the API's full history.

## `includeSourceNote` (type: `boolean`):

Attach each indicator's methodology note and source organization to every row (one extra request per unique indicator, not per row).

## `maxResults` (type: `integer`):

Stop after this many rows. Each row is one billed result event.

## `proxyConfiguration` (type: `object`):

World Bank's API is public and keyless and does not need a proxy. Leave this off unless your account requires egress through Apify Proxy.

## Actor input object example

```json
{
  "indicatorCodes": [
    "NY.GDP.MKTP.CD",
    "SP.POP.TOTL"
  ],
  "countryCodes": "US;CN;DE",
  "dateRange": "2015:2024",
  "includeSourceNote": false,
  "maxResults": 200,
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}
```

# Actor output Schema

## `datasetItems` (type: `string`):

All dataset items as JSON.

## `datasetItemsCsv` (type: `string`):

Same data exported to CSV.

## `datasetView` (type: `string`):

Open the run dataset in the Console.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "indicatorCodes": [
        "NY.GDP.MKTP.CD",
        "SP.POP.TOTL"
    ],
    "countryCodes": "US;CN;DE",
    "dateRange": "2015:2024",
    "maxResults": 200,
    "proxyConfiguration": {
        "useApifyProxy": false
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("devilscrapes/world-bank-indicators-scraper").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "indicatorCodes": [
        "NY.GDP.MKTP.CD",
        "SP.POP.TOTL",
    ],
    "countryCodes": "US;CN;DE",
    "dateRange": "2015:2024",
    "maxResults": 200,
    "proxyConfiguration": { "useApifyProxy": False },
}

# Run the Actor and wait for it to finish
run = client.actor("devilscrapes/world-bank-indicators-scraper").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "indicatorCodes": [
    "NY.GDP.MKTP.CD",
    "SP.POP.TOTL"
  ],
  "countryCodes": "US;CN;DE",
  "dateRange": "2015:2024",
  "maxResults": 200,
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}' |
apify call devilscrapes/world-bank-indicators-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,devilscrapes/world-bank-indicators-scraper"
        }
    }
}

```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/igUBwyzHVBe1vKqdU/builds/Rvy8zwRlRKmQ1KFd9/openapi.json
