query-dataset

Query tabular data from Montréal's open data portal via the CKAN DataStore API.

1|Updated Mar 13, 2026
One-click install
npx skills add https://github.com/alistaircroll/montreal-open-data --skill query-dataset-alistaircroll
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: query-dataset
Source: https://github.com/alistaircroll/montreal-open-data/tree/main/skills/core/query-dataset
Command: npx skills add https://github.com/alistaircroll/montreal-open-data --skill query-dataset-alistaircroll

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires requests.

What problem does it solve? Analysts and developers need to retrieve, filter, and aggregate records from Montréal's open data portal without downloading entire datasets, but the CKAN DataStore API has specific conventions (resource UUIDs, SQL dialect rules, pagination) that are easy to get wrong. ## Core Features & Use Cases - Filtered Queries: Run exact-match filters, full-text search, field selection, sorting, and pagination through the datastore_search endpoint. - SQL Aggregation: Execute SQL queries with GROUP BY, LIKE patterns, date ranges, and aggregate functions via datastore_search_sql. - Direct Downloads: Retrieve non-DataStore resources such as GeoJSON, Shapefiles, and PDFs by their download URLs. - Use Case: Ask how many trees are in the Ville-Marie borough; the skill resolves the resource UUID, runs a filtered datastore_search or a GROUP BY SQL query, and returns the count with the total record metadata. ## Quick Start Ask the agent to count how many trees are in the Plateau borough using Montréal's open data portal.

Frequently Asked Questions about query-dataset

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I query Montréal open data with the CKAN DataStore API?

First get the resource UUID from package_show for the dataset slug, then call datastore_search with that resource_id plus optional filters, fields, sort, and limit parameters. Only resources with datastore_active set to true can be queried this way.

How do I run SQL queries on CKAN DataStore resources?

Use the datastore_search_sql endpoint with a SQL string where the table name is the resource UUID in double quotes. Column names with accents or spaces must be double-quoted, string values use single quotes, and JOINs across resources are not supported.

What is the row limit for CKAN DataStore queries?

Each query returns a maximum of 32,000 rows, with a default limit of 100. To retrieve an entire dataset, paginate with limit and offset parameters until a page returns fewer rows than the limit.

Why do numeric comparisons fail in CKAN SQL queries?

Many datasets store numeric fields as text, so comparisons and aggregations behave unexpectedly. Use CAST("field" AS FLOAT) or CAST("field" AS INTEGER) in the SQL query to convert values before numeric operations.

Can I query resources that are not in the DataStore?

No, resources without datastore_active cannot be queried through the API. For GeoJSON, Shapefile, PDF, or GBFS resources, extract the download URL from package_show and fetch the file directly with curl.