# Wikipedia trending - top pageviews by day/country (API) (`retrainmapdata/wikipedia-trending`) Actor

The 1,000 most-viewed Wikipedia articles for a day - per project (en.wikipedia, de.wikipedia, ...) or per country - plus daily view series for chosen articles, from the Wikimedia Pageviews API. Rank, article, views, date, link. Default: yesterday's English top 200.

- **URL**: https://apify.com/retrainmapdata/wikipedia-trending.md
- **Developed by:** [RetrainMap Data](https://apify.com/retrainmapdata) (community)
- **Categories:**
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $5.00 / 1,000 records

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?

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

## Wikipedia trending — top pageviews by day/country (API)

What people read on Wikipedia yesterday. One row per ranked article from the Wikimedia
Foundation's **Pageviews API**: the 1,000 most-viewed pages of a project (English, German,
Spanish, … or `all-projects`) or of a **country** for a given day, or the **daily view series**
of articles you name. Each row carries rank, article, views, project, country, date, access
method and a link to the page.

### Data source and status

| | |
|---|---|
| Publisher | Wikimedia Foundation — Analytics Query Service, `https://wikimedia.org/api/rest_v1/metrics/pageviews/…` (public, no key; a descriptive `User-Agent` is required and sent) |
| Endpoints | `top/{project}/{access}/{Y}/{M}/{D}` · `top-per-country/{country}/{access}/{Y}/{M}/{D}` · `per-article/{project}/{access}/{agent}/{title}/daily/{start}/{end}` ([reference](https://doc.wikimedia.org/generated-data-platform/aqs/analytics-api/reference/page-views.html)) |
| Refresh cadence | Wikimedia publishes each UTC day a few hours after it ends. The Actor reads live on every run; with no `date` given it asks for yesterday and, if that day is not out yet, uses the day before and says so (`date_fallback_used` in the run summary) |
| Precision | Per-project top lists and article series are exact counts. Per-country top lists are published as **ceilings** (rounded up) to protect reader privacy — rows carry `views_is_ceiling: true` |
| Terms and licence | Use of the API is subject to the [Wikimedia Terms of Use](https://foundation.wikimedia.org/wiki/Policy:Terms_of_Use) and API etiquette (identify yourself, ≤ 100 requests/s). Wikimedia's REST API notice states that content accessed via the API is licensed CC BY-SA 3.0 unless an endpoint says otherwise; attribute the Wikimedia Foundation when you republish these statistics |
| Response guards | The item/article keys measured on 2026-09-04 (`article`, `rank`, `views` / `views_ceil`, `project`, `timestamp`) must be present; anything else fails the run loudly instead of writing guessed values |
| Identification | `User-Agent: RetrainMap-wikipedia-trending/0.1 (https://apify.com/retrainmap; <contact>)` plus the contact address in the standard `From:` header |

Honesty note: "trending" here means *most viewed on that day as published by Wikimedia* —
the Actor adds no ranking of its own. `exclude_non_articles` (default on) drops `Main_Page`,
`-` and titles with English namespace prefixes (`Special:`, `Wikipedia:`, `File:`, …); on
other-language projects the localised prefixes are not recognised, so a few non-article pages
can remain. Ranks keep their original numbers, so gaps show what was dropped.

### Input

| Field | Type | Meaning |
|---|---|---|
| `mode` | `top` / `top_per_country` / `article_series` | Default `top` |
| `project` | string | Default `en.wikipedia` (e.g. `de.wikipedia`, `commons.wikimedia`, `all-projects`) |
| `country` | 2-letter code | For `top_per_country`; default `US` |
| `date` | `YYYY-MM-DD` | Top modes; default yesterday (UTC) with one-day fallback |
| `access` | `all-access` / `desktop` / `mobile-web` / `mobile-app` | Default `all-access` |
| `articles` | array of titles | For `article_series`, e.g. `"Python (programming language)"` |
| `start_date`, `end_date` | `YYYY-MM-DD` | Series range; default the 30 days ending yesterday |
| `agent` | `user` / `all-agents` / `spider` / `automated` | Series only; default `user` |
| `exclude_non_articles` | boolean | Default true |
| `max_records` | integer | Default 200 (a top list has 1,000 entries) |
| `request_interval_ms` | integer | Default 250 (floor 100) |
| `contact_email` | string | Sent in the User-Agent and `From:` header |

Examples:

```json
{ "mode": "top_per_country", "country": "IN", "max_records": 100 }
```

```json
{ "mode": "article_series", "articles": ["Artificial intelligence", "Python (programming language)"], "start_date": "2026-08-01", "end_date": "2026-08-31" }
```

### Output (dataset row)

`rank` (null in series mode), `article` (title with spaces), `article_key` (as in the URL),
`views`, `views_is_ceiling`, `project`, `country` (per-country mode), `date`, `access`, `agent`
(series mode), `wikipedia_url`, `fetched_at`. A run summary (mode, effective date, fallback
flag, the exact API requests made, counts) is stored as `RUN_SUMMARY` in the run's key-value
store.

### Pricing (pay per event)

| Event | Price |
|---|---|
| `run-start` — once per run | $0.10 |
| `record` — per row written | $0.005 |

The default run (200 rows) costs $1.10; a full 1,000-row top list $5.10. Rows stop when your
run's maximum charge is reached; the run summary says so.

### Operator

Steelyard Ventures LLC (RetrainMap) — info@steelyardclinical.com. The Actor writes only to its
own dataset and key-value store; it stores no credentials and sends nothing but GET requests.

# Actor input Schema

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

`top`: the 1,000 most-viewed pages of a project on one day. `top_per_country`: the 1,000 most-viewed pages from one country (counts are ceilings). `article_series`: daily views of the given articles over a date range.

## `project` (type: `string`):

Wikimedia project, e.g. en.wikipedia, de.wikipedia, es.wikipedia, commons.wikimedia (or all-projects for `top`). Ignored in top\_per\_country mode, where each row carries its own project.

## `country` (type: `string`):

Two-letter ISO 3166-1 country code, e.g. US, GB, IN, DE.

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

YYYY-MM-DD (UTC day). Leave empty for yesterday; if Wikimedia has not published yesterday yet, the Actor uses the day before and says so.

## `access` (type: `string`):

Which traffic to count.

## `articles` (type: `array`):

Article titles as on Wikipedia (spaces or underscores), e.g. "Python (programming language)". Used only in article\_series mode.

## `start_date` (type: `string`):

YYYY-MM-DD. Default: 29 days before the end date.

## `end_date` (type: `string`):

YYYY-MM-DD. Default: yesterday (UTC).

## `agent` (type: `string`):

Traffic class for the per-article series. `user` excludes spiders and automated traffic.

## `exclude_non_articles` (type: `boolean`):

Drops Main\_Page, '-', and pages whose title starts with an English namespace prefix (Special:, Wikipedia:, File:, Portal:, Help:, Template:, Category:, Talk:, User:, ...). Ranks keep their original numbers, so gaps show what was dropped.

## `max_records` (type: `integer`):

Stop after this many rows (a top list has at most 1,000 entries).

## `request_interval_ms` (type: `integer`):

Politeness delay towards wikimedia.org (floor 100 ms; the API rule is at most 100 requests per second). Top modes make one request.

## `contact_email` (type: `string`):

Wikimedia requires a User-Agent with contact details. Sent in the User-Agent and in the standard From: request header (RFC 9110 s10.1.2).

## Actor input object example

```json
{
  "mode": "top",
  "project": "en.wikipedia",
  "country": "US",
  "access": "all-access",
  "articles": [
    "Artificial intelligence"
  ],
  "agent": "user",
  "exclude_non_articles": true,
  "max_records": 200,
  "request_interval_ms": 250,
  "contact_email": "info@steelyardclinical.com"
}
```

# Actor output Schema

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

One row per ranked article (or per article-day in series mode): rank, article, views, project, country, date, access, Wikipedia URL, fetch time.

## `results_csv` (type: `string`):

The same rows as a CSV file.

# 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": "top",
    "project": "en.wikipedia",
    "country": "US",
    "access": "all-access",
    "articles": [
        "Artificial intelligence"
    ],
    "agent": "user",
    "exclude_non_articles": true,
    "max_records": 200
};

// Run the Actor and wait for it to finish
const run = await client.actor("retrainmapdata/wikipedia-trending").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": "top",
    "project": "en.wikipedia",
    "country": "US",
    "access": "all-access",
    "articles": ["Artificial intelligence"],
    "agent": "user",
    "exclude_non_articles": True,
    "max_records": 200,
}

# Run the Actor and wait for it to finish
run = client.actor("retrainmapdata/wikipedia-trending").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": "top",
  "project": "en.wikipedia",
  "country": "US",
  "access": "all-access",
  "articles": [
    "Artificial intelligence"
  ],
  "agent": "user",
  "exclude_non_articles": true,
  "max_records": 200
}' |
apify call retrainmapdata/wikipedia-trending --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,retrainmapdata/wikipedia-trending"
        }
    }
}

```

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/m1oT72h6fh5EsroyL/builds/Y3wuJdQVKLQ39hzPj/openapi.json
