# World Country Profiles Scraper - Flags, Capitals & Currencies (`ninhothedev/country-profiles-scraper`) Actor

$0.5/1K 🔥 Country profiles scraper! Flags, capitals, currencies, languages, population & borders for 250 countries. No key. JSON, CSV, Excel or API in seconds. Power forms & travel apps ⚡

- **URL**: https://apify.com/ninhothedev/country-profiles-scraper.md
- **Developed by:** [ninhothedev](https://apify.com/ninhothedev) (community)
- **Categories:** Travel, Developer tools
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.50 / 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.

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

## World Country Profiles Scraper 🌍

**Get a complete, structured profile for every country on earth — flag image, flag emoji, capital city, region, population, area, official languages, currencies, international calling code, land borders, timezones, top-level domain and GPS coordinates — in a single run. No API key, no signup, no rate-limit headaches.**

Country reference data sounds trivial until you need it. Then you discover that the free API you bookmarked is deprecated, the CSV you found is five years old, the flag URLs are broken, and half the "countries" in your dropdown are missing their capital. This actor gives you one clean, refreshed dataset you can drop straight into a database, a form, or an LLM pipeline.

***

### What you get

One row per country or territory (~250 records), with these fields:

| Field | Example | Notes |
|---|---|---|
| `name_common` | `Germany` | Everyday name |
| `name_official` | `Federal Republic of Germany` | Full official name |
| `cca2` / `cca3` | `DE` / `DEU` | ISO 3166-1 alpha-2 & alpha-3 |
| `capital` | `Berlin` | Primary capital |
| `region` / `subregion` | `Europe` / `Western Europe` | |
| `continents` | `["Europe"]` | |
| `population` | `83491249` | Latest available figure |
| `area_km2` | `357114` | Square kilometres |
| `languages` | `["German"]` | Plain language names |
| `currencies` | `["EUR - Euro"]` | Human-readable label |
| `currency_codes` | `["EUR"]` | ISO 4217 codes |
| `flag_png` | `https://flagcdn.com/w320/de.png` | Ready-to-embed image URL |
| `flag_emoji` | `🇩🇪` | |
| `latitude` / `longitude` | `51` / `9` | Country centroid |
| `borders` | `["AUT","BEL","CZE", …]` | Neighbours as alpha-3 |
| `border_count` | `9` | |
| `timezones` | `["UTC+01:00"]` | |
| `tld` | `[".de"]` | |
| `calling_code` | `+49` | International dialling prefix |
| `driving_side` | `right` | |
| `un_member` / `independent` | `true` / `true` | |
| `google_maps_url` | Google Maps search link | |
| `source` / `scraped_at` | provenance + UTC timestamp | |

Every field is nullable — small territories legitimately have no capital, no borders or no currency.

***

### Input

```json
{
  "mode": "all",
  "maxItems": 300
}
```

```json
{
  "mode": "countries",
  "countries": ["Germany", "Japan", "BR", "USA"],
  "maxItems": 300
}
```

| Input | Type | Default | Description |
|---|---|---|---|
| `mode` | select `all` / `countries` | `all` | Scrape every country, or only the ones you list |
| `countries` | array of strings | `[]` | Names or ISO codes (`Germany`, `DE`, `DEU`, `Deutschland` all work) |
| `maxItems` | integer (1–1000) | `300` | Cap on how many profiles get pushed |

***

### Use cases

**1. Country dropdowns & signup forms.** One run gives you name, ISO code, flag image and calling code — everything a country `<select>`, a phone-number field or a shipping form needs, already sorted and consistent. No more hand-maintained JSON files that drift out of date.

**2. Travel & booking apps.** Combine capital, coordinates, timezone, currency, driving side and Google Maps link to build destination pages, currency converters, or "what you need to know before you fly" cards without stitching together five different sources.

**3. CRM & lead data enrichment.** Map raw country strings from your leads ("DE", "Deutschland", "Germany") onto a canonical record with region, subregion and continent — then segment campaigns, assign sales territories, or normalise a messy import in minutes.

**4. Teaching, quizzes & data journalism.** Population, area, borders and flags are the raw material for geography quizzes, classroom datasets, choropleth maps and newsroom fact-checks. Border data (`borders` + `border_count`) also powers graph/network exercises.

***

### Data source (and why it matters)

The classic free `restcountries.com` v1–v4 endpoints were **shut down** — every legacy request now returns `{"success": false, "errors":[{"message":"This API version has been deprecated…"}]}`, and the replacement v5 API requires an account and an `Authorization: Bearer` key.

This actor is built to keep working without a key:

1. It **still probes** the legacy `restcountries.com/v3.1/all?fields=…` endpoint first, and uses it automatically if it ever comes back (`source: "restcountries"`).
2. Otherwise it falls back to the **[mledoze/countries](https://github.com/mledoze/countries)** dataset — the very open dataset restcountries itself was built on — served from GitHub raw (`source: "mledoze"`), enriched with:
   - **population** from the keyless **World Bank** indicator API (`SP.POP.TOTL`, most recent year),
   - **timezones** from the archived restcountries v2 dataset dump,
   - **flag images** from **[flagcdn.com](https://flagcdn.com)** (`w320` PNG, hotlink-friendly).

The `source` field on every record tells you exactly which path was used for that run.

***

### Pricing

Runs on the pay-per-usage model. A full ~250-country run finishes in well under a minute on 512 MB, which works out to roughly **$0.5 per 1,000 country profiles** — a complete world dataset for a few cents.

***

### Output sample

```json
{
  "name_common": "Germany",
  "name_official": "Federal Republic of Germany",
  "cca2": "DE",
  "cca3": "DEU",
  "capital": "Berlin",
  "region": "Europe",
  "subregion": "Western Europe",
  "continents": ["Europe"],
  "population": 83491249,
  "area_km2": 357114,
  "languages": ["German"],
  "currencies": ["EUR - Euro"],
  "currency_codes": ["EUR"],
  "flag_png": "https://flagcdn.com/w320/de.png",
  "flag_emoji": "🇩🇪",
  "latitude": 51,
  "longitude": 9,
  "borders": ["AUT", "BEL", "CZE", "DNK", "FRA", "LUX", "NLD", "POL", "CHE"],
  "border_count": 9,
  "timezones": ["UTC+01:00"],
  "tld": [".de"],
  "calling_code": "+49",
  "driving_side": "right",
  "un_member": true,
  "independent": true,
  "google_maps_url": "https://www.google.com/maps/search/?api=1&query=Germany",
  "source": "mledoze",
  "scraped_at": "2026-07-28T13:59:09+00:00"
}
```

Export as JSON, CSV, Excel or XML, or pull it straight from the Apify API into your app.

***

### FAQ

**Do I need an API key?** No. That is the whole point of this actor.

**How many countries are there?** 250 entries, covering UN members, observer states and dependent territories. Filter with `un_member` or `independent` if you only want sovereign states.

**Why is `capital` empty for a few rows?** Places like Antarctica or Bouvet Island genuinely have no capital. Same logic applies to `borders` for islands.

**Can I get a specific country only?** Yes — set `mode` to `countries` and list names or ISO codes.

**How fresh is the data?** Boundaries, codes and currencies come from a continuously maintained open dataset; population is the most recent World Bank figure available.

***

### Related actors

- [Countries Data Scraper](https://apify.com/ninhothedev/countries-data-scraper)
- [World Bank Scraper](https://apify.com/ninhothedev/worldbank-scraper)
- [Geocoding Scraper](https://apify.com/ninhothedev/geocoding-scraper)
- [Wikivoyage Scraper](https://apify.com/ninhothedev/wikivoyage-scraper)

***

### Development

```bash
python -m py_compile src/*.py
python tests/test_smoke.py   # offline smoke tests
apify run                    # local run
```

Legal note: all data comes from public, openly licensed datasets (mledoze/countries, World Bank Open Data, flagcdn). No personal data is collected.

# Actor input Schema

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

Choose 'All countries' to scrape a profile for every country and territory on earth (~250 records), or 'Specific countries' to only scrape the countries listed in the 'Countries' field below.

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

Country names or ISO codes to scrape, one per line - for example 'Germany', 'Japan', 'DE' or 'JPN'. Only used when Mode is set to 'Specific countries'. Matching is case-insensitive and also accepts official names and common alternative spellings.

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

Maximum number of country profiles to push to the dataset. Use it to cap your run cost - there are about 250 countries and territories in total.

## Actor input object example

```json
{
  "mode": "all",
  "countries": [
    "Germany",
    "Japan"
  ],
  "maxItems": 300
}
```

# 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 = {
    "countries": [
        "Germany",
        "Japan"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("ninhothedev/country-profiles-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 = { "countries": [
        "Germany",
        "Japan",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("ninhothedev/country-profiles-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 '{
  "countries": [
    "Germany",
    "Japan"
  ]
}' |
apify call ninhothedev/country-profiles-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,ninhothedev/country-profiles-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/oK8ci8M8Iy10A9GRh/builds/nbkCZe3lD2kBZ64zm/openapi.json
