# Statistics Canada Web Data Service Scraper (`parseforge/statistics-canada-scraper`) Actor

Scrape Statistics Canada catalogue (NDM cubes), full cube metadata, and time-series data from the official StatCan Web Data Service (WDS). Pull cube titles, release dates, dimensions, members, geography, frequencies and recent observations for any of the 6000+ cubes.

- **URL**: https://apify.com/parseforge/statistics-canada-scraper.md
- **Developed by:** [ParseForge](https://apify.com/parseforge) (community)
- **Categories:** Business, Education, Automation
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, NaN bookmarks
- **User rating**: No ratings yet

## Pricing

from $26.62 / 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/platform/actors/running/actors-in-store#pay-per-event

## What's an Apify Actor?

Actors are a software tools running on the Apify platform, for all kinds of web data extraction and automation use cases.
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.

In JavaScript/TypeScript projects, use official [JavaScript/TypeScript client](https://docs.apify.com/api/client/js.md):

```bash
npm install apify-client
```

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python.md):

```bash
pip install apify-client
```

In shell scripts, use [Apify CLI](https://docs.apify.com/cli/docs.md):

````bash
# MacOS / Linux
curl -fsSL https://apify.com/install-cli.sh | bash
# Windows
irm https://apify.com/install-cli.ps1 | iex
```bash

In AI frameworks, you might use the [Apify MCP server](https://docs.apify.com/platform/integrations/mcp.md).

If your project is in a different language, use 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 Banner](https://github.com/ParseForge/apify-assets/blob/main/banners/banner-default.jpg?raw=true)

## 📊 Statistics Canada Scraper

> 🚀 **Export the official Canadian statistical catalogue in seconds.** Pull **8,000+ data cubes**, full cube metadata, dimension members, and time-series observations across the economy, labour market, health, and more. No sign-up needed, no manual CSV wrangling.

> 🕒 **Last updated:** 2026-05-15 · **📊 24 fields** per record · **📦 8,000+ cubes** · **🇨🇦 National + provincial + municipal coverage**

The **Statistics Canada Scraper** taps the official Statistics Canada catalogue and returns clean, structured records covering every published cube (NDM table). Pull cube titles in English and French, release dates, frequency, dimensions, member counts, geography codes, and time-stamped observation values.

The catalogue spans **8,000+ active cubes**, decades of historical data, and every Canadian province and territory. Subjects range from monthly Consumer Price Index releases and quarterly GDP to building permits, immigration flows, hospital activity, household spending, and election data. This Actor turns the entire reference catalogue, single-cube metadata, single-coordinate observations, and multi-vector time-series into downloadable CSV, Excel, JSON, or XML in minutes.

| 🎯 Target Audience | 💡 Primary Use Cases |
|---|---|
| Economists, journalists, policy analysts, fintech & real estate teams, researchers, BI engineers, civic-tech developers | Economic dashboards, inflation tracking, real estate market intelligence, labour-market reports, academic research, Power BI / Tableau feeds, ML feature engineering |

---

### 📋 What the Statistics Canada Scraper does

Four workflows in a single Actor:

- 📚 **Catalogue mode.** List every published Statistics Canada cube with title, frequency, release date, dimension names, and a deep link to the official table view.
- 🧾 **Cube metadata mode.** Pull the full schema for one cube or batch up to 100 cubes in a single run, including dimension positions, member counts, geography levels, classifications, and CANSIM legacy IDs.
- 📈 **Data from cube mode.** Fetch the latest N periods (up to 36) of observation values for any coordinate inside any cube.
- 📉 **Vector mode.** Pass one or many vector IDs and pull the most recent N periods of each time-series in one shot.

Every record carries the official Statistics Canada deep link, so you can verify any number against the source page in one click.

> 💡 **Why it matters:** Canadian economic and demographic data underpins lending decisions, real-estate underwriting, retail planning, public-policy research, and journalism. Building your own pipeline against the official catalogue means handling pagination, dimension decoding, and bilingual labels by hand. This Actor skips all of that and keeps your dataset fresh on every run.

---

### 🎬 Full Demo

_🚧 Coming soon: a 3-minute walkthrough showing how to go from sign-up to a downloaded dataset._

---

### ⚙️ Input

<table>
<thead>
<tr><th>Input</th><th>Type</th><th>Default</th><th>Behavior</th></tr>
</thead>
<tbody>
<tr><td><code>mode</code></td><td>enum</td><td><code>"catalogue"</code></td><td>One of <code>catalogue</code>, <code>cubeMetadata</code>, <code>dataFromCube</code>, <code>vector</code>.</td></tr>
<tr><td><code>productId</code></td><td>integer</td><td><code>34100007</code></td><td>8-digit cube product ID. Required for cubeMetadata and dataFromCube modes.</td></tr>
<tr><td><code>productIds</code></td><td>array</td><td><code>[]</code></td><td>Batch lookup for cubeMetadata mode. Up to 100 IDs per run. Takes precedence over <code>productId</code>.</td></tr>
<tr><td><code>coordinate</code></td><td>string</td><td><code>""</code></td><td>Comma-separated dimension positions (e.g. <code>"1.1.1.1.0.0.0.0.0.0"</code>). Required for dataFromCube mode.</td></tr>
<tr><td><code>vectorIds</code></td><td>string</td><td><code>""</code></td><td>Comma-separated vector IDs for vector mode (e.g. <code>"1,2,42"</code>).</td></tr>
<tr><td><code>latestN</code></td><td>integer</td><td><code>10</code></td><td>Number of most recent periods (1-36) for dataFromCube and vector modes.</td></tr>
<tr><td><code>maxItems</code></td><td>integer</td><td><code>10</code></td><td>Records to return. Free plan caps at 10, paid plan at 1,000,000.</td></tr>
</tbody>
</table>

**Example: full Statistics Canada catalogue (first 50 cubes).**

```json
{
    "mode": "catalogue",
    "maxItems": 50
}
````

**Example: latest 12 monthly Consumer Price Index periods for the Canada-wide all-items basket (cube 18-10-0004-01).**

```json
{
    "mode": "vector",
    "vectorIds": "41690973",
    "latestN": 12
}
```

> ⚠️ **Good to Know:** the catalogue contains every Statistics Canada cube including archived series. Use the `archived` field to filter out historical cubes, and the `frequencyCode` field (1=Daily, 6=Monthly, 9=Quarterly, 12=Annual) to filter by release cadence. Cube IDs (productIds) are 8 digits; vector IDs are integers tied to a specific coordinate inside a cube.

***

### 📊 Output

Each record contains up to **24 fields** depending on mode. Download the dataset as CSV, Excel, JSON, or XML.

#### 🧾 Schema

| Field | Type | Example |
|---|---|---|
| 🆔 `productId` | integer | `34100007` |
| 🔗 `url` | string | `"https://www150.statcan.gc.ca/t1/tbl1/en/tv.action?pid=34100007"` |
| 🏷️ `cansimId` | string | `"026-0006"` |
| 🇬🇧 `cubeTitleEn` | string | `"Building permits, by type of structure and type of work"` |
| 🇫🇷 `cubeTitleFr` | string | `"Permis de bâtir, selon le type de structure et le type de travaux"` |
| 📅 `cubeStartDate` | string | `"1948-01-01"` |
| 📅 `cubeEndDate` | string | `"2026-03-01"` |
| 🕒 `releaseTime` | string | `"2026-04-12T08:30"` |
| 📆 `issueDate` | string | `"2026-04-12"` |
| 🗃️ `archived` | string | `"2"` |
| 🏷️ `subjectCode` | array | `["18"]` |
| 📋 `surveyCode` | array | `["2802"]` |
| 🔁 `frequencyCode` | integer | `6` |
| 🔁 `frequency` | string | `"Monthly"` |
| 📐 `dimensions` | array | `[{ "id": 1, "nameEn": "Geography", "nameFr": "Géographie", "hasUOM": false }, ...]` |
| 📐 `dimensionNames` | string | `"Geography, Type of structure, Type of work"` |
| 📊 `nbSeriesCube` | integer | `2880` |
| 📊 `nbDatapointsCube` | integer | `1456320` |
| 🌎 `geoLevel` | array | `[{ "geoLevelEn": "Canada" }, ...]` |
| 📝 `correctionFootnote` | array | `[]` |
| 📋 `productNotice` | array | `[]` |
| 🔢 `vectorId` | integer | `41690973` |
| 📅 `refPeriod` | string | `"2026-04-01"` |
| 💰 `value` | number | `162.4` |
| 🔢 `decimals` | integer | `1` |
| 🕒 `scrapedAt` | ISO 8601 | `"2026-05-15T10:00:00.000Z"` |

#### 📦 Sample record (catalogue mode)

<details>
<summary><strong>📊 Building permits cube (productId 34100007)</strong></summary>

```json
{
    "productId": 34100007,
    "url": "https://www150.statcan.gc.ca/t1/tbl1/en/tv.action?pid=34100007",
    "cansimId": "026-0006",
    "cubeTitleEn": "Building permits, by type of structure and type of work",
    "cubeTitleFr": "Permis de bâtir, selon le type de structure et le type de travaux",
    "cubeStartDate": "1948-01-01",
    "cubeEndDate": "2026-03-01",
    "releaseTime": "2026-04-12T08:30",
    "issueDate": "2026-04-12",
    "archived": "2",
    "subjectCode": ["18"],
    "surveyCode": ["2802"],
    "frequencyCode": 6,
    "frequency": "Monthly",
    "dimensions": [
        { "id": 1, "nameEn": "Geography", "nameFr": "Géographie", "hasUOM": false },
        { "id": 2, "nameEn": "Type of structure", "nameFr": "Type de structure", "hasUOM": false },
        { "id": 3, "nameEn": "Type of work", "nameFr": "Type de travaux", "hasUOM": false }
    ],
    "dimensionNames": "Geography, Type of structure, Type of work",
    "scrapedAt": "2026-05-15T10:00:00.000Z"
}
```

</details>

<details>
<summary><strong>📈 Vector mode: monthly CPI (vector 41690973)</strong></summary>

```json
{
    "productId": 18100004,
    "vectorId": 41690973,
    "url": "https://www150.statcan.gc.ca/t1/tbl1/en/tv.action?pid=18100004",
    "refPeriod": "2026-04-01",
    "refPeriodRaw": "2026-04",
    "value": 162.4,
    "decimals": 1,
    "frequencyCode": 6,
    "scrapedAt": "2026-05-15T10:00:00.000Z"
}
```

</details>

***

### ✨ Why choose this Actor

| | Capability |
|---|---|
| 🇨🇦 | **Full national catalogue.** 8,000+ cubes covering economy, labour, health, justice, demographics, and more. |
| 🌐 | **Bilingual labels.** Titles, dimension names, and members in English and French. |
| 📈 | **Time-series mode.** Pull the latest 1-36 periods of any vector in a single call. |
| 🧾 | **Batch metadata.** Up to 100 cubes' full schemas in one run. |
| 🔁 | **Always fresh.** Every run pulls from the official catalogue, so the dataset reflects the latest releases. |
| 🧰 | **No setup.** No sign-up, no key, no scraping CSS selectors. |
| 🔗 | **Source-anchored.** Every record carries the official Statistics Canada deep link. |

> 📊 Statistics Canada is the most-cited reference for Canadian inflation, employment, GDP, immigration, and housing data. This Actor makes it queryable in seconds.

***

### 📈 How it compares to alternatives

| Approach | Cost | Coverage | Refresh | Filters | Setup |
|---|---|---|---|---|---|
| **⭐ Statistics Canada Scraper** *(this Actor)* | $5 free credit, then pay-per-use | **8,000+ cubes, decades of history** | **Live per run** | catalogue, cube, coordinate, vector | ⚡ 2 min |
| Manual CSV downloads | Free | Per-cube only | Manual | None | 🐢 Hours per cube |
| Commercial macro-data terminals | $24,000+/year | Curated subset | Live | Many | ⏳ Days |
| Build your own pipeline | Engineering hours | What you build | What you build | What you build | 🕒 Weeks |

Pick this Actor when you want broad national coverage, automated refreshes, and zero parser maintenance.

***

### 🚀 How to use

1. 📝 **Sign up.** [Create a free account with $5 credit](https://console.apify.com/sign-up?fpr=vmoqkp) (takes 2 minutes).
2. 🌐 **Open the Actor.** Go to the Statistics Canada Scraper page on the Apify Store.
3. 🎯 **Set input.** Pick a mode (start with `catalogue` to browse), set `maxItems`, and click Start.
4. 🚀 **Run it.** Click **Start** and let the Actor collect your data.
5. 📥 **Download.** Grab your results in the **Dataset** tab as CSV, Excel, JSON, or XML.

> ⏱️ Total time from signup to downloaded dataset: **3-5 minutes.** No coding required.

***

### 💼 Business use cases

<table>
<tr>
<td width="50%" valign="top">

#### 🏦 Banking, fintech, and lending

- Inflation and rate-sensitivity dashboards driven by monthly CPI vectors
- Mortgage underwriting fed by housing starts, building permits, and price indices
- Consumer-credit risk models that use household-debt cubes
- Macroeconomic forecasts for treasury and ALM teams

</td>
<td width="50%" valign="top">

#### 🏘️ Real estate and PropTech

- City-level building permit feeds for site-selection models
- Demographic shifts and migration flows by census subdivision
- Construction cost indices for development underwriting
- Vacancy, rents, and household-formation cubes

</td>
</tr>
<tr>
<td width="50%" valign="top">

#### 📊 Market research and consulting

- Industry sales, employment, and GDP-by-industry reports
- Retail trade, e-commerce, and food-services analytics
- Tourism, accommodation, and travel arrivals
- Sector benchmarks for client deliverables

</td>
<td width="50%" valign="top">

#### 📰 Journalism and policy

- Live charts of jobs, inflation, and immigration in newsrooms
- Public-policy briefs with cited, versioned data
- Election and demographic explainers
- Investigative reporting on housing, healthcare, and crime

</td>
</tr>
</table>

***

### 🔌 Automating Statistics Canada Scraper

Control the scraper programmatically for scheduled runs and pipeline integrations:

- 🟢 **Node.js.** Install the `apify-client` NPM package.
- 🐍 **Python.** Use the `apify-client` PyPI package.
- 📚 See the [Apify API documentation](https://docs.apify.com/api/v2) for full details.

The [Apify Schedules feature](https://docs.apify.com/platform/schedules) lets you trigger this Actor on any cron interval. Daily refreshes for high-frequency vectors (CPI, employment, building permits) keep dashboards current without engineering work.

***

### 🌟 Beyond business use cases

Data like this powers more than commercial workflows. The same structured records support research, education, civic projects, and personal initiatives.

<table>
<tr>
<td width="50%">

#### 🎓 Research and academia

- Macroeconomic theses with cited, versioned dataset pulls
- Health and demographic research at the provincial level
- Reproducible studies with stable cube product IDs
- Open-data exercises in econometrics courses

</td>
<td width="50%">

#### 🎨 Personal and creative

- Side projects, indie data dashboards, and portfolio demos
- Population pyramids, inflation trackers, and visualizations
- Interactive maps of Canadian municipalities
- Hobbyist time-series for traders and forecasters

</td>
</tr>
<tr>
<td width="50%">

#### 🤝 Non-profit and civic

- Equity research on income, housing, and labour outcomes
- Civic transparency on public spending and services
- Investigative journalism backed by official numbers
- Open data community contributions and visualizations

</td>
<td width="50%">

#### 🧪 Experimentation

- Train forecasting and anomaly-detection ML models
- Validate macro hypotheses with real time-series
- Prototype agent pipelines that resolve cube IDs
- Test BI dashboard concepts with live national data

</td>
</tr>
</table>

***

### 🤖 Ask an AI assistant about this scraper

Open a ready-to-send prompt about this ParseForge actor in the AI of your choice:

- 💬 [**ChatGPT**](https://chat.openai.com/?q=How%20do%20I%20use%20the%20Statistics%20Canada%20Scraper%20by%20ParseForge%20on%20Apify%3F%20Show%20me%20input%20examples%2C%20output%20fields%2C%20common%20use%20cases%2C%20and%20how%20to%20integrate%20it%20into%20a%20workflow.)
- 🧠 [**Claude**](https://claude.ai/new?q=How%20do%20I%20use%20the%20Statistics%20Canada%20Scraper%20by%20ParseForge%20on%20Apify%3F%20Show%20me%20input%20examples%2C%20output%20fields%2C%20common%20use%20cases%2C%20and%20how%20to%20integrate%20it%20into%20a%20workflow.)
- 🔍 [**Perplexity**](https://perplexity.ai/search?q=How%20do%20I%20use%20the%20Statistics%20Canada%20Scraper%20by%20ParseForge%20on%20Apify%3F%20Show%20me%20input%20examples%2C%20output%20fields%2C%20common%20use%20cases%2C%20and%20how%20to%20integrate%20it%20into%20a%20workflow.)
- 🅒 [**Copilot**](https://copilot.microsoft.com/?q=How%20do%20I%20use%20the%20Statistics%20Canada%20Scraper%20by%20ParseForge%20on%20Apify%3F%20Show%20me%20input%20examples%2C%20output%20fields%2C%20common%20use%20cases%2C%20and%20how%20to%20integrate%20it%20into%20a%20workflow.)

***

### ❓ Frequently Asked Questions

#### 🧩 How does it work?

Pick a mode (catalogue, cube metadata, data from cube, or vector), set the cube product ID or vector IDs, and click Start. The Actor pulls clean structured records straight from the official catalogue. No browser automation, no captchas, no setup.

#### 📏 How accurate is the data?

Every value comes directly from the official Statistics Canada catalogue, the canonical source for Canadian official statistics. No transformation is applied beyond field-name normalization and ISO timestamp stamping.

#### 🔁 How often is the catalogue refreshed?

The catalogue is updated continuously as Statistics Canada releases new cubes and revises existing ones. Every run of this Actor returns the live state of the catalogue.

#### 🌐 Are labels available in French?

Yes. Catalogue and metadata records include `cubeTitleEn` and `cubeTitleFr`, plus dimension and member names in both languages where Statistics Canada publishes them.

#### ⏰ Can I schedule regular runs?

Yes. Use Apify Schedules to run this Actor on any cron interval (hourly, daily, weekly) and keep your downstream database in sync with the latest CPI, employment, GDP, and other high-frequency releases.

#### ⚖️ Is this data legal to use?

Statistics Canada publishes under the Statistics Canada Open Licence, which permits commercial and non-commercial use with attribution. Review the licence terms for your specific use case.

#### 💼 Can I use this data commercially?

Yes. The underlying data is open and permits commercial use with attribution. You are responsible for complying with the licence and with any downstream regulatory requirements in your own product.

#### 💳 Do I need a paid Apify plan to use this Actor?

No. The free Apify plan is enough for testing and small runs (10 records per run). A paid plan lifts the limit and gives you access to scheduling, higher concurrency, and larger datasets.

#### 🔁 What happens if a run fails or gets interrupted?

Apify automatically retries transient errors. If a run still fails, you can inspect the log in the Runs tab, fix the input, and re-run. Partial datasets from failed runs are preserved so you never lose progress.

#### 🔢 What is a productId vs a vectorId?

A **productId** is an 8-digit cube ID (e.g. `34100007` = Building permits). A **vectorId** is an integer pointing to a single time-series at one coordinate inside a cube. Use catalogue or cube metadata mode to discover IDs.

#### 🆘 What if I need help?

Our support team is here to help. Contact us through the Apify platform or use the Tally form linked below.

***

### 🔌 Integrate with any app

Statistics Canada Scraper connects to any cloud service via [Apify integrations](https://apify.com/integrations):

- [**Make**](https://docs.apify.com/platform/integrations/make) - Automate multi-step workflows
- [**Zapier**](https://docs.apify.com/platform/integrations/zapier) - Connect with 5,000+ apps
- [**Slack**](https://docs.apify.com/platform/integrations/slack) - Get run notifications in your channels
- [**Airbyte**](https://docs.apify.com/platform/integrations/airbyte) - Pipe Statistics Canada records into your warehouse
- [**n8n**](https://n8n.io) - Self-hosted workflow automation
- [**Pipedream**](https://pipedream.com) - Event-driven serverless workflows
- [**GitHub**](https://docs.apify.com/platform/integrations/github) - Trigger runs from commits and releases
- [**Google Drive**](https://docs.apify.com/platform/integrations/drive) - Export datasets straight to Sheets

You can also use webhooks to trigger downstream actions when a run finishes. Push fresh CPI, employment, or housing numbers into your product backend, or alert your team in Slack the minute a new release lands.

***

### 🔗 Recommended Actors

- [**📊 ONS UK Statistics Scraper**](https://apify.com/parseforge/ons-uk-scraper) - UK Office for National Statistics datasets
- [**📊 INE Spain Scraper**](https://apify.com/parseforge/ine-spain-scraper) - Spanish National Statistics Institute
- [**📊 IBGE Brazil Scraper**](https://apify.com/parseforge/ibge-brazil-scraper) - Brazilian Institute of Geography and Statistics
- [**📈 Indexmundi Scraper**](https://apify.com/parseforge/indexmundi-scraper) - Global demographic and economic indicators
- [**🗺️ Nominatim OSM Scraper**](https://apify.com/parseforge/nominatim-osm-scraper) - Geocode addresses via OpenStreetMap

> 💡 **Pro Tip:** browse the complete [ParseForge collection](https://apify.com/parseforge) for more reference-data scrapers.

***

**🆘 Need Help?** [**Open our contact form**](https://tally.so/r/BzdKgA) to request a new scraper, propose a custom data project, or report an issue.

***

> **⚠️ Disclaimer:** this Actor is an independent tool and is not affiliated with, endorsed by, or sponsored by Statistics Canada or the Government of Canada. All trademarks mentioned are the property of their respective owners. Only publicly available open data is collected.

# Actor input Schema

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

What to fetch from Statistics Canada: full catalogue of cubes, single cube metadata, recent observations for a coordinate, or time-series for one or more vectors.

## `productId` (type: `integer`):

8-digit Statistics Canada cube product ID (e.g. 34100007 = Building permits). Required for cubeMetadata and dataFromCube modes.

## `productIds` (type: `array`):

Array of 8-digit Statistics Canada productIds to fetch in one run (cubeMetadata mode). Takes precedence over single productId. Max 100 per call. Items can be integers or numeric strings.

## `coordinate` (type: `string`):

Comma-separated dimension position values, e.g. '1.1.1.1.0.0.0.0.0.0'. Required for dataFromCube mode. Use '0' for unused trailing dimensions.

## `vectorIds` (type: `string`):

Comma-separated Statistics Canada vector IDs for vector mode (e.g. '1,2,42'). Each vector returns the latest N periods of its time-series.

## `latestN` (type: `integer`):

Number of most recent periods to fetch in dataFromCube mode.

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

Free users: Limited to 10 items (preview). Paid users: Optional, max 1,000,000

## Actor input object example

```json
{
  "mode": "catalogue",
  "productId": 34100007,
  "productIds": [],
  "latestN": 10,
  "maxItems": 10
}
```

# Actor output Schema

## `overview` (type: `string`):

Overview of scraped data

## `fullData` (type: `string`):

Complete dataset

# 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": "catalogue",
    "productId": 34100007,
    "latestN": 10,
    "maxItems": 10
};

// Run the Actor and wait for it to finish
const run = await client.actor("parseforge/statistics-canada-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 = {
    "mode": "catalogue",
    "productId": 34100007,
    "latestN": 10,
    "maxItems": 10,
}

# Run the Actor and wait for it to finish
run = client.actor("parseforge/statistics-canada-scraper").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
for item in client.dataset(run["defaultDatasetId"]).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": "catalogue",
  "productId": 34100007,
  "latestN": 10,
  "maxItems": 10
}' |
apify call parseforge/statistics-canada-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=parseforge/statistics-canada-scraper",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "Statistics Canada Web Data Service Scraper",
        "description": "Scrape Statistics Canada catalogue (NDM cubes), full cube metadata, and time-series data from the official StatCan Web Data Service (WDS). Pull cube titles, release dates, dimensions, members, geography, frequencies and recent observations for any of the 6000+ cubes.",
        "version": "0.0",
        "x-build-id": "cnXqvYMDt67LCLoMP"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/parseforge~statistics-canada-scraper/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-parseforge-statistics-canada-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/acts/parseforge~statistics-canada-scraper/runs": {
            "post": {
                "operationId": "runs-sync-parseforge-statistics-canada-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor and returns information about the initiated run in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/runsResponseSchema"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/acts/parseforge~statistics-canada-scraper/run-sync": {
            "post": {
                "operationId": "run-sync-parseforge-statistics-canada-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "inputSchema": {
                "type": "object",
                "properties": {
                    "mode": {
                        "title": "Mode",
                        "enum": [
                            "catalogue",
                            "cubeMetadata",
                            "dataFromCube",
                            "vector"
                        ],
                        "type": "string",
                        "description": "What to fetch from Statistics Canada: full catalogue of cubes, single cube metadata, recent observations for a coordinate, or time-series for one or more vectors.",
                        "default": "catalogue"
                    },
                    "productId": {
                        "title": "Product ID",
                        "type": "integer",
                        "description": "8-digit Statistics Canada cube product ID (e.g. 34100007 = Building permits). Required for cubeMetadata and dataFromCube modes."
                    },
                    "productIds": {
                        "title": "Product IDs (batch lookup, cubeMetadata mode)",
                        "type": "array",
                        "description": "Array of 8-digit Statistics Canada productIds to fetch in one run (cubeMetadata mode). Takes precedence over single productId. Max 100 per call. Items can be integers or numeric strings.",
                        "default": []
                    },
                    "coordinate": {
                        "title": "Coordinate",
                        "type": "string",
                        "description": "Comma-separated dimension position values, e.g. '1.1.1.1.0.0.0.0.0.0'. Required for dataFromCube mode. Use '0' for unused trailing dimensions."
                    },
                    "vectorIds": {
                        "title": "Vector IDs",
                        "type": "string",
                        "description": "Comma-separated Statistics Canada vector IDs for vector mode (e.g. '1,2,42'). Each vector returns the latest N periods of its time-series."
                    },
                    "latestN": {
                        "title": "Latest N periods",
                        "minimum": 1,
                        "maximum": 36,
                        "type": "integer",
                        "description": "Number of most recent periods to fetch in dataFromCube mode.",
                        "default": 10
                    },
                    "maxItems": {
                        "title": "Max Items",
                        "minimum": 1,
                        "maximum": 1000000,
                        "type": "integer",
                        "description": "Free users: Limited to 10 items (preview). Paid users: Optional, max 1,000,000"
                    }
                }
            },
            "runsResponseSchema": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "actId": {
                                "type": "string"
                            },
                            "userId": {
                                "type": "string"
                            },
                            "startedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "finishedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "status": {
                                "type": "string",
                                "example": "READY"
                            },
                            "meta": {
                                "type": "object",
                                "properties": {
                                    "origin": {
                                        "type": "string",
                                        "example": "API"
                                    },
                                    "userAgent": {
                                        "type": "string"
                                    }
                                }
                            },
                            "stats": {
                                "type": "object",
                                "properties": {
                                    "inputBodyLen": {
                                        "type": "integer",
                                        "example": 2000
                                    },
                                    "rebootCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "restartCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "resurrectCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "computeUnits": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "options": {
                                "type": "object",
                                "properties": {
                                    "build": {
                                        "type": "string",
                                        "example": "latest"
                                    },
                                    "timeoutSecs": {
                                        "type": "integer",
                                        "example": 300
                                    },
                                    "memoryMbytes": {
                                        "type": "integer",
                                        "example": 1024
                                    },
                                    "diskMbytes": {
                                        "type": "integer",
                                        "example": 2048
                                    }
                                }
                            },
                            "buildId": {
                                "type": "string"
                            },
                            "defaultKeyValueStoreId": {
                                "type": "string"
                            },
                            "defaultDatasetId": {
                                "type": "string"
                            },
                            "defaultRequestQueueId": {
                                "type": "string"
                            },
                            "buildNumber": {
                                "type": "string",
                                "example": "1.0.0"
                            },
                            "containerUrl": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "usageTotalUsd": {
                                "type": "number",
                                "example": 0.00005
                            },
                            "usageUsd": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "number",
                                        "example": 0.00005
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
