# World Bank Indicators Scraper (`b2b_lead_generation/world-bank-indicators-scraper`) Actor

- **URL**: https://apify.com/b2b_lead_generation/world-bank-indicators-scraper.md
- **Developed by:** [B2B Lead Generation](https://apify.com/b2b_lead_generation) (community)
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.99 / 1,000 results

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

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

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
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.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## 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.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## World Bank Indicators Scraper: WDI by Country & Year

<p align="center">
  <img src="https://imgur.com/JF4VyoE.png" alt="World Bank Indicators Scraper" style="max-width:100%; border-radius:14px; width:680px;" />
</p>

Collect yearly development indicators—such as total population, GDP, and economic metrics—for targeted countries across specified date ranges. This tool gathers structured historical records in bulk, allowing you to export global datasets directly to JSON, CSV, or Excel formats.

Rather than searching through individual web pages, you can extract reliable, multi-year economic and demographic metrics in clean, structured tables.

### Use Cases

- **Population trends:** Extract multi-year population totals (`SP.POP.TOTL`) for specific countries or across all supported nations.
- **Economic analysis:** Pull GDP figures (`NY.GDP.MKTP.CD`) and compare national economic metrics year over year.
- **Custom date windows:** Filter dataset extractions to specific ranges (e.g., `2000:2024`) to eliminate unnecessary historical data.
- **Automated reporting:** Maintain up-to-date research spreadsheets and databases with scheduled data refreshes.
- **Research & analysis:** Keep indicator labels, country identifiers, observation statuses, and numeric metrics side-by-side.

### Extracted Data Points

Each observation includes standard metadata for clean analysis:

- Country name, standard country code, and ISO3 identifier
- Indicator code and indicator name
- Year or observation period
- Metric value (including decimal precision and observation status)

### Input Parameters

| Parameter | Type | Default | Description |
| --- | --- | --- | --- |
| `mode` | String | `values` | Extraction mode (one row per country, indicator, and year). |
| `countries` | Array | `["US"]` | ISO 2-letter or 3-letter country codes (or `["all"]` for all available countries). |
| `indicators` | Array | `["SP.POP.TOTL"]` | Target indicator codes (one per entry). |
| `date` | String | empty | Target year or range (e.g., `2000:2024`). Leave blank to retrieve all available years. |
| `maxItems` | Integer | `100` | Maximum row count limit (up to 1,000). |
| `timeoutSecs` | Integer | `300` | Overall execution limit in seconds. |

#### Example Input

```json
{
    "mode": "values",
    "countries": ["US"],
    "indicators": ["SP.POP.TOTL"],
    "date": "2000:2024",
    "maxItems": 100,
    "timeoutSecs": 300
}

```

### Output Format

```json
{
    "indicator": {
        "id": "SP.POP.TOTL",
        "value": "Population, total"
    },
    "indicatorId": "SP.POP.TOTL",
    "indicatorName": "Population, total",
    "country": {
        "id": "US",
        "value": "United States"
    },
    "countryId": "US",
    "countryName": "United States",
    "countryiso3code": "USA",
    "date": "2025",
    "value": 341784857,
    "unit": "",
    "obs_status": "",
    "decimal": 0
}

```

### How It Works

1. Processes input configurations, applying country lists, indicator codes, and year range filters.
2. Formats requests into structured pages to collect observations efficiently.
3. Automatically deduplicates rows by indicator, country, and year.
4. Handles brief network interruptions smoothly using retry delays.
5. Generates clean datasets available for instant export as JSON, CSV, or Excel.

### Frequently Asked Questions

**Can I pull data for all countries at once?**

Yes. Include `"all"` in the `countries` array. Because this generates a large volume of data, specifying a date range and `maxItems` limit is recommended.

**What happens if a specific indicator code is invalid?**

An error entry will be recorded for that query explaining the issue, allowing the process to continue running for the remaining valid indicators.

**Why are some values empty or null?**

If the source source dataset does not have a recorded metric for a specific year, the row is preserved with a `null` value so data gaps remain visible in your analysis.

***

### Legal & Compliance

#### Trademark Notice

World Bank Indicators and related names, logos, and trademarks belong to their respective owners. Their mention in this documentation is strictly to identify data compatibility and utility, and does not imply affiliation, sponsorship, or endorsement.

#### Disclaimer

This tool is an independent utility and is not affiliated with, endorsed by, or officially connected to third-party data providers. Users are responsible for ensuring their usage complies with relevant terms of service, usage guidelines, and licensing terms.

#### Is web scraping legal?

This tool collects publicly available statistical data without bypassing access controls. Collecting public data is standard practice, but proper compliance requires considering how the data is used:

- **Personal data:** Ensure dataset usage respects regional privacy regulations (such as GDPR or CCPA) when combining outputs with personal user records.
- **Copyright & Terms:** Respect the terms of use, usage limits, and licensing terms set by the data source.
- **Legal advice:** This summary is provided for general informational purposes and does not constitute formal legal counsel.

# Actor input Schema

## `mode` (type: `string`):

values fetches yearly indicator observations for each country and indicator pair.

## `countries` (type: `array`):

ISO 2-letter or 3-letter country codes, or all. One code per line. Example: US.

## `indicators` (type: `array`):

World Bank indicator codes, one per line. Example: SP.POP.TOTL for total population.

## `date` (type: `string`):

Optional year or year range sent as the date query, such as 2020 or 2000:2024. Leave blank for every year the API returns.

## `maxItems` (type: `integer`):

Maximum rows to save in one run, including error rows. Values above 1000 are clamped to 1000.

## `timeoutSecs` (type: `integer`):

Stop scheduling new requests after this many seconds. Rows already saved are kept.

## `requestTimeoutSecs` (type: `integer`):

Per-request timeout in seconds for each call to the World Bank indicators API.

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

Optional proxy. Default is no proxy. The public indicators API does not require a proxy, and proxies are not used to get around stated limits.

## Actor input object example

```json
{
  "mode": "values",
  "countries": [
    "US"
  ],
  "indicators": [
    "SP.POP.TOTL"
  ],
  "date": "2000:2024",
  "maxItems": 100,
  "timeoutSecs": 300,
  "requestTimeoutSecs": 30,
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}
```

# Actor output Schema

## `datasetUrl` (type: `string`):

Default dataset for this run.

## `overview` (type: `string`):

Table of indicator observations from this run.

# 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 = {
    "mode": "values",
    "countries": [
        "US"
    ],
    "indicators": [
        "SP.POP.TOTL"
    ],
    "date": "",
    "maxItems": 100,
    "timeoutSecs": 300,
    "requestTimeoutSecs": 30,
    "proxyConfiguration": {
        "useApifyProxy": false
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("b2b_lead_generation/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 = {
    "mode": "values",
    "countries": ["US"],
    "indicators": ["SP.POP.TOTL"],
    "date": "",
    "maxItems": 100,
    "timeoutSecs": 300,
    "requestTimeoutSecs": 30,
    "proxyConfiguration": { "useApifyProxy": False },
}

# Run the Actor and wait for it to finish
run = client.actor("b2b_lead_generation/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 '{
  "mode": "values",
  "countries": [
    "US"
  ],
  "indicators": [
    "SP.POP.TOTL"
  ],
  "date": "",
  "maxItems": 100,
  "timeoutSecs": 300,
  "requestTimeoutSecs": 30,
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}' |
apify call b2b_lead_generation/world-bank-indicators-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,b2b_lead_generation/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/84k5VCnaTv5q6Lqh0/builds/BigrdCOxcmdkVVKN3/openapi.json
