# CKAN Open Data Scraper (`straightforward_hydra/ckan-open-data-scraper`) Actor

Search datasets and pull tabular records from any public CKAN open-data portal. No key.

- **URL**: https://apify.com/straightforward\_hydra/ckan-open-data-scraper.md
- **Developed by:** [Dev D](https://apify.com/straightforward_hydra) (community)
- **Categories:** Developer tools, Automation, Lead generation
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.00 / 1,000 records

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

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

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## CKAN Open Data Scraper 📂

**Search datasets and pull tabular records from any public CKAN open-data portal — data.gov.uk, open.canada.ca and hundreds more. No API key, no proxy.**

CKAN is the software behind most government and research **open-data portals** worldwide. This actor is a universal connector: point it at any CKAN portal and either **search its datasets** (metadata, organizations, resources, tags) or **pull the actual rows** from a datastore-backed resource.

Perfect for **open-data pipelines, government/research data aggregation, civic tech, data journalism**, and keeping a warehouse in sync with public datasets.

> Uses CKAN's public Action API — no key, no login. One actor works across every CKAN portal.

***

### Two modes

- 🔎 **Search datasets** — `package_search`: dataset title, notes, organization, license, tags, and its resources (with `datastore_active` flags).
- 📊 **Resource records** — `datastore_search`: the actual tabular rows from a datastore-backed resource.

### Features

- ✅ **No API key, no proxy** — public CKAN Action API.
- ✅ **Universal** — works on any CKAN portal (just change the portal URL).
- ✅ **Dataset discovery** — search + Solr filter queries (`res_format:CSV`, `organization:...`).
- ✅ **Raw data** — pull the rows behind a resource, with full-text search.
- ✅ **Auto-pagination** — handles both endpoints' paging.

***

### Input

| Field | Description |
|---|---|
| **Portal URL** | Base URL, e.g. `https://data.gov.uk` or `https://open.canada.ca/data`. |
| **Mode** | `datasets` (search) or `records` (datastore rows). |
| **Query** | Free-text search. |
| **Filter query** | Solr `fq` filter (datasets mode), e.g. `res_format:CSV`. |
| **Resource ID** | Datastore-active resource ID (records mode). |
| **Max results** | Cap on datasets/records returned. |

#### Example — search CSV crime datasets on data.gov.uk

```json
{
  "portalUrl": "https://data.gov.uk",
  "mode": "datasets",
  "query": "crime",
  "filterQuery": "res_format:CSV",
  "maxResults": 500
}
```

#### Example — pull rows from a specific resource

```json
{
  "portalUrl": "https://open.canada.ca/data",
  "mode": "records",
  "resourceId": "a811cac0-2a2a-4440-8a81-2994fc753171",
  "maxResults": 10000
}
```

### Output

Datasets mode:

```json
{
  "id": "…",
  "name": "crime-data",
  "title": "Crime",
  "notes": "…",
  "organization": "Calderdale Metropolitan Borough Council",
  "license_title": "UK Open Government Licence (OGL)",
  "num_resources": 3,
  "tags": ["crime", "safety"],
  "url": "https://data.gov.uk/dataset/crime-data",
  "resources": [
    { "id": "…", "name": "2024 CSV", "format": "CSV", "url": "…", "datastore_active": true }
  ]
}
```

Records mode returns each row as-is (the resource's own columns) plus a `_resource_id` field.

### Workflow tip

Use **datasets mode** to find resources where `datastore_active: true`, then feed those resource IDs into **records mode** to pull the actual data.

### Run it on a schedule

Keep a mirror of chosen datasets/resources fresh — pipe to a database, Google Sheets or a webhook.

### Notes & limitations

- Public CKAN portals only.
- Records mode requires a **datastore-active** resource (many resources are just file links, which have no queryable rows).
- Some portals mount CKAN under a subpath (e.g. `/data`) — include it in the portal URL.
- Data sources: the respective open-data portals; respect their licenses.

***

#### Keywords

CKAN, open data, data.gov, data.gov.uk, open.canada.ca, government data, datastore, package\_search, datasets, civic tech, open data portal, public data, data catalog, research data, data journalism, Solr, open government, data aggregation, tabular data, API.

# Actor input Schema

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

Base URL of a CKAN portal, e.g. https://data.gov.uk or https://open.canada.ca/data.

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

Search datasets (metadata) or pull records from a specific datastore resource.

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

Free-text search. In datasets mode searches dataset text; in records mode does a full-text search over the resource rows.

## `filterQuery` (type: `string`):

Optional Solr filter, e.g. "organization:calderdale" or "res\_format:CSV" or "tags:crime".

## `resourceId` (type: `string`):

The datastore-active resource ID to pull rows from. Find it in a dataset's resources (datastore\_active: true).

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

Maximum number of datasets (datasets mode) or records (records mode) to return.

## Actor input object example

```json
{
  "portalUrl": "https://data.gov.uk",
  "mode": "datasets",
  "maxResults": 1000
}
```

# 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 = {
    "portalUrl": "https://data.gov.uk"
};

// Run the Actor and wait for it to finish
const run = await client.actor("straightforward_hydra/ckan-open-data-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 = { "portalUrl": "https://data.gov.uk" }

# Run the Actor and wait for it to finish
run = client.actor("straightforward_hydra/ckan-open-data-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 '{
  "portalUrl": "https://data.gov.uk"
}' |
apify call straightforward_hydra/ckan-open-data-scraper --silent --output-dataset

```

## MCP server setup

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

```

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/acts/yqeArMeoerceojpSh/builds/UrOw6GKGvC16HZLhQ/openapi.json
