# REST Countries Scraper (`parseforge/restcountries-scraper`) Actor

Scrapes country data from REST Countries API by region or name search. Returns each country as a flat row with name, capital, region, population, area, currencies, languages, and flag URL.

- **URL**: https://apify.com/parseforge/restcountries-scraper.md
- **Developed by:** [ParseForge](https://apify.com/parseforge) (community)
- **Categories:** Other, Developer tools, Lead generation
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $19.00 / 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?

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

[![ParseForge](https://raw.githubusercontent.com/ParseForge/apify-assets/main/banner.jpg)](https://apify.com/parseforge?fpr=vmoqkp)

### REST Countries Scraper

**Scrape country data and flags from REST Countries, up to 250 countries per run.** Every country comes with its name, capital, region, population, area, currencies, languages, and flag image URL. No API key or login. Export to CSV, JSON, Excel, or XML.

REST Countries is a free public API that provides detailed information about every country in the world, but querying it manually means writing code, handling pagination, and parsing nested JSON. This Actor reads the API directly, filters by region or country name, and returns each country as one flat row. You get clean, structured data without any setup.

| Who uses it | What they scrape REST Countries for |
|---|---|
| Market researchers | Build a dataset of countries by region for demographic analysis |
| Travel app developers | Populate a country picker with names, capitals, and flag images |
| Data journalists | Compare population, area, and language data across countries |
| Educators | Create geography quizzes and reference tables for students |

### What it does

This Actor collects country data from REST Countries by region or name search, and returns each country as a flat row with fields like name, capital, region, population, area, currencies, languages, and flag URL.

- 🌍 **Region filter:** Select Africa, Americas, Asia, Europe, Oceania, or Antarctic, or scrape all 250 countries.
- 🔍 **Name search:** Enter a partial country name like 'united' to get matching countries.
- 📊 **Flat output:** Each country is returned as a single row, ready for spreadsheets or databases.
- 🖼️ **Flag URLs:** Every record includes a direct link to the country's flag image.

Results export to CSV, JSON, Excel, or XML, or straight from the API.

### What you can do with REST Countries data

**📈 Build a regional country dataset.**

A market researcher selects the Europe region and scrapes all 50 countries to compare population and area for a report.

**🗺️ Populate a travel app's country selector.**

A developer scrapes all countries with their flag URLs and capital names to seed a mobile app's destination picker.

**📰 Fact-check country statistics.**

A journalist searches for 'united' to quickly pull data on the United States, United Kingdom, and United Arab Emirates for an article.

**🎓 Create geography teaching materials.**

An educator scrapes all countries in Africa to generate a worksheet with capitals, populations, and flags.

### Why choose this scraper

|  | What you get |
|---|---|
| **No API key** | REST Countries is free and open, no registration or authentication needed |
| **All 250 countries** | Covers every sovereign state and dependent territory in one dataset |
| **Flat schema** | Nested fields like currencies and languages are flattened into simple columns |
| **Export anywhere** | Download as CSV, JSON, Excel, or XML for your workflow |

### How it compares

No other Store actor targets REST Countries the same way, so the honest comparison is with the alternatives teams actually weigh.

| | REST Countries Scraper | Build it in-house | By hand |
|---|---|---|---|
| Setup | Run it now, zero config | Days of engineering | None, but hours per pull |
| When REST Countries changes | Maintained for you | You fix it | You re-learn the page |
| Proxies, retries, anti-bot | Built in | Your problem | Browser only |
| Output | Fixed JSON schema, CSV/Excel export | Whatever you build | Copy-paste |
| Cost | Pay per result | Engineering time | Analyst hours |

### Configure the run

Drive the Actor with a region filter or a country name search, and set a maximum number of countries to collect per run. The Input tab lists every parameter.

A first run with the defaults:

```json
{
  "maxItems": 10,
  "region": "all"
}
```

A larger pull:

```json
{
  "maxItems": 200,
  "region": "all"
}
```

### Pricing

Pay-per-result: **$0.021 per result** collected. You pay only for the results written to your dataset.

| Results collected | Approximate cost |
|---|---|
| 100 results | $2.10 |
| 1,000 results | $21.00 |
| 10,000 results | $210.00 |

New Apify accounts start with $5 in free credit.

### Free users

Free-plan runs return up to 10 results as a preview. [Upgrade your Apify plan](https://console.apify.com/sign-up?fpr=vmoqkp) to collect up to 1,000,000 results per run.

### Run it

1. [Create a free Apify account with $5 in credit](https://console.apify.com/sign-up?fpr=vmoqkp).
2. Open the [REST Countries Scraper](https://apify.com/parseforge/restcountries-scraper?fpr=vmoqkp).
3. Set your inputs and any filters, then click **Start**.
4. Export the results as CSV, Excel, JSON, or XML from the **Dataset** tab.

Run it programmatically through the [Apify API](https://docs.apify.com/api/v2) (`run-sync-get-dataset-items`) or the [ApifyClient](https://docs.apify.com/api/client/js) for JavaScript and Python.

### Use with AI agents (MCP)

Give an AI agent live access to REST Countries through the Model Context Protocol. Add the Actor to Claude, Cursor, or any MCP client:

```bash
claude mcp add --transport http apify "https://mcp.apify.com/?tools=parseforge/restcountries-scraper"
```

Then prompt it in plain language to run the scraper and read back the results.

### Troubleshooting

**Why am I getting no results?**

Check your region filter and country name search. If you set a region and also enter a country name that is not in that region, you will get zero results. Try clearing the search field or setting region to 'All Regions'.

**Why is the run slow?**

The REST Countries API may be rate-limited. Reduce the maxItems value or run during off-peak hours. The Actor processes countries sequentially to avoid hitting limits.

**Why are some fields empty?**

Some countries may not have data for certain fields, such as capital or area. This is normal for dependent territories. Check the REST Countries documentation for field availability.

**Why did I get fewer countries than maxItems?**

The total number of countries returned depends on your filters. If you set maxItems to 100 but only 50 countries match your region, you will get 50 results.

**Why is the flag URL not working?**

Flag URLs are provided by REST Countries and may change. If a URL is broken, try re-running the Actor to get the latest data, or check the REST Countries website for updates.

### FAQ

| Question | Answer |
|---|---|
| Is the REST Countries API free? | Yes, REST Countries is a free public API with no authentication or API key required. This Actor uses the public endpoint directly. |
| How many countries can I scrape in one run? | You can scrape up to 250 countries, which is the full list available from REST Countries. Use the maxItems input to limit the number if you need fewer. |
| Can I filter by region? | Yes, select from Africa, Americas, Asia, Europe, Oceania, or Antarctic. Choose 'All Regions' to scrape every country. |
| Can I search for a specific country? | Yes, use the country name search field. It supports partial matches, so entering 'united' returns the United States, United Kingdom, and United Arab Emirates. |
| What data fields are returned for each country? | Each country record includes name, capital, region, subregion, population, area, currencies, languages, flag URL, and more. The exact fields are shown in the sample output. |
| Does the output include flag images? | Yes, every country record includes a direct URL to its flag image in PNG or SVG format, which you can download or embed. |
| What export formats are supported? | You can export the scraped data as CSV, JSON, Excel, or XML from the Apify dataset. |
| Is there a rate limit on the REST Countries API? | The public API is generally rate-limited, but this Actor handles requests efficiently. For large runs, the maxItems input lets you control the volume. |
| Can I schedule this Actor to run regularly? | Yes, you can set up a schedule in Apify to run this Actor daily, weekly, or at any interval to keep your country data up to date. |
| Does this Actor work with Apify's integrations? | Yes, you can connect the output dataset to Google Sheets, Slack, Zapier, or any other Apify integration for automated workflows. |

### Related actors

Browse the full [ParseForge collection](https://apify.com/parseforge?fpr=vmoqkp) for more scrapers.

🆘 **Need help?** Email parseforge@protonmail.com with your run ID, your input, and what you expected.

⚠️ **Disclaimer.** This Actor is unofficial and is not affiliated with, endorsed by, or sponsored by REST Countries. It collects only publicly available data. You are responsible for using the collected data in compliance with the source's terms of service and applicable data-protection laws, including GDPR, CCPA, and PIPL. Do not use it to collect personal data unlawfully.

# Actor input Schema

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

How many countries to collect per run.

## `region` (type: `string`):

Filter countries by region. Select 'all' to scrape all 250 countries.

## `search` (type: `string`):

Optional. Search for a specific country by name (partial match supported, e.g. 'united'). Leave blank to use region filter.

## Actor input object example

```json
{
  "maxItems": 10,
  "region": "all"
}
```

# Actor output Schema

## `results` (type: `string`):

No description

# 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 = {
    "maxItems": 10,
    "region": "all"
};

// Run the Actor and wait for it to finish
const run = await client.actor("parseforge/restcountries-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 = {
    "maxItems": 10,
    "region": "all",
}

# Run the Actor and wait for it to finish
run = client.actor("parseforge/restcountries-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 '{
  "maxItems": 10,
  "region": "all"
}' |
apify call parseforge/restcountries-scraper --silent --output-dataset

```

## MCP server setup

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