# CKAN Open Data Portal Scraper (`anyxsolutions/ckan-datasets-scraper`) Actor

Scrape datasets from CKAN open-data portals such as Canada, California, Germany or Italy by search link, organization, dataset or keyword: titles, descriptions, publishers, tags, licences, maintainers, dates and every resource with format, size and download link.

- **URL**: https://apify.com/anyxsolutions/ckan-datasets-scraper.md
- **Developed by:** [Anyx Solutions](https://apify.com/anyxsolutions) (community)
- **Categories:** Developer tools, Business
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.70 / 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/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

![banner](https://anyx.solutions/banners/ckan-datasets-scraper.png)

## CKAN Open Data Portal Scraper

**Datasets from CKAN open-data portals, with publishers, tags, licences, dates and every resource with its format, size and download link, as clean JSON.**

CKAN is the open-source platform behind many government and city open-data portals, such as
Canada's open.canada.ca, South Australia's data.sa.gov.au, Zurich's data.stadt-zuerich.ch,
Italy's dati.gov.it and Latvia's data.gov.lv. This Actor scrapes any CKAN portal by dataset search
link, organization, group, dataset, or by keyword. Get each dataset's title, description, publisher
organization, tags, groups, licence, author and maintainer contacts, version, creation and
modification dates, and every resource (file, API or link) with its format, size, dates and
download link. There is no login and no proxy to configure. Built for open-data aggregation and
monitoring, data discovery for analysts and journalists, government transparency research, and
feeding public data catalogues into search, RAG and BI pipelines.

### ⚡ Quick start

```json
{
  "startUrls": [
    { "url": "https://open.canada.ca/data/en/dataset?q=water%20quality" }
  ],
  "maxItems": 5
}
```

Or pick a portal and search it by keyword, most recently modified first:

```json
{
  "portalUrl": "https://data.sa.gov.au/data",
  "searchTerms": ["road", "public transport"],
  "sortBy": "lastModified",
  "maxItems": 100
}
```

Or every dataset of one organization:

```json
{
  "startUrls": [
    { "url": "https://data.stadt-zuerich.ch/organization/stadt-zurich" }
  ],
  "maxItems": 1000
}
```

### 🧩 Input

| Field                | Type    | Required | Default                      | Description                                                                                                                                                                                                                                                     |
| -------------------- | ------- | -------- | ---------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `startUrls`          | array   | no       | —                            | Pages of a CKAN portal: a dataset search with its filters (`…/dataset?q=…&organization=…&tags=…&res_format=…`), a dataset (`…/dataset/<name>`), an organization (`…/organization/<name>`), a group (`…/group/<name>`), or a portal home page for every dataset. |
| `portalUrl`          | string  | no       | —                            | Home page of a CKAN portal to search with the search terms, such as `https://open.canada.ca/data`. With no search terms, every dataset of the portal is returned.                                                                                               |
| `searchTerms`        | array   | no       | —                            | Keywords to search the portal for, one search per line. CKAN search syntax works too, such as `res_format:CSV`.                                                                                                                                                 |
| `sortBy`             | string  | no       | `"relevance"`                | Order of the search-term results: `relevance` (best match), `lastModified`, `newest` or `name` (A to Z).                                                                                                                                                        |
| `maxItems`           | integer | no       | —                            | Maximum number of datasets per start URL or search term. The input form starts at 5; leave it empty to get every match.                                                                                                                                         |
| `proxyConfiguration` | object  | no       | `{ "useApifyProxy": false }` | Proxy settings. CKAN portals need no proxy.                                                                                                                                                                                                                     |

Add at least one start URL, or a portal URL. `searchTerms` and `sortBy` need `portalUrl`; start
URLs keep the search, filters and sort set in them.

**Search links.** Search the portal's dataset page, tick the filters you want (organization, tags,
formats, licence, groups or the portal's own facets) and copy the address bar into `startUrls`.
Pages behind a language segment, such as `/en/dataset` or `/de/dataset`, work too.

**Which portals work.** Any portal running CKAN whose robots.txt lets crawlers use its data API,
for example open.canada.ca/data, data.sa.gov.au/data, data.stadt-zuerich.ch, dati.gov.it/opendata
and data.gov.lv/dati. Many portals keep CKAN's default robots.txt, which closes the data API to
crawlers; the Actor respects that and says so in its log. A link to a site that does not run CKAN
also gets a clear log message.

### 📤 Output

Each dataset is one dataset row. A field the portal has no value for is `null`, and a list with
nothing in it is `[]`.

#### Fields

| Field              | Type    | Description                                                                                                                           |
| ------------------ | ------- | ------------------------------------------------------------------------------------------------------------------------------------- |
| `portal`           | string  | The portal's root, such as `https://open.canada.ca/data`.                                                                             |
| `id`               | string  | Dataset ID on the portal.                                                                                                             |
| `name`             | string  | Dataset name (the URL slug).                                                                                                          |
| `url`              | string  | The dataset's page on the portal.                                                                                                     |
| `title`            | string  | Title (English first on bilingual portals).                                                                                           |
| `notes`            | string  | Description, as the portal writes it (often Markdown).                                                                                |
| `organization`     | string  | Publishing organization.                                                                                                              |
| `organizationName` | string  | The organization's slug, as used in organization links and filters.                                                                   |
| `tags`             | array   | Tags or keywords.                                                                                                                     |
| `groups`           | array   | Groups or themes the dataset belongs to.                                                                                              |
| `licenseId`        | string  | Licence ID, such as `cc-by` or `ca-ogl-lgo`.                                                                                          |
| `licenseTitle`     | string  | Licence name.                                                                                                                         |
| `licenseUrl`       | string  | Link to the licence.                                                                                                                  |
| `isOpen`           | boolean | Whether the portal marks the licence as open.                                                                                         |
| `author`           | string  | Author.                                                                                                                               |
| `authorEmail`      | string  | Author's contact email, when published.                                                                                               |
| `maintainer`       | string  | Maintainer.                                                                                                                           |
| `maintainerEmail`  | string  | Maintainer's contact email, when published.                                                                                           |
| `version`          | string  | Version.                                                                                                                              |
| `sourceUrl`        | string  | Link to the dataset's source or home page, when given.                                                                                |
| `metadataCreated`  | string  | When the dataset was created on the portal (ISO 8601, UTC).                                                                           |
| `metadataModified` | string  | When the dataset was last modified on the portal (ISO 8601, UTC).                                                                     |
| `numResources`     | number  | Number of resources.                                                                                                                  |
| `resources`        | array   | Files, APIs and links, each with `id`, `name`, `description`, `format`, `url`, `sizeBytes`, `mimeType`, `created` and `lastModified`. |
| `extras`           | object  | Extra fields the portal stores as key–value pairs, such as `spatial` or `frequency`.                                                  |

<details><summary>Example output</summary>

```json
{
  "portal": "https://data.sa.gov.au/data",
  "id": "cf8d8549-b976-4523-88ad-46dd32053696",
  "name": "road-crashes-in-sa",
  "url": "https://data.sa.gov.au/data/dataset/road-crashes-in-sa",
  "title": "Road Crash Locations in SA",
  "notes": "Sites of Road Crashes in South Australia.",
  "organization": "Department for Infrastructure and Transport",
  "organizationName": "department-of-planning-transport-and-infrastructure",
  "tags": ["crash", "road", "road crashes"],
  "groups": ["Emergency and safety", "Transport, travel and motoring"],
  "licenseId": "cc-by",
  "licenseTitle": "Creative Commons Attribution",
  "licenseUrl": "http://creativecommons.org/licenses/by/4.0",
  "isOpen": true,
  "author": "Department of Planning, Transport and Infrastructure",
  "authorEmail": null,
  "maintainer": "philip-greer-632",
  "maintainerEmail": null,
  "version": null,
  "sourceUrl": null,
  "metadataCreated": "2014-07-10T07:03:08.934634Z",
  "metadataModified": "2026-10-15T04:55:21.060246Z",
  "numResources": 30,
  "resources": [
    {
      "id": "6bc446be-d777-450c-8484-63d8035df63c",
      "name": "Road Crash Locations - Metadata",
      "description": "Annual extracts for rolling 5 year periods are extracted from the Traffic Accident Register (TARS) for any crash which has enough information to be located. …",
      "format": "GeoJSON",
      "url": "https://location.sa.gov.au/lms/Reports/ReportMetadata.aspx?p_no=1122&pu=y",
      "sizeBytes": null,
      "mimeType": null,
      "created": "2015-12-21T10:42:24.666452Z",
      "lastModified": "2022-11-29T23:08:09.449362Z"
    }
  ],
  "extras": {}
}
```

</details>

### 💡 Use cases

- **Open-data aggregation** — pull the catalogues of several portals into one table with a common shape.
- **Monitoring** — track new and updated datasets of a portal, organization or topic, newest first.
- **Data discovery** — find CSV, GeoJSON or API resources on a topic, with direct download links.
- **Transparency research** — see what each agency publishes, under which licence and how recently.
- **RAG and analytics** — feed titles, descriptions and tags into search, embedding or BI pipelines.

### ❓ FAQ

- **Do I need an account or an API key?** No. The Actor reads public catalogue data only.
- **Do I need a proxy?** No. It runs without one by default.
- **Why was a portal skipped?** Its robots.txt closes the data API to crawlers (the CKAN default on many portals), opts out of AI agents, or could not be read. The log says which. The Actor respects those rules.
- **Why is it slow on some portals?** Some portals ask crawlers to wait between requests (open.canada.ca asks for 20 seconds). Each request returns up to 100 datasets, so this matters only for very large lists.
- **Why did my sort not apply?** Some portals' robots.txt does not allow sorted requests; the Actor then returns best match and says so in the log.
- **Can I use the data commercially?** Each dataset carries its licence in `licenseId`, `licenseTitle` and `licenseUrl`, and each portal publishes its catalogue under its own terms. Open.canada.ca's catalogue, for example, is under the Open Government Licence – Canada, which asks for the attribution "Contains information licensed under the Open Government Licence – Canada."
- **Does it download the files?** No. Every resource carries its `url`, so you can fetch the ones you need.

### 🔗 More scrapers by Anyx

- [Web Content Scraper](https://apify.com/anyxsolutions/web-content-scraper)
- [Crossref Scraper](https://apify.com/anyxsolutions/crossref-scraper)
- [Google Search Scraper](https://apify.com/anyxsolutions/google-search-scraper)
- [Google Maps Email Extractor](https://apify.com/anyxsolutions/google-maps-email-extractor)

### 🤝 Anyx Solutions

We build custom scrapers and data-extraction pipelines.

- Email: tantosthor@gmail.com

# Actor input Schema

## `startUrls` (type: `array`):

Pages of a CKAN portal: a dataset search with its filters, such as https://open.canada.ca/data/en/dataset?q=water\&organization=nrcan-rncan, a dataset such as https://data.stadt-zuerich.ch/dataset/erz_abwassermenge_klaerwerk_werdhoelzli, an organization (…/organization/<name>), a group (…/group/<name>), or a portal home page for every dataset.

## `portalUrl` (type: `string`):

Home page of a CKAN portal to search with the search terms below, for example https://open.canada.ca/data or https://data.sa.gov.au/data. With no search terms, every dataset of the portal is returned.

## `searchTerms` (type: `array`):

Keywords to search the portal above for, one search per line, for example air quality or "public transport". CKAN search syntax works too, such as res_format:CSV.

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

Order of the search-term results: best match, last modified, newest, or name A to Z. Portals that do not allow sorting return best match.

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

Maximum number of datasets to return per start URL or search term. Leave empty to get every match.

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

Proxy settings. CKAN portals need no proxy; the Actor keeps to each portal's crawl delay.

## Actor input object example

```json
{
  "startUrls": [
    {
      "url": "https://open.canada.ca/data/en/dataset?q=water%20quality"
    }
  ],
  "sortBy": "relevance",
  "maxItems": 5,
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}
```

# Actor output Schema

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

No description

# 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 = {
    "startUrls": [
        {
            "url": "https://open.canada.ca/data/en/dataset?q=water%20quality"
        }
    ],
    "maxItems": 5
};

// Run the Actor and wait for it to finish
const run = await client.actor("anyxsolutions/ckan-datasets-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 = {
    "startUrls": [{ "url": "https://open.canada.ca/data/en/dataset?q=water%20quality" }],
    "maxItems": 5,
}

# Run the Actor and wait for it to finish
run = client.actor("anyxsolutions/ckan-datasets-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 '{
  "startUrls": [
    {
      "url": "https://open.canada.ca/data/en/dataset?q=water%20quality"
    }
  ],
  "maxItems": 5
}' |
apify call anyxsolutions/ckan-datasets-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,anyxsolutions/ckan-datasets-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/YNOSWVgfgxNdfhYaG/builds/oKxaz6f5KKAfRnyFG/openapi.json
