# World Happiness Report — Rankings & Factors (`memo23/world-happiness-report`) Actor

Official World Happiness Report rankings for every edition with published data (2012, 2015-2026): rank, score, six factor contributions, ISO3 codes. JSON or CSV out.

- **URL**: https://apify.com/memo23/world-happiness-report.md
- **Developed by:** [Muhamed Didovic](https://apify.com/memo23) (community)
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $10.00 / 1,000 scraped items

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/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 Happiness Report — Rankings & Factors

<p align="center"><img src="https://raw.githubusercontent.com/muhamed-didovic/muhamed-didovic.github.io/main/assets/world-happiness-logo.png" width="140" alt="World Happiness Report"></p>

Official World Happiness Report rankings for every edition with published data (2012, 2015–2026): rank, score, and the six factor contributions (GDP per capita, social support, life expectancy, freedom, generosity, corruption). One row per country-year, clean JSON out.

***

### Why use this scraper

- **Official data.** Downloads the World Happiness Report's own published Excel files — no scraping, no parsing HTML.
- **All editions.** 2012, 2015–2026. Scrape one edition or all of them.
- **Full factor breakdown.** Each row has the happiness score plus all six factor contributions: GDP per capita, social support, healthy life expectancy, freedom, generosity, and corruption perception.
- **Historical data.** Each edition contains multiple years of data (e.g. the 2026 edition has 2011–2025), so you get time-series for every country.
- **No login, no API key.** Reads the public Excel files directly.

***

### Overview

The World Happiness Report is an annual publication that ranks countries by their happiness score, based on Gallup World Poll data. This actor downloads the official Excel files and outputs one row per country-year with the rank, score, and six factor contributions.

***

### Use cases

- **Academic research** — analyze happiness trends across countries and years.
- **Data journalism** — visualize happiness rankings and factor breakdowns.
- **Policy analysis** — compare countries on GDP, social support, life expectancy, freedom, generosity, and corruption.
- **Benchmarking** — use happiness scores as a quality-of-life indicator in dashboards.

***

### How it works

<p align="center"><img src="https://raw.githubusercontent.com/muhamed-didovic/muhamed-didovic.github.io/main/assets/how-it-works-world-happiness.png" width="900" alt="How it works"></p>

1. You provide edition years (e.g. `2026`, `2025`) or leave empty for all.
2. The actor downloads the official WHR Excel file for each edition.
3. It parses the Excel with the `xlsx` library.
4. Each country-year becomes one row in the dataset with rank, score, and all six factors.

***

### Input

| Field | Type | Default | Notes |
|---|---|---|---|
| `editions` | array | all | Edition years to scrape (e.g. `2026`, `2025`). Leave empty for all (2012, 2015–2026). |
| `maxItems` | integer | 10000 | Maximum country-year rows to output. |
| `proxy` | object | Apify proxy | Proxy configuration (not needed — files are public). |

```json
{
  "editions": ["2026", "2025"],
  "maxItems": 10000
}
```

***

### Output

One row per country-year:

```json
{
  "type": "happiness-ranking",
  "edition": "2026",
  "year": 2025,
  "rank": 1,
  "countryName": "Finland",
  "happinessScore": 7.764,
  "gdpPerCapita": 1.915,
  "socialSupport": 1.638,
  "healthyLifeExpectancy": 0.939,
  "freedom": 1.105,
  "generosity": 0.093,
  "corruption": 0.491,
  "dystopiaResidual": 2.583,
  "lowerWhisker": 7.69,
  "upperWhisker": 7.837
}
```

#### Key output fields

- **`edition`** — WHR edition year (e.g. `2026`).
- **`year`** — the data year (editions contain multiple years).
- **`rank`** — happiness rank for that year.
- **`countryName`** — country name.
- **`happinessScore`** — happiness score (0–10 scale).
- **`gdpPerCapita` / `socialSupport` / `healthyLifeExpectancy` / `freedom` / `generosity` / `corruption`** — the six factor contributions to the score.
- **`dystopiaResidual`** — the residual (unexplained) component.

***

### Available editions

2012, 2015, 2016, 2017, 2018, 2019, 2020, 2022, 2023, 2024, 2025, 2026

***

### ⚠️ Disclaimer

This Actor downloads publicly available Excel files from the World Happiness Report's official website. The data is © World Happiness Report and is used here under their published terms. You are responsible for using the output in line with their terms and any applicable law in your jurisdiction.

***

### SEO Keywords

world happiness report, happiness rankings, happiness score, happiness data, whr data, country happiness, gdp per capita, social support, life expectancy, freedom index, generosity, corruption perception, happiness factors, happiness time series, country rankings, quality of life index, well-being data, gallup world poll

# Actor input Schema

## `editions` (type: `array`):

Editions to scrape (e.g. 2026, 2025). Leave empty for all available editions (2012, 2015-2026).

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

Maximum number of country-year rows to output.

## `proxy` (type: `object`):

Apify proxy to use.

## Actor input object example

```json
{
  "editions": [
    "2026",
    "2025"
  ],
  "maxItems": 10000,
  "proxy": {
    "useApifyProxy": true
  }
}
```

# 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 = {
    "editions": [
        "2026",
        "2025"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("memo23/world-happiness-report").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 = { "editions": [
        "2026",
        "2025",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("memo23/world-happiness-report").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 '{
  "editions": [
    "2026",
    "2025"
  ]
}' |
apify call memo23/world-happiness-report --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,memo23/world-happiness-report"
        }
    }
}
```

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/IpQNosk2HyA7MNv7s/builds/KhC1KF6E2TZtIwT7w/openapi.json
