# Open Canada Dataset Scraper (`bigibyte/open-canada-dataset-scraper`) Actor

Search the Government of Canada open data catalogue on open.canada.ca and pull dataset records or the files attached to them. Filter by topic or department, pick dataset or file-resource rows, and export to JSON, CSV, or Excel. Uses the public CKAN Data with paging, retries, and duplicate skipping.

- **URL**: https://apify.com/bigibyte/open-canada-dataset-scraper.md
- **Developed by:** [BigiByte](https://apify.com/bigibyte) (community)
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per usage

This Actor is paid per platform usage. The Actor is free to use, and you only pay for the Apify platform usage, which gets cheaper the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-usage

## 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

## Open Canada Dataset Scraper: open.canada.ca open data

<p align="center">
  <img src="https://imgur.com/bKiy7lL.png" alt="Open Canada Dataset Scraper" style="max-width:100%; border-radius:14px; width:680px;" />
</p>

Search the Government of Canada open data catalogue and pull dataset records or the files attached to them. Results land in an Apify dataset you can export as JSON, CSV, or Excel.

### Use cases

- **Catalogue research**: search open Canada datasets for a topic such as health and keep the metadata in one table
- **File inventory**: switch to resources mode and list CSV, HTML, and other files attached to each dataset
- **Department filters**: limit a run to one department or organization, for example phac-aspc
- **Scheduled refresh**: rerun the same query and export the dataset when the catalogue changes
- **Licence check**: read license_id, license_title, and license_url on each row before you reuse a file

### What data does this actor extract?

Search mode writes one row per dataset. Resources mode writes one row per file resource and keeps the parent dataset fields on that row. Nested bilingual objects stay as returned. The dataset title is stored as `itemTitle`, the record kind as `recordKind`, and a file's format label as `resourceFormat`.

### Input

| Parameter | Type | Default | Description |
|-----------|------|---------|-------------|
| `mode` | string | `search` | `search` for datasets, `resources` for one row per file |
| `query` | string | `health` | Search text used to match datasets |
| `organization` | string | empty | Organization name used to narrow results, such as phac-aspc |
| `includeResources` | boolean | `true` | In search mode, attach the file list on each dataset row |
| `maxItems` | integer | `100` | Cap on rows saved. Hard maximum 1000 |
| `timeoutSecs` | integer | `300` | Stop the run after this many seconds |
| `requestTimeoutSecs` | integer | `30` | How long to wait for each response, in seconds |
| `proxyConfiguration` | object | `{"useApifyProxy": false}` | Optional proxy. Leave off unless a direct connection fails |

#### Example input

```json
{
    "mode": "search",
    "query": "health",
    "organization": "",
    "includeResources": true,
    "maxItems": 100,
    "timeoutSecs": 300,
    "requestTimeoutSecs": 30,
    "proxyConfiguration": { "useApifyProxy": false }
}
```

### Output

```json
{
    "id": "21d8ef00-a5e3-4e49-ae96-2b61b90a4dda",
    "itemTitle": "Preconception health: health before pregnancy",
    "collection": "publication",
    "jurisdiction": "federal",
    "license_id": "ca-ogl-lgo",
    "license_title": "Open Government Licence - Canada",
    "license_url": "https://open.canada.ca/en/open-government-licence-canada",
    "date_published": "2019-11-27 00:00:00",
    "keywords": {
        "en": ["Preconception health", "Fertility", "Pregnancy", "Reproductive life plan"],
        "fr": []
    },
    "isopen": false,
    "scrapedAt": "2026-10-12T00:00:00+00:00"
}
```

| Field | Type | Description |
|-------|------|-------------|
| `id` | string | Dataset id in search mode, file id in resources mode. Used to skip duplicates |
| `itemTitle` | string | Dataset title from the catalogue |
| `collection` | string | Collection label such as publication or primary |
| `license_id` | string | Licence id from the dataset |
| `license_title` | string | Licence title from the dataset |
| `license_url` | string | Link to the licence |
| `keywords` | object | Bilingual keyword lists |
| `resourceUrl` | string | File or page URL, resources mode only |
| `resourceFormat` | string | Format label such as CSV or HTML, resources mode only |
| `scrapedAt` | string | UTC time the row was saved |
| `error` | string | Set only when a row cannot be produced. The run continues instead of crashing |

Other catalogue fields are copied when they are present: `additional_notes`, `audience`, `author`, `author_email`, `contributor`, `creator`, `creator_user_id`, `data_series_issue_identification`, `data_series_name`, `date_modified`, `date_published`, `departmental_identification_number`, `digital_object_identifier`, `edition`, `frequency`, `gc_catalogue_number`, `geographic_region`, `imso_approval`, `isbn`, `isopen`, `issn`, `issuance`, `issuance_frequency`, and `jurisdiction`.

### Limits

`maxItems` caps how many rows a run saves and cannot exceed 1000. `timeoutSecs` stops the run after the set number of seconds and defaults to 300. Rows already saved stay in the dataset when the timeout is reached.

### Related tools

If you plan to join or analyse these rows, a quick CSV cleanup or a de-duplication pass are the usual next steps. BigiByte also builds scrapers for other open-data catalogues when you need them as a separate job.

Need another national or provincial open-data catalogue, a scheduled monitor, or a custom pipeline? BigiByte builds custom scrapers and data tools: https://bigibyte.com

### FAQ

**What is the difference between search and resources?**
Search saves one row per dataset. Resources saves one row per file on those datasets, with `resourceUrl` and `resourceFormat` filled in.

**How many rows can one run save?**
`maxItems` defaults to 100 and will not go past 1000. Raise it when you need a wider slice, or schedule a narrower query.

**Can I export to CSV, JSON, or Excel?**
Yes. The default dataset export covers those formats. Schedule the actor if you want a fresh export later.

#### Trademark notice

Open Canada Dataset and related names, logos, and trademarks belong to their respective owners. Their use in this documentation is solely to identify the source of the data and does not imply affiliation, sponsorship, endorsement, or partnership.

#### Disclaimer

Disclaimer: This Actor is an independent tool and is not affiliated with, endorsed by, sponsored by, or otherwise officially associated with Open Canada Dataset or its owners. All data is collected from publicly available sources. Users are responsible for complying with the source's terms of use, rate limits, and attribution or licensing requirements.

#### Is web scraping legal?

This Actor only collects publicly available data from Open Canada Dataset, without bypassing any access controls. Scraping public data is generally legal, but how you use it matters:

- **Personal data:** If the results include personal data (for example names, emails, or profile details), laws such as the GDPR in the EU and the CCPA in California may apply. Only collect and store personal data when you have a legitimate reason.
- **Copyright:** Some content (articles, images, descriptions) may be protected by copyright. Do not republish full copyrighted content without permission.
- **Terms of use:** Respect the source terms, stated rate limits, and any attribution requirements in the Open Government Licence.
- **Legal advice:** This is general information, not legal advice. If you're unsure, consult a lawyer.

To learn more, read Apify's guide: [Is web scraping legal?](https://blog.apify.com/is-web-scraping-legal/)

# Actor input Schema

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

search returns one row per dataset. resources returns one row per file attached to those datasets.

## `query` (type: `string`):

Text passed to the CKAN package_search q parameter. Example: health.

## `organization` (type: `string`):

Optional CKAN organization name used as an fq filter, such as phac-aspc. Leave empty to search every organization.

## `includeResources` (type: `boolean`):

In search mode, attach the dataset file list on each row. Ignored in resources mode, which already emits one row per file.

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

Maximum dataset or resource rows to save. Values above 1000 are clamped to 1000.

## `timeoutSecs` (type: `integer`):

Stop fetching when this many seconds have passed. Already saved rows stay in the dataset.

## `requestTimeoutSecs` (type: `integer`):

Seconds to wait for each CKAN HTTP response before retrying.

## `proxyConfiguration` (type: `object`):

Optional proxy for CKAN requests. Default is no proxy. The public API does not require one.

## Actor input object example

```json
{
  "mode": "search",
  "query": "health",
  "organization": "phac-aspc",
  "includeResources": true,
  "maxItems": 100,
  "timeoutSecs": 300,
  "requestTimeoutSecs": 30,
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}
```

# Actor output Schema

## `datasetUrl` (type: `string`):

Link to the default dataset for this run.

## `datasetItemsUrl` (type: `string`):

JSON items from the default 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": "search",
    "query": "health",
    "proxyConfiguration": {
        "useApifyProxy": false
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("bigibyte/open-canada-dataset-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": "search",
    "query": "health",
    "proxyConfiguration": { "useApifyProxy": False },
}

# Run the Actor and wait for it to finish
run = client.actor("bigibyte/open-canada-dataset-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 '{
  "mode": "search",
  "query": "health",
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}' |
apify call bigibyte/open-canada-dataset-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,bigibyte/open-canada-dataset-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/JJtdRfDCrnOcFdqEk/builds/aMzC2RbvpcXndYPnI/openapi.json
