Skip to content

Using Command Line Tools to Access the CKAN API

Command-line tools let you test CKAN endpoints quickly without writing scripts.
They’re ideal for exploring datasets, checking parameters, and debugging queries.


HTTPie

HTTPie is a user‑friendly command‑line HTTP client.
It provides color‑coded, structured JSON output, making responses easier to read.

Basic usage pattern:

http <api_endpoint>
HTTPie Examples

To get a list of all the themes within the CanWIN Data Catalogue, call the group_list action function by entering this command at CL:

http 'https://canwin-datahub.ad.umanitoba.ca/data/api/3/action/group_list'

Here is an example of querying the DataStore for a certain resource by using the datastore_search action function:

http 'https://canwin-datahub.ad.umanitoba.ca/data/api/3/action/datastore_search?resource_id=c5c16064-e2b3-4618-9b27-0dbf5c1388c2&limit=2'

Example JSON response (trimmed):

{
  "help": "https://canwin-datahub.ad.umanitoba.ca/data/api/3/action/help_show?name=group_list",
  "result": [
    "modelling",
    "cryosphere",
    "freshwater",
    "marine",
    "remote-sensing"
  ],
  "success": true
}

cURL

cURL is a widely available command‑line tool for HTTP requests.

It outputs raw JSON (no color‑coding), but is preinstalled on most systems.

Basic usage pattern:

curl <api_endpoint>
cURL Examples

To get a list of all the themes within the CanWIN Data Catalogue, call the group_list action function by entering this command at CL:

curl https://canwin-datahub.ad.umanitoba.ca/data/api/3/action/group_list

Here is an example of querying the DataStore for a certain resource by using the datastore_search action function:

curl https://canwin-datahub.ad.umanitoba.ca/data/api/3/action/datastore_search?resource_id=c5c16064-e2b3-4618-9b27-0dbf5c1388c2&limit=2

HTTPie vs cURL

Tool Pros Cons
HTTPie Pretty JSON, simpler syntax Requires installation
cURL Preinstalled on most systems Raw, less readable

Authentication

Some API functions require an API key.

Include it in your request using the Authorization header:

http GET https://canwin-datahub.ad.umanitoba.ca/data/api/3/action/package_list \ "Authorization:YOUR-API-KEY”
curl -H "Authorization: YOUR-API-KEY" \
     https://canwin-datahub.ad.umanitoba.ca/data/api/3/action/package_list

Common Pitfall

In HTTPie, always wrap URLs containing ? parameters in quotes. Example:

http 'https://.../datastore_search?resource_id=...&q=fish'