# Wikipedia Pageviews Scraper (`devilscrapes/wikipedia-pageviews-scraper`) Actor

Pull Wikipedia article traffic by day or month — view counts split by access type and agent, per article, over any date range. Keyless Wikimedia REST source for SEO, PR spike tracking, and public-interest trend research.

- **URL**: https://apify.com/devilscrapes/wikipedia-pageviews-scraper.md
- **Developed by:** [DevilScrapes](https://apify.com/devilscrapes) (community)
- **Categories:** Marketing, News
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per event

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

<div align="center">
  <img src=".actor/icon.svg" width="160" alt="Devil Scrapes mark" />

## Wikipedia Pageviews Scraper — Traffic & Trend Data

**💰 $2.20 / 1 000 results**  ·  pay only for results  ·  no credit card to try

*The devil's in the data — we just count the views.* 😈

Pull Wikipedia article traffic straight from the keyless Wikimedia REST Pageviews API — daily or monthly view counts, split by access method and agent type, for any list of articles over any date range. Built for measuring attention, not extracting content.

</div>

***

### 🎯 What this scrapes

The Wikimedia REST Pageviews API answers one question well: how many times was this article viewed, on this day, by this kind of visitor? This Actor takes a list of article titles and a date range and returns one clean row per article per day (or month), with view counts split by access method (desktop, mobile app, mobile web) and agent type (human, spider, automated). This is a traffic/trend feed, not a content scraper — for article text (summary, infobox, references) see our separate `wikipedia-article-scraper`. The two listings target different buyer intent on purpose and don't overlap.

### 🔥 What we handle for you

- 🔤 **Title normalization done right** — spaces, slashes, and non-ASCII characters (`Beyoncé`, `AC/DC`) are underscore-normalized and percent-encoded correctly before every request.
- 🫠 **One bad article never fails the run** — a title with no data for the requested range is logged and skipped; every other article still ships.
- 🔁 **Retries with exponential backoff** on `429 / 5xx` — up to 5 attempts, `Retry-After` honoured.
- 🧊 **Clean, typed dataset rows** — Pydantic-validated, one row per article per day/month, JSON / CSV / Excel export straight from the Apify Console.
- 🌐 **No key, no login, no proxy tax** — the Wikimedia Pageviews API is public and keyless; we don't add proxy overhead you don't need.
- 💰 **Pay-Per-Event pricing** — you only pay for rows that land in your dataset, plus one small warm-up charge per run.

### 💡 Use cases

- SEO and content strategists sizing topic demand before committing to a content push.
- PR and media researchers tracking attention spikes around a campaign or news event.
- Trend analysts building time series of public interest in a topic, product, or public figure.
- Academics and researchers studying public interest patterns at scale.

### ⚙️ How to use it

1. Click **Try for free** at the top of the page.
2. Enter the article titles you want traffic for, and a start/end date.
3. Click **Start**. Output streams into the run's dataset.
4. Export from **Storage → Dataset** as JSON, CSV, or Excel — or fetch via the API.

### 📥 Input

| Field | Type | Required | Default | Notes |
|---|---|:--:|---|---|
| `articles` | `array` | **yes** | — | Wikipedia article titles. Spaces are allowed — normalized to underscores automatically. |
| `project` | `string` | no | `en.wikipedia` | Wikimedia project, e.g. `en.wikipedia` or `commons.wikimedia`. |
| `startDate` | `string` | **yes** | — | First date in the range, as `YYYYMMDD`. |
| `endDate` | `string` | **yes** | — | Last date in the range (inclusive), as `YYYYMMDD`. Must be on or after `startDate`. |
| `access` | `string` | no | `all-access` | One of `all-access`, `desktop`, `mobile-app`, `mobile-web`. |
| `agent` | `string` | no | `user` | One of `all-agents`, `user`, `spider`, `automated`. |
| `granularity` | `string` | no | `daily` | `daily` or `monthly` row cadence. |

#### Example input

```json
{
  "articles": ["Web_scraping", "ChatGPT", "Artificial_intelligence"],
  "project": "en.wikipedia",
  "startDate": "20260801",
  "endDate": "20260810",
  "access": "all-access",
  "agent": "user",
  "granularity": "daily"
}
```

### 📤 Output

Every row is one dataset item — one article, one day (or month).

| Field | Type | Notes |
|---|---|---|
| `article` | `string` | Article title, underscore-normalized. |
| `project` | `string` | Wikimedia project queried. |
| `access` | `string` | Access method filter applied. |
| `agent` | `string` | Agent type filter applied. |
| `granularity` | `string` | Row cadence — `daily` or `monthly`. |
| `date` | `string` | ISO-8601 date (`YYYY-MM-DD`). |
| `views` | `integer` | View count for that article/date/filter combination. |

#### Example output

```json
{
  "article": "Web_scraping",
  "project": "en.wikipedia",
  "access": "all-access",
  "agent": "user",
  "granularity": "daily",
  "date": "2026-08-01",
  "views": 1842
}
```

### 💰 Pricing

Pay-Per-Event — you pay only when these events fire:

| Event | USD | What it is |
|---|---:|---|
| `actor-start` | $0.20 | One-off warm-up charge per run |
| `result` | $0.002 | Per pageviews row written to the dataset |

Example: 1 000 results at the rates above ≈ **$2.20**. No subscription, no minimum, no card to start — Apify gives every new account $5 of free credit.

### 🚧 Limitations

- A title that redirects to a canonical page reports its own (often near-zero) view count, not the canonical article's — use canonical titles for accurate numbers.
- A `404` from Wikimedia can mean either "no data for this date range" or "this article doesn't exist" — the API doesn't distinguish, so both are logged and skipped the same way.
- The separate `/top` most-viewed-articles endpoint isn't covered in this version — it's a fast-follow candidate.

### ❓ FAQ

**Do I need an API key?**

No. The Wikimedia Pageviews API is public and keyless — no auth, no login.

**What happens if an article has no data for my date range?**

That article is skipped with a warning and the run keeps going. If every article you asked for comes back empty, the run still succeeds with zero rows — it names exactly what was searched.

**Can I get monthly instead of daily numbers?**

Yes — set `granularity` to `monthly` and you'll get one row per month instead of one per day.

### 💬 Your feedback

Spotted a bug, hit a weird edge case, or need a new field? Open an
issue on the Actor's **Issues** tab on Apify Console — we ship
fixes weekly and we read every report.

***

<div align="center">

Built by **[Devil Scrapes](https://apify.com/DevilScrapes)** 😈 — a small fleet of
opinionated public-data Actors. Honest pricing, real engineering, zero fine print.

</div>

# Actor input Schema

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

Wikipedia article titles to fetch pageviews for. Spaces are allowed — they are normalized to underscores automatically.

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

Wikimedia project, e.g. <code>en.wikipedia</code> for the English Wikipedia or <code>commons.wikimedia</code> for Wikimedia Commons.

## `startDate` (type: `string`):

First date in the range, as <code>YYYYMMDD</code>, e.g. <code>20260801</code>.

## `endDate` (type: `string`):

Last date in the range (inclusive), as <code>YYYYMMDD</code>. Must be on or after Start date.

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

Restrict results to one access method, or leave the default to include all of them.

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

Restrict results to one agent type, or leave the default to count human traffic only.

## `granularity` (type: `string`):

Row cadence — one row per day or one row per month.

## Actor input object example

```json
{
  "articles": [
    "Web_scraping",
    "ChatGPT",
    "Artificial_intelligence"
  ],
  "project": "en.wikipedia",
  "startDate": "20260801",
  "endDate": "20260810",
  "access": "all-access",
  "agent": "user",
  "granularity": "daily"
}
```

# Actor output Schema

## `datasetItems` (type: `string`):

All dataset items as JSON.

## `datasetItemsCsv` (type: `string`):

Same data exported to CSV.

## `datasetView` (type: `string`):

Open the run dataset in the Console.

# 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 = {
    "articles": [
        "Web_scraping",
        "ChatGPT",
        "Artificial_intelligence"
    ],
    "project": "en.wikipedia",
    "startDate": "20260801",
    "endDate": "20260810",
    "access": "all-access",
    "agent": "user",
    "granularity": "daily"
};

// Run the Actor and wait for it to finish
const run = await client.actor("devilscrapes/wikipedia-pageviews-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 = {
    "articles": [
        "Web_scraping",
        "ChatGPT",
        "Artificial_intelligence",
    ],
    "project": "en.wikipedia",
    "startDate": "20260801",
    "endDate": "20260810",
    "access": "all-access",
    "agent": "user",
    "granularity": "daily",
}

# Run the Actor and wait for it to finish
run = client.actor("devilscrapes/wikipedia-pageviews-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 '{
  "articles": [
    "Web_scraping",
    "ChatGPT",
    "Artificial_intelligence"
  ],
  "project": "en.wikipedia",
  "startDate": "20260801",
  "endDate": "20260810",
  "access": "all-access",
  "agent": "user",
  "granularity": "daily"
}' |
apify call devilscrapes/wikipedia-pageviews-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,devilscrapes/wikipedia-pageviews-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/yAbYZhq4r21y9cLQw/builds/RTkTOBMvH5aozqYIt/openapi.json
