Skip to content

CKAN

Search datasets and read DataStore tables from any CKAN open-data portal

Connector software
Free and open source
Service credentials
Optional
Use with an agent

Install the Orchard skill in your project to help your agent find connectors, configure them, and verify SQL results.

npx skills add Query-farm/vgi-skills --skill orchard

Copy this request into your coding agent to get started.

Use https://query.farm/products/orchard/connectors/ckan/index.md to help me query CKAN with DuckDB or Haybarn 2.0.1 and VGI protocol 3.4. Ask only for missing details about the result I need or whether I want local execution, self-hosting or Query Farm hosting. Check the connector's actual hosting availability, credentials and input requirements. Read one format of each needed reference and the exact object declarations before writing SQL. Use a released connector, and distinguish a saved example result from anything you actually execute. If you cannot run the query, tell me what remains to verify.

Datasets per publishing organization on the CKAN demo portal

Example output · captured
Connector release
v0.2.0
Engine
2.0.1
VGI protocol
3.4.0
SELECT organization, count(*) AS datasets
FROM ckan.main.datasets('https://demo.ckan.org')
GROUP BY organization
ORDER BY datasets DESC, organization
Result
organization datasets
NULL 11
demo-organization 2

Quick start

Choose where to run CKAN, then follow the steps below.

The connector runs alongside DuckDB or Haybarn. No Query Farm account is needed.

1. Install the vgi extension

Run this in your SQL client. On DuckDB, keep FROM query_farm on LOAD in later sessions.

setup.sql
SET allow_extension_repositories = 'allowed';

CREATE EXTENSION REPOSITORY IF NOT EXISTS query_farm
    WITH PREFIX 'https://duckdb-extensions.query.farm';

INSTALL vgi FROM query_farm;
LOAD vgi FROM query_farm;

2. Attach the connector

Attach with uvx

Needs uv. uvx builds the worker from its release tag on first attach and reuses the cached environment after that.

ATTACH 'ckan' AS ckan (
  TYPE vgi,
  LOCATION 'uvx --from git+https://github.com/Query-farm/[email protected] vgi-ckan-worker'
);

3. Add service credentials (optional)

Public portals need no credentials; a token is only for private datasets. Replace the placeholders with your service settings.

ckan credentials

CKAN API token for one portal (scope the secret to the portal URL). Only needed for private datasets and private DataStore tables; public portals need no secret.

Get these credentials →
secret.sql
CREATE SECRET ckan (
    TYPE ckan,
    api_token '<API_TOKEN>'  -- secret
);
Credential fields and requirements →

4. Run a query

query.sql
SELECT organization, count(*) AS datasets
FROM ckan.main.datasets('https://demo.ckan.org')
GROUP BY organization
ORDER BY datasets DESC, organization
More example queries →
Technical details
Verified connector release
v0.2.0
Engine
2.0.1
VGI protocol
3.4.0
Verified on
December 1, 2026
Release notes on GitHub
Pin a version for production

When running the connector yourself, keep a specific release until you’re ready to upgrade. Replace the ATTACH statement above with this one and follow the same extension and credential setup.

Attach with uvx

Needs uv. uvx builds the worker from its release tag on first attach and reuses the cached environment after that.

ATTACH 'ckan' AS ckan (
  TYPE vgi,
  LOCATION 'uvx --from git+https://github.com/Query-farm/[email protected] vgi-ckan-worker'
);

Overview

Any CKAN open-data portal as SQL: search datasets and resources, browse organizations, groups, tags and licenses, and read DataStore tables, from data.gov.ie, open.canada.ca and thousands of other CKAN sites.

ATTACH options

portal
Default CKAN portal base URL for functions called without one, e.g. 'https://data.gov.ie'.VARCHAR

Catalog

Everything ckan exposes once attached — read straight from the worker's released build.

ckan 1 schema
main 14 functions

CKAN Action API functions: dataset search, portal directory and DataStore tables.

Schema examples (14)
Examples (14)

Datasets per publishing organization on the CKAN demo portal

SELECT organization, count(*) AS datasets
FROM ckan.main.datasets('https://demo.ckan.org')
GROUP BY organization
ORDER BY datasets DESC, organization;
Result
organization datasets
NULL 11
demo-organization 2

Metadata of one data.gov.ie dataset

SELECT title, organization, license_id, num_resources, modified
FROM ckan.main.dataset('https://data.gov.ie', 'courts-service-purchase-orders-greater-than-20-000-2026');

Resource formats on the CKAN demo portal

SELECT format, count(*) AS resources
FROM ckan.main.resources('https://demo.ckan.org')
GROUP BY format
ORDER BY resources DESC, format;

Organizations on the CKAN demo portal by number of datasets

SELECT name, title, dataset_count
FROM ckan.main.organizations('https://demo.ckan.org')
ORDER BY dataset_count DESC, name;
10 more examples

data.gov.ie themes by number of datasets

SELECT name, title, dataset_count
FROM ckan.main.groups('https://data.gov.ie')
ORDER BY dataset_count DESC;

The twenty most used tags on data.gov.ie

SELECT tag, dataset_count
FROM ckan.main.tags('https://data.gov.ie')
ORDER BY dataset_count DESC, tag
LIMIT 20;

The ten most common resource formats on data.gov.ie

SELECT value AS format, dataset_count
FROM ckan.main.facets('https://data.gov.ie', 'res_format')
ORDER BY dataset_count DESC
LIMIT 10;

Open Definition-approved licenses on the CKAN demo portal

SELECT license_id, title
FROM ckan.main.licenses('https://demo.ckan.org')
WHERE od_conformance = 'approved'
ORDER BY 1;

Which CKAN version the demo portal runs

SELECT site_title, ckan_version, datastore_enabled
FROM ckan.main.portal_info('https://demo.ckan.org');

The ten latest dataset changes on data.gov.ie

SELECT changed_at, activity_type, title
FROM ckan.main.recent_changes('https://data.gov.ie')
ORDER BY changed_at DESC
LIMIT 10;

Largest paid suppliers in a data.gov.ie purchase-order table (filter sent to the portal)

SELECT "Supplier Name", sum("Amount") AS total
FROM ckan.main.datastore('https://data.gov.ie', 'dfb0930a-98a5-45a0-a6b7-e4beb66340e5')
WHERE paid_yes_no = 'Y'
GROUP BY ALL
ORDER BY total DESC
LIMIT 5;

Readings per wave buoy, counted by the Queensland portal's PostgreSQL

SELECT "Site", readings
FROM ckan.main.datastore_sql('https://www.data.qld.gov.au', 'SELECT "Site", count(*) AS readings FROM "2bbef99e-9974-49b9-a316-57402b00609c" GROUP BY 1')
ORDER BY readings DESC
LIMIT 5;

A DataStore-backed resource reads as typed rows

SELECT count(*) AS orders, sum("Amount") AS total
FROM ckan.main.resource_data('https://data.gov.ie', 'dfb0930a-98a5-45a0-a6b7-e4beb66340e5');

Reader queries for the loadable files on the CKAN demo portal

SELECT title, ckan.main.read_sql(format, url) AS query
FROM ckan.main.resources('https://demo.ckan.org')
WHERE ckan.main.read_sql(format, url) IS NOT NULL
ORDER BY title
LIMIT 5;
Scalar functions
read_sql (resource_format VARCHAR, url VARCHAR) 4 examples

Build the DuckDB query (read_csv / read_parquet / read_json_auto) that loads a resource URL

Arguments
resource_format VARCHAR
The resource's declared format, e.g. 'CSV' or 'Parquet'; blank falls back to the URL's extension.
url VARCHAR
The resource's download URL (resources().url).
ReturnsVARCHAR
Examples (4)

Reader queries for the loadable files on the CKAN demo portal

SELECT title, ckan.main.read_sql(format, url) AS query
FROM ckan.main.resources('https://demo.ckan.org')
WHERE ckan.main.read_sql(format, url) IS NOT NULL
ORDER BY title
LIMIT 5;

A blank format falls back to the URL's extension

SELECT ckan.main.read_sql('', 'https://example.org/export.parquet?download=1') AS q;
SELECT ckan.main.read_sql('CSV', 'https://example.org/data.csv') AS q;
1 more example
SELECT f,
  ckan.main.read_sql(f, 'https://example.org/file') IS NOT NULL AS readable
FROM (VALUES ('Parquet'), ('GeoJSON'), ('PDF')) AS t(f)
ORDER BY f;
Link
Table functions
dataset (portal VARCHAR, id VARCHAR) +1 overload 2 examples

One CKAN dataset by id or name, with the same columns as datasets()

Arguments
portal VARCHAR
Base URL of the CKAN site, e.g. 'https://demo.ckan.org', 'https://data.gov.ie' or 'https://open.canada.ca/data'. A pasted dataset or /api/3 URL is trimmed to the site root.
id VARCHAR
Dataset id or name (its URL slug).
Overloads
dataset(portal VARCHAR, id VARCHAR)dataset(id VARCHAR)
Returns columns
portal VARCHAR
Base URL of the CKAN portal the row came from.
dataset_id VARCHAR
Dataset (package) id.
name VARCHAR
Dataset URL slug (unique per portal).
title VARCHAR
Dataset title (the portal locale's translation on multilingual portals).
description VARCHAR
Dataset description (CKAN 'notes'), usually Markdown.
organization VARCHAR
Publishing organization's slug (name).
organization_title VARCHAR
Publishing organization's display title.
groups VARCHAR[]
Slugs of the groups (themes) the dataset belongs to.
tags VARCHAR[]
Tag names (keywords).
formats VARCHAR[]
Distinct formats of the dataset's resources, sorted, e.g. ['CSV', 'JSON'].
license_id VARCHAR
License id, e.g. 'cc-by', 'CC-BY-4.0', 'uk-ogl' (see licenses()).
license_title VARCHAR
License display title.
num_resources INTEGER
Number of resources (files / APIs) in the dataset.
private BOOLEAN
True for private datasets (visible only with an API token).
state VARCHAR
Lifecycle state: 'active' for published datasets.
type VARCHAR
Dataset type: 'dataset' unless the portal defines custom types.
author VARCHAR
Author named in the metadata.
maintainer VARCHAR
Maintainer named in the metadata.
version VARCHAR
Version string from the metadata.
source_url VARCHAR
The dataset's own 'url' field: a link to the source or homepage.
url VARCHAR
The dataset's page on the portal: <portal>/dataset/<name>.
created TIMESTAMP WITH TIME ZONE
When the dataset record was created on the portal (metadata_created, UTC).
modified TIMESTAMP WITH TIME ZONE
When the dataset record last changed (metadata_modified, UTC).
extras MAP(VARCHAR, VARCHAR)
Custom key/value metadata ('extras').
raw JSON
The full dataset dictionary as returned by the portal (portal-specific fields).
Examples (2)

Metadata of one data.gov.ie dataset

SELECT title, organization, license_id, num_resources, modified
FROM ckan.main.dataset('https://data.gov.ie', 'courts-service-purchase-orders-greater-than-20-000-2026');

Resource formats of one open.canada.ca dataset, looked up by id

SELECT title, organization, unnest(formats) AS format
FROM ckan.main.dataset('https://open.canada.ca/data', 'ee9bd7e8-90a5-45db-9287-85c8cf3589b6')
ORDER BY format;
Link
datasets (portal VARCHAR, tag := VARCHAR, q := VARCHAR, res_format := VARCHAR, page_size := BIGINT, group_name := VARCHAR, fq := VARCHAR) +1 overload 2 examples
Positional arguments
portal VARCHAR
Base URL of the CKAN site, e.g. 'https://demo.ckan.org', 'https://data.gov.ie' or 'https://open.canada.ca/data'. A pasted dataset or /api/3 URL is trimmed to the site root.
Named arguments
tag := VARCHAR
Only datasets with this tag. · default null
q := VARCHAR
Free-text search (Solr syntax), e.g. 'air quality' or 'title:budget'. · default null
res_format := VARCHAR
Only datasets with a resource of this format, e.g. 'CSV'. · default null
page_size := BIGINT
Datasets per request, 1-1000 (portals cap it, 1000 by default). · default 100
group_name := VARCHAR
Only datasets in this group (slug). · default null
fq := VARCHAR
Raw Solr filter query ANDed with the pushed-down filters, e.g. 'num_tags:[5 TO *]'. · default null
Overloads
datasets(portal VARCHAR, tag VARCHAR, q VARCHAR, res_format VARCHAR, page_size BIGINT, group_name VARCHAR, fq VARCHAR)datasets(tag VARCHAR, q VARCHAR, res_format VARCHAR, page_size BIGINT, group_name VARCHAR, fq VARCHAR)
Returns columns
portal VARCHAR
Base URL of the CKAN portal the row came from.
dataset_id VARCHAR
Dataset (package) id.
name VARCHAR
Dataset URL slug (unique per portal).
title VARCHAR
Dataset title (the portal locale's translation on multilingual portals).
description VARCHAR
Dataset description (CKAN 'notes'), usually Markdown.
organization VARCHAR
Publishing organization's slug (name).
organization_title VARCHAR
Publishing organization's display title.
groups VARCHAR[]
Slugs of the groups (themes) the dataset belongs to.
tags VARCHAR[]
Tag names (keywords).
formats VARCHAR[]
Distinct formats of the dataset's resources, sorted, e.g. ['CSV', 'JSON'].
license_id VARCHAR
License id, e.g. 'cc-by', 'CC-BY-4.0', 'uk-ogl' (see licenses()).
license_title VARCHAR
License display title.
num_resources INTEGER
Number of resources (files / APIs) in the dataset.
private BOOLEAN
True for private datasets (visible only with an API token).
state VARCHAR
Lifecycle state: 'active' for published datasets.
type VARCHAR
Dataset type: 'dataset' unless the portal defines custom types.
author VARCHAR
Author named in the metadata.
maintainer VARCHAR
Maintainer named in the metadata.
version VARCHAR
Version string from the metadata.
source_url VARCHAR
The dataset's own 'url' field: a link to the source or homepage.
url VARCHAR
The dataset's page on the portal: <portal>/dataset/<name>.
created TIMESTAMP WITH TIME ZONE
When the dataset record was created on the portal (metadata_created, UTC).
modified TIMESTAMP WITH TIME ZONE
When the dataset record last changed (metadata_modified, UTC).
extras MAP(VARCHAR, VARCHAR)
Custom key/value metadata ('extras').
raw JSON
The full dataset dictionary as returned by the portal (portal-specific fields).
Examples (2)

Datasets per publishing organization on the CKAN demo portal

SELECT organization, count(*) AS datasets
FROM ckan.main.datasets('https://demo.ckan.org')
GROUP BY organization
ORDER BY datasets DESC, organization;
Result
organization datasets
NULL 11
demo-organization 2

Recently updated EPA air-quality datasets on data.gov.ie (filters run in the portal)

SELECT name, title, modified
FROM ckan.main.datasets('https://data.gov.ie', q := 'air quality')
WHERE organization = 'environmental-protection-agency' AND modified >= TIMESTAMPTZ '2025-01-01'
ORDER BY modified DESC
LIMIT 10;
Link
datastore (portal VARCHAR, resource_id VARCHAR, page_size := BIGINT, q := VARCHAR, filters := VARCHAR) +1 overload 2 examples
Positional arguments
portal VARCHAR
Base URL of the CKAN site, e.g. 'https://demo.ckan.org', 'https://data.gov.ie' or 'https://open.canada.ca/data'. A pasted dataset or /api/3 URL is trimmed to the site root.
resource_id VARCHAR
Id of a resource whose rows are loaded into DataStore.
Named arguments
page_size := BIGINT
Rows per request, 1-32000 (the DataStore default maximum). · default 1000
q := VARCHAR
Full-text search across the table's text columns. · default null
filters := VARCHAR
Remote equality filters: a JSON object mapping a column to a value, or to a list of values. · default null
Overloads
datastore(portal VARCHAR, resource_id VARCHAR, page_size BIGINT, q VARCHAR, filters VARCHAR)datastore(resource_id VARCHAR, page_size BIGINT, q VARCHAR, filters VARCHAR)
Returns columns
_id BIGINT
DataStore row id (1-based).
Returns columns · depends on the arguments
_id BIGINT
DataStore row id (1-based).
Examples (2)

Largest paid suppliers in a data.gov.ie purchase-order table (filter sent to the portal)

SELECT "Supplier Name", sum("Amount") AS total
FROM ckan.main.datastore('https://data.gov.ie', 'dfb0930a-98a5-45a0-a6b7-e4beb66340e5')
WHERE paid_yes_no = 'Y'
GROUP BY ALL
ORDER BY total DESC
LIMIT 5;

Mean significant wave height at two Queensland buoys

SELECT "Site", avg("Hs"::DOUBLE) AS mean_wave_height_m
FROM ckan.main.datastore('https://www.data.qld.gov.au', '2bbef99e-9974-49b9-a316-57402b00609c', filters := '{"Site": ["Caloundra", "Mooloolaba"]}')
GROUP BY ALL
ORDER BY 1;
Link
datastore_sql (portal VARCHAR, sql VARCHAR) +1 overload 2 examples

Run a read-only PostgreSQL query on a CKAN portal's DataStore, where the portal enables it

Arguments
portal VARCHAR
Base URL of the CKAN site, e.g. 'https://demo.ckan.org', 'https://data.gov.ie' or 'https://open.canada.ca/data'. A pasted dataset or /api/3 URL is trimmed to the site root.
sql VARCHAR
One read-only PostgreSQL query; each table is a resource id written as a double-quoted identifier.
Overloads
datastore_sql(portal VARCHAR, sql VARCHAR)datastore_sql(sql VARCHAR)
Returns columns
Site VARCHAR
Buoy name (a text column).
readings BIGINT
count(*) per site (int8).
ts TIMESTAMP
The text DateTime column cast to timestamp.
Returns columns · depends on the arguments
Site VARCHAR
Buoy name (a text column).
readings BIGINT
count(*) per site (int8).
ts TIMESTAMP
The text DateTime column cast to timestamp.
Examples (2)

Readings per wave buoy, counted by the Queensland portal's PostgreSQL

SELECT "Site", readings
FROM ckan.main.datastore_sql('https://www.data.qld.gov.au', 'SELECT "Site", count(*) AS readings FROM "2bbef99e-9974-49b9-a316-57402b00609c" GROUP BY 1')
ORDER BY readings DESC
LIMIT 5;

Latest reading time at the Caloundra buoy, as a typed TIMESTAMP

SELECT max(ts) AS latest
FROM ckan.main.datastore_sql('https://www.data.qld.gov.au', 'SELECT "DateTime"::timestamp AS ts FROM "2bbef99e-9974-49b9-a316-57402b00609c" WHERE "Site" = ''Caloundra'' ');
Link
facets (portal VARCHAR, field VARCHAR, max_values := BIGINT, q := VARCHAR, fq := VARCHAR) +1 overload 2 examples
Positional arguments
portal VARCHAR
Base URL of the CKAN site, e.g. 'https://demo.ckan.org', 'https://data.gov.ie' or 'https://open.canada.ca/data'. A pasted dataset or /api/3 URL is trimmed to the site root.
field VARCHAR
Search field to count: organization, groups, tags, res_format, license_id, or any indexed field.
Named arguments
max_values := BIGINT
Most values to return (largest counts first), 1-100000. · default 1000
q := VARCHAR
Free-text search restricting the datasets counted. · default null
fq := VARCHAR
Raw Solr filter restricting the datasets counted. · default null
Overloads
facets(portal VARCHAR, field VARCHAR, max_values BIGINT, q VARCHAR, fq VARCHAR)facets(field VARCHAR, max_values BIGINT, q VARCHAR, fq VARCHAR)
Returns columns
portal VARCHAR
Base URL of the CKAN portal.
field VARCHAR
The faceted search field, e.g. 'res_format'.
value VARCHAR
One value of the field.
display_name VARCHAR
The value's display name (e.g. an organization's title).
dataset_count BIGINT
Number of matching datasets with this value.
Examples (2)

The ten most common resource formats on data.gov.ie

SELECT value AS format, dataset_count
FROM ckan.main.facets('https://data.gov.ie', 'res_format')
ORDER BY dataset_count DESC
LIMIT 10;

Organizations publishing the most CSV datasets on open.canada.ca

SELECT display_name, dataset_count
FROM ckan.main.facets('https://open.canada.ca/data', 'organization', fq := 'res_format:CSV')
ORDER BY dataset_count DESC
LIMIT 5;
Link
groups (portal VARCHAR) +1 overload 2 examples

List a CKAN portal's groups (themes) with their dataset counts

Arguments
portal VARCHAR
Base URL of the CKAN site, e.g. 'https://demo.ckan.org', 'https://data.gov.ie' or 'https://open.canada.ca/data'. A pasted dataset or /api/3 URL is trimmed to the site root.
Overloads
groups(portal VARCHAR)groups()
Returns columns
portal VARCHAR
Base URL of the CKAN portal.
group_id VARCHAR
The group's id, a UUID.
name VARCHAR
The group's URL slug, as used in datasets().group.
title VARCHAR
Display title.
description VARCHAR
Description, usually Markdown.
dataset_count BIGINT
Number of public datasets.
state VARCHAR
Lifecycle state: 'active'.
image_url VARCHAR
Logo / image URL.
created TIMESTAMP WITH TIME ZONE
When it was created on the portal (UTC).
url VARCHAR
Its page on the portal: <portal>/group/<name>.
Examples (2)

data.gov.ie themes by number of datasets

SELECT name, title, dataset_count
FROM ckan.main.groups('https://data.gov.ie')
ORDER BY dataset_count DESC;

How many groups the CKAN demo portal has

SELECT count(*) AS groups FROM ckan.main.groups('https://demo.ckan.org');
Link
licenses (portal VARCHAR) +1 overload 2 examples

List the licenses a CKAN portal offers for datasets

Arguments
portal VARCHAR
Base URL of the CKAN site, e.g. 'https://demo.ckan.org', 'https://data.gov.ie' or 'https://open.canada.ca/data'. A pasted dataset or /api/3 URL is trimmed to the site root.
Overloads
licenses(portal VARCHAR)licenses()
Returns columns
portal VARCHAR
Base URL of the CKAN portal.
license_id VARCHAR
License id, as in datasets().license_id.
title VARCHAR
License title.
url VARCHAR
License text URL.
family VARCHAR
License family, when given.
status VARCHAR
Status, e.g. 'active'.
od_conformance VARCHAR
Open Definition conformance: 'approved', 'not reviewed', ...
osd_conformance VARCHAR
Open Source Definition conformance.
is_generic BOOLEAN
True for generic placeholders such as 'other-open'.
is_okd_compliant BOOLEAN
Open Knowledge Definition compliant.
is_osi_compliant BOOLEAN
OSI-approved (software licenses).
domain_content BOOLEAN
Applies to content.
domain_data BOOLEAN
Applies to data.
domain_software BOOLEAN
Applies to software.
Examples (2)

Open Definition-approved licenses on the CKAN demo portal

SELECT license_id, title
FROM ckan.main.licenses('https://demo.ckan.org')
WHERE od_conformance = 'approved'
ORDER BY 1;

Datasets per license on the CKAN demo portal

SELECT l.title, count(*) AS datasets
FROM ckan.main.datasets('https://demo.ckan.org') d
JOIN ckan.main.licenses('https://demo.ckan.org') l USING (license_id)
GROUP BY ALL
ORDER BY datasets DESC;
Link
organizations (portal VARCHAR) +1 overload 2 examples

List a CKAN portal's publishing organizations with their dataset counts

Arguments
portal VARCHAR
Base URL of the CKAN site, e.g. 'https://demo.ckan.org', 'https://data.gov.ie' or 'https://open.canada.ca/data'. A pasted dataset or /api/3 URL is trimmed to the site root.
Overloads
organizations(portal VARCHAR)organizations()
Returns columns
portal VARCHAR
Base URL of the CKAN portal.
organization_id VARCHAR
The organization's id, a UUID.
name VARCHAR
The organization's URL slug, as used in datasets().organization.
title VARCHAR
Display title.
description VARCHAR
Description, usually Markdown.
dataset_count BIGINT
Number of public datasets.
state VARCHAR
Lifecycle state: 'active'.
image_url VARCHAR
Logo / image URL.
created TIMESTAMP WITH TIME ZONE
When it was created on the portal (UTC).
url VARCHAR
Its page on the portal: <portal>/organization/<name>.
Examples (2)

Organizations on the CKAN demo portal by number of datasets

SELECT name, title, dataset_count
FROM ckan.main.organizations('https://demo.ckan.org')
ORDER BY dataset_count DESC, name;

How many data.gov.ie organizations have published nothing yet

SELECT count(*) AS organizations,
  count(*) FILTER (WHERE dataset_count = 0) AS empty
FROM ckan.main.organizations('https://data.gov.ie');
Link
portal_info (portal VARCHAR) +1 overload 2 examples

Show a CKAN portal's title, CKAN version and enabled plugins

Arguments
portal VARCHAR
Base URL of the CKAN site, e.g. 'https://demo.ckan.org', 'https://data.gov.ie' or 'https://open.canada.ca/data'. A pasted dataset or /api/3 URL is trimmed to the site root.
Overloads
portal_info(portal VARCHAR)portal_info()
Returns columns
portal VARCHAR
Base URL of the CKAN portal.
site_title VARCHAR
The portal's title.
site_url VARCHAR
The portal's configured public URL.
site_description VARCHAR
The portal's description.
ckan_version VARCHAR
CKAN version, e.g. '2.10.8' (NULL when the portal hides it).
locale_default VARCHAR
Default locale, e.g. 'en' or 'en_GB'.
extensions VARCHAR[]
Enabled CKAN plugins, e.g. ['datastore', 'dcat', ...].
datastore_enabled BOOLEAN
True when the datastore plugin is enabled (datastore() works).
Examples (2)

Which CKAN version the demo portal runs

SELECT site_title, ckan_version, datastore_enabled
FROM ckan.main.portal_info('https://demo.ckan.org');

Compare CKAN versions and DCAT support across three national portals

SELECT portal, ckan_version, list_contains(extensions, 'dcat') AS dcat
FROM (SELECT * FROM ckan.main.portal_info('https://data.gov.ie') UNION ALL SELECT * FROM ckan.main.portal_info('https://open.canada.ca/data') UNION ALL SELECT * FROM ckan.main.portal_info('https://www.data.qld.gov.au'))
ORDER BY portal;
Link
recent_changes (portal VARCHAR, page_size := BIGINT) +1 overload 2 examples
Positional arguments
portal VARCHAR
Base URL of the CKAN site, e.g. 'https://demo.ckan.org', 'https://data.gov.ie' or 'https://open.canada.ca/data'. A pasted dataset or /api/3 URL is trimmed to the site root.
Named arguments
page_size := BIGINT
Activities per request, 1-100 (portals cap it). · default 100
Overloads
recent_changes(portal VARCHAR, page_size BIGINT)recent_changes(page_size BIGINT)
Returns columns
portal VARCHAR
Base URL of the CKAN portal.
activity_id VARCHAR
Activity id.
changed_at TIMESTAMP WITH TIME ZONE
When the change happened (UTC).
activity_type VARCHAR
'new package', 'changed package' or 'deleted package'.
dataset_id VARCHAR
Id of the dataset that changed.
dataset_name VARCHAR
Slug of the dataset (NULL when the portal omits the snapshot).
title VARCHAR
Title of the dataset at the time of the change.
user_id VARCHAR
Id of the user who made the change.
url VARCHAR
The dataset's page on the portal.
Examples (2)

The ten latest dataset changes on data.gov.ie

SELECT changed_at, activity_type, title
FROM ckan.main.recent_changes('https://data.gov.ie')
ORDER BY changed_at DESC
LIMIT 10;

Kinds of change among the 50 latest on open.canada.ca

SELECT activity_type, count(*) AS changes
FROM (SELECT activity_type FROM ckan.main.recent_changes('https://open.canada.ca/data', page_size := 25) LIMIT 50)
GROUP BY ALL
ORDER BY changes DESC;
Link
resource_data (portal VARCHAR, resource_id VARCHAR, page_size := BIGINT) +1 overload 2 examples
Positional arguments
portal VARCHAR
Base URL of the CKAN site, e.g. 'https://demo.ckan.org', 'https://data.gov.ie' or 'https://open.canada.ca/data'. A pasted dataset or /api/3 URL is trimmed to the site root.
resource_id VARCHAR
Id of the resource to read.
Named arguments
page_size := BIGINT
DataStore rows per request, 1-32000. · default 1000
Overloads
resource_data(portal VARCHAR, resource_id VARCHAR, page_size BIGINT)resource_data(resource_id VARCHAR, page_size BIGINT)
Returns columns
_id BIGINT
DataStore row id.
portal VARCHAR
Base URL of the portal.
resource_id VARCHAR
Resource id.
dataset_id VARCHAR
Dataset the resource belongs to.
title VARCHAR
Resource name.
format VARCHAR
Declared format.
url VARCHAR
Download URL.
read_sql VARCHAR
DuckDB query that loads the URL (NULL when no reader fits).
datastore_active BOOLEAN
Always false in this shape.
Returns columns · depends on the arguments
_id BIGINT
DataStore row id.
portal VARCHAR
Base URL of the portal.
resource_id VARCHAR
Resource id.
dataset_id VARCHAR
Dataset the resource belongs to.
title VARCHAR
Resource name.
format VARCHAR
Declared format.
url VARCHAR
Download URL.
read_sql VARCHAR
DuckDB query that loads the URL (NULL when no reader fits).
datastore_active BOOLEAN
Always false in this shape.
Examples (2)

A DataStore-backed resource reads as typed rows

SELECT count(*) AS orders, sum("Amount") AS total
FROM ckan.main.resource_data('https://data.gov.ie', 'dfb0930a-98a5-45a0-a6b7-e4beb66340e5');

A plain file returns its URL and the read_csv call to load it

SELECT format, url, read_sql
FROM ckan.main.resource_data('https://demo.ckan.org', '73127990-4645-4de7-a5f0-f016d028d984');
Link
resources (portal VARCHAR, tag := VARCHAR, q := VARCHAR, res_format := VARCHAR, page_size := BIGINT, group_name := VARCHAR, fq := VARCHAR) +1 overload 2 examples
Positional arguments
portal VARCHAR
Base URL of the CKAN site, e.g. 'https://demo.ckan.org', 'https://data.gov.ie' or 'https://open.canada.ca/data'. A pasted dataset or /api/3 URL is trimmed to the site root.
Named arguments
tag := VARCHAR
Only datasets with this tag. · default null
q := VARCHAR
Free-text search (Solr syntax), e.g. 'air quality' or 'title:budget'. · default null
res_format := VARCHAR
Only datasets with a resource of this format, e.g. 'CSV'. · default null
page_size := BIGINT
Datasets per request, 1-1000 (portals cap it, 1000 by default). · default 100
group_name := VARCHAR
Only datasets in this group (slug). · default null
fq := VARCHAR
Raw Solr filter query ANDed with the pushed-down filters, e.g. 'num_tags:[5 TO *]'. · default null
Overloads
resources(portal VARCHAR, tag VARCHAR, q VARCHAR, res_format VARCHAR, page_size BIGINT, group_name VARCHAR, fq VARCHAR)resources(tag VARCHAR, q VARCHAR, res_format VARCHAR, page_size BIGINT, group_name VARCHAR, fq VARCHAR)
Returns columns
portal VARCHAR
Base URL of the CKAN portal the row came from.
resource_id VARCHAR
Resource id (use it with datastore()).
dataset_id VARCHAR
Id of the dataset the resource belongs to.
dataset_name VARCHAR
Slug of the dataset the resource belongs to.
dataset_title VARCHAR
Title of the dataset the resource belongs to.
organization VARCHAR
Publishing organization's slug.
title VARCHAR
Resource name (its title on the portal).
description VARCHAR
Resource description.
format VARCHAR
Declared format, e.g. 'CSV', 'JSON', 'XLSX', 'API' (as typed by the publisher).
mimetype VARCHAR
MIME type, when the portal records one.
url VARCHAR
Download or access URL: pass it to read_csv / read_parquet / read_json.
size BIGINT
Size in bytes when the portal records a number.
datastore_active BOOLEAN
True when the rows are loaded into DataStore (read with datastore()).
position INTEGER
Order of the resource within its dataset (0-based).
resource_type VARCHAR
Resource type, e.g. 'file', 'api', 'documentation'.
url_type VARCHAR
'upload' for files stored on the portal, NULL/empty for links.
state VARCHAR
Lifecycle state: 'active'.
created TIMESTAMP WITH TIME ZONE
When the resource was created (UTC).
modified TIMESTAMP WITH TIME ZONE
When the resource's data last changed (last_modified, else metadata_modified, UTC).
dataset_url VARCHAR
The dataset's page on the portal.
raw JSON
The full resource dictionary as returned by the portal.
Examples (2)

Resource formats on the CKAN demo portal

SELECT format, count(*) AS resources
FROM ckan.main.resources('https://demo.ckan.org')
GROUP BY format
ORDER BY resources DESC, format;

CSV purchase-order files on data.gov.ie that are also queryable in DataStore

SELECT dataset_name, title, url
FROM ckan.main.resources('https://data.gov.ie', q := 'purchase orders')
WHERE format = 'CSV' AND datastore_active
ORDER BY dataset_name, position
LIMIT 20;
Link
tags (portal VARCHAR, max_values := BIGINT, q := VARCHAR, fq := VARCHAR) +1 overload 2 examples
Positional arguments
portal VARCHAR
Base URL of the CKAN site, e.g. 'https://demo.ckan.org', 'https://data.gov.ie' or 'https://open.canada.ca/data'. A pasted dataset or /api/3 URL is trimmed to the site root.
Named arguments
max_values := BIGINT
Most tags to return (most used first), 1-100000. · default 1000
q := VARCHAR
Free-text search restricting the datasets counted. · default null
fq := VARCHAR
Raw Solr filter restricting the datasets counted. · default null
Overloads
tags(portal VARCHAR, max_values BIGINT, q VARCHAR, fq VARCHAR)tags(max_values BIGINT, q VARCHAR, fq VARCHAR)
Returns columns
portal VARCHAR
Base URL of the CKAN portal.
tag VARCHAR
Tag name.
dataset_count BIGINT
Number of matching datasets carrying the tag.
Examples (2)

The twenty most used tags on data.gov.ie

SELECT tag, dataset_count
FROM ckan.main.tags('https://data.gov.ie')
ORDER BY dataset_count DESC, tag
LIMIT 20;

How many distinct tags the CKAN demo portal uses

SELECT count(*) AS tags, sum(dataset_count) AS taggings
FROM ckan.main.tags('https://demo.ckan.org');
Link

Credentials

The secret type ckan declares, as reported by the worker itself.

ckan

How to get these credentials

CKAN API token for one portal (scope the secret to the portal URL). Only needed for private datasets and private DataStore tables; public portals need no secret.

secret.sql
CREATE SECRET ckan (
    TYPE ckan,
    api_token '<API_TOKEN>'  -- secret
);
Key Type Required Description
api_token secret VARCHAR — CKAN API token (user settings -> API tokens), sent as the Authorization header.

The worker doesn't mark which keys are required.

Create the secret in the same session, after attaching ckan — the worker registers its secret types at ATTACH. Keys marked secret are masked in duckdb_secrets(); angle-bracket values are placeholders. Read credentials from your environment or secret store in your application and pass them through your SQL client’s parameter bindings. Keep real values out of saved SQL and history. Native DuckDB and Haybarn do not provide a SQL getenv() function.

Try these queries

Metadata of one data.gov.ie dataset

SELECT title, organization, license_id, num_resources, modified
FROM ckan.main.dataset('https://data.gov.ie', 'courts-service-purchase-orders-greater-than-20-000-2026')

Uses dataset

Resource formats on the CKAN demo portal

SELECT format, count(*) AS resources
FROM ckan.main.resources('https://demo.ckan.org')
GROUP BY format
ORDER BY resources DESC, format

Uses resources

Organizations on the CKAN demo portal by number of datasets

SELECT name, title, dataset_count
FROM ckan.main.organizations('https://demo.ckan.org')
ORDER BY dataset_count DESC, name

Uses organizations

data.gov.ie themes by number of datasets

SELECT name, title, dataset_count
FROM ckan.main.groups('https://data.gov.ie')
ORDER BY dataset_count DESC

Uses groups

The twenty most used tags on data.gov.ie

SELECT tag, dataset_count
FROM ckan.main.tags('https://data.gov.ie')
ORDER BY dataset_count DESC, tag
LIMIT 20

Uses tags

The ten most common resource formats on data.gov.ie

SELECT value AS format, dataset_count
FROM ckan.main.facets('https://data.gov.ie', 'res_format')
ORDER BY dataset_count DESC
LIMIT 10

Uses facets

23 more examples in the Catalog, each listed under the table or function it uses.

Questions it can answer

Plain-English questions from the worker's agent test tasks. An AI agent with this catalog attached should answer each one with SQL.

  • On the CKAN portal https://demo.ckan.org, how many resources are there of each format? Return format and count, most common first.
  • Which datasets published by the organization 'the-courts-service' on https://data.gov.ie were modified since 1 January 2026? Give their names.
  • Which CKAN version does the portal at https://demo.ckan.org run?
  • List the organizations on https://demo.ckan.org with how many datasets each has published, largest first.
  • What are the five most common resource formats on https://data.gov.ie, by number of datasets?
  • Which tags are used most on https://demo.ckan.org? Show the top five with their dataset counts.

CKAN is an independent open-source connector from Query.Farm. It is not affiliated with, endorsed by or sponsored by the services, projects or organisations it works with. Product names, logos and trademarks belong to their respective owners.