# Canada Open Data Catalog Scraper (`muhammadafzal/canada-open-data-catalog-scraper`) Actor

Search Canada’s official open data catalog. Export bilingual dataset titles, publishers, licenses, dates, formats, resource links, and metadata.

- **URL**: https://apify.com/muhammadafzal/canada-open-data-catalog-scraper.md
- **Developed by:** [Muhammad Afzal](https://apify.com/muhammadafzal) (community)
- **Categories:** Other, Developer tools, Integrations
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $15.00 / 1,000 canada dataset records

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

## Canada Open Data Catalog Scraper

> **Free-plan limit:** Apify free-plan runs can return at most **5 dataset records per run** from this Actor, even if you request more.

Search the official Canada Open Government catalog and export bilingual dataset metadata, publisher details, licenses, topics, resource formats, and download URLs for research, discovery, data inventories, and monitoring.

This Actor reads the Government of Canada's public CKAN catalog directly. It does not download the attached datasets themselves; each output item describes one catalog dataset and, when enabled, includes its resource links.

### What it extracts

| Field | Description |
|---|---|
| `datasetId`, `catalogUrl`, `apiUrl` | Stable UUID and official catalog/API links |
| `title`, `titleEn`, `titleFr` | Selected-language and bilingual titles |
| `description`, `descriptionEn`, `descriptionFr` | Selected-language and bilingual descriptions |
| `publisher`, `publisherSlug` | Publishing government organization |
| `subjects`, `keywords*`, `collection`, `datasetType` | Search and taxonomy metadata |
| `licenseId`, `licenseTitle`, `licenseUrl` | Reuse-license metadata |
| `datePublished`, `metadataCreated`, `metadataModified` | Catalog dates and timestamps |
| `resourceFormats`, `resourceCount` | Available formats and resource total |
| `resources` | File/service IDs, names, URLs, formats, languages, size, and DataStore status |

### When to use it

Use this Actor to discover Canadian public datasets, build a data catalog, monitor newly modified records, find downloadable CSV/JSON/GeoJSON resources, or feed structured catalog metadata into an AI agent. It is not a file-content scraper, geocoder, or authenticated government registry client.

### Input

| Input | Default | Description |
|---|---:|---|
| `query` | `climate change` | Keyword or CKAN search expression. Set to an empty string only when using exact IDs. |
| `datasetIds` | `[]` | Exact dataset UUIDs to retrieve in addition to search results. |
| `language` | `en` | `en` or `fr` for the selected-language fields and links. |
| `organization` | empty | Case-insensitive publisher name or organization-slug filter. |
| `resourceFormats` | `[]` | Keep datasets with at least one listed format, such as `CSV` or `JSON`. |
| `modifiedAfter` | empty | ISO date/timestamp lower bound, such as `2025-01-01`. |
| `sortBy` | `relevance` | `relevance`, `modified_desc`, `modified_asc`, or `title_asc`. |
| `includeResources` | `true` | Include resource-level download metadata. |
| `maxResults` | `20` | Maximum records and result events, from 1 to 10,000. |

Keyword search:

```json
{
  "query": "wildfire",
  "language": "en",
  "resourceFormats": ["CSV", "JSON"],
  "modifiedAfter": "2024-01-01",
  "sortBy": "modified_desc",
  "maxResults": 100
}
```

Exact dataset lookup:

```json
{
  "query": "",
  "datasetIds": ["2d90548d-50ef-4802-91f8-c59c5cf68251"],
  "language": "fr",
  "maxResults": 1
}
```

Run through the Apify API:

```bash
curl -X POST "https://api.apify.com/v2/acts/YOUR_ACTOR_ID/runs?token=YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"query":"housing","maxResults":10}'
```

For production integrations, send the Apify token in an authorization header instead of a URL.

### Output example

```json
{
  "datasetId": "09ffaeb5-ec8f-5bb5-bdcb-3436ccf26f58",
  "title": "Climatic Regions",
  "titleEn": "Climatic Regions",
  "titleFr": "Régions climatiques",
  "publisher": "Natural Resources Canada | Ressources naturelles Canada",
  "publisherSlug": "nrcan-rncan",
  "subjects": ["nature_and_environment", "science_and_technology"],
  "keywords": ["climate", "meteorological data", "meteorology", "weather"],
  "licenseId": "ca-ogl-lgo",
  "licenseTitle": "Open Government Licence - Canada",
  "metadataModified": "2022-03-14T19:51:11.728358",
  "resourceCount": 4,
  "resourceFormats": ["JPG", "PDF"],
  "catalogUrl": "https://open.canada.ca/data/en/dataset/09ffaeb5-ec8f-5bb5-bdcb-3436ccf26f58",
  "resources": [
    {
      "resourceId": "4ec05161-60d1-4fc9-9e7c-487798c19b82",
      "name": "Download the English JPG through HTTP",
      "format": "JPG",
      "url": "https://ftp.geogratis.gc.ca/pub/nrcan_rncan/raster/atlas_3_ed/eng/environment/climate/030.jpg",
      "language": ["en", "fr"],
      "sizeBytes": 1134541,
      "dataStoreActive": false,
      "lastModified": "2017-01-26T11:25:44.012952"
    }
  ]
}
```

The default dataset contains homogeneous dataset records. The `OUTPUT` key-value-store record contains the run outcome (`DATA`, `EMPTY`, `REJECTED`, or `FAILED`), counts, source URL, warnings, and completion time.

### Pricing

This Actor uses **pay-per-event** pricing. These are the current Apify Store event prices:

| Event | Price (USD) | When it is charged |
|---|---:|---|
| `apify-default-dataset-item` | FREE: $0.02; BRONZE: $0.019; SILVER: $0.018; GOLD: $0.015; PLATINUM: $0.015; DIAMOND: $0.015 | Canada dataset record — One validated Canada Open Government catalog dataset record written to the default dataset. |
| `apify-actor-start` | $0.005 | Actor Start — Charged when the Actor starts running. Number of events charged depends on Actor memory (one event per GB, minimum one event). — Charged once per run. |

Apify platform usage for this Actor run is included alongside the event prices above; no separate per-run platform-usage fee is passed to users.

This covers Apify platform usage for this Actor run. Other Apify products or usage outside this Actor run may still follow your account plan.

### Reliability and limits

- Uses the official, unauthenticated Canada Open Government CKAN GET API.
- Retries bounded `429`, server, timeout, and network failures; no proxy is normally required.
- Deduplicates exact-ID and search overlap by dataset UUID before writing.
- Scans up to 10× `maxResults` (minimum 500, maximum 10,000) when client-side filters are active. Narrow broad searches when filters leave too few results.
- Valid no-match searches finish with an `EMPTY` summary and zero dataset-item charges.
- Invalid UUIDs, dates, or missing search modes are rejected before result work with an actionable terminal message.
- Source records occasionally omit translations, licenses, dates, or resource sizes; nullable output fields represent those omissions truthfully.

### Legal and compliance

The Actor only reads public catalog metadata and resource links. Review each dataset's stated license, restrictions, attribution terms, privacy considerations, and downstream resource conditions before reuse. Avoid using public data to profile people or make high-impact decisions without appropriate legal and ethical review.

### Support

If a catalog field changes or a valid query produces unexpected output, share the Actor run ID and redacted input through the Actor issue/support channel. Do not include Apify tokens or private data.

# Actor input Schema

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

Use this for keyword or CKAN search syntax, for example `climate change`. Leave empty only when datasetIds are supplied. Defaults to `climate change` in the prefill.

## `datasetIds` (type: `array`):

Use this to fetch exact Open Government dataset UUIDs, for example `2d90548d-50ef-4802-91f8-c59c5cf68251`. When set, these are fetched in addition to search results.

## `language` (type: `string`):

Use this to select English or French titles, descriptions, keywords, and catalog URLs. Bilingual fields remain available. Default is English.

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

Use this to keep records whose organization slug or bilingual publisher name contains the text, for example `nrcan-rncan` or `Natural Resources Canada`. Matching is case-insensitive.

## `resourceFormats` (type: `array`):

Use this to keep datasets with at least one matching resource format, for example `CSV`, `JSON`, or `GeoJSON`. Values are case-insensitive; empty means all formats.

## `modifiedAfter` (type: `string`):

Use this to keep datasets modified on or after an ISO date or timestamp, for example `2025-01-01`. Empty means no modified-date filter.

## `sortBy` (type: `string`):

Use this to order keyword search results by relevance, newest modification time, oldest modification time, or title. Exact dataset IDs preserve the supplied order.

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

Use this to include each dataset's files, formats, download URLs, sizes, and DataStore status. Disable for smaller output records. Default is enabled.

## `maxResults` (type: `integer`):

Use this to cap delivered dataset records and PPE result events. Accepts 1–10,000; default is 20. Exact-ID and search results share this cap.

## Actor input object example

```json
{
  "query": "climate change",
  "datasetIds": [],
  "language": "en",
  "organization": "",
  "resourceFormats": [],
  "modifiedAfter": "",
  "sortBy": "relevance",
  "includeResources": true,
  "maxResults": 20
}
```

# Actor output Schema

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

Schema-validated Canada Open Government dataset records.

## `summary` (type: `string`):

Counts, outcome classification, warnings, and source information.

# 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 = {
    "query": "climate change"
};

// Run the Actor and wait for it to finish
const run = await client.actor("muhammadafzal/canada-open-data-catalog-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 = { "query": "climate change" }

# Run the Actor and wait for it to finish
run = client.actor("muhammadafzal/canada-open-data-catalog-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 '{
  "query": "climate change"
}' |
apify call muhammadafzal/canada-open-data-catalog-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,muhammadafzal/canada-open-data-catalog-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/sn15a5Bpd1nMKfpU1/builds/4j2JskC060J2QkJCD/openapi.json
