Skip to content

Overview of the CKAN and DataStore APIs

The CKAN API

The CKAN Action API is an RPC-style API that allows you to access all of CKAN's core features programmatically using action functions. All the website’s core functionality can be used by calling the CKAN API. This includes everything you can do with the web interface and more! 🥳

For example, through this API service, users can:

  • Get JSON-formatted lists of CanWIN's data outputs (datasets, projects, publications, etc.):

    https://canwin-datahub.ad.umanitoba.ca/data/api/3/action/package_list
    
  • Get a full JSON metadata representation of a dataset or resource:

    https://canwin-datahub.ad.umanitoba.ca/data/api/3/action/package_show?id=96f9db0e-06cc-4888-9a48-a065efae24fb
    
  • Search for datasets or resources matching a query:

    https://canwin-datahub.ad.umanitoba.ca/data/api/3/action/package_search?q=Greenedge
    
  • Get an activity stream of recently changed datasets:

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

In the above examples, the action functions are package_list, package_show, package_search and recently_changed_packages_activity_list.

Note

There may be some differences between the terms seen on the CanWIN site, and the terms used in the API action functions. These are highlighted in the table below. For example, you will see the term keyword on the CanWIN site, but to search for keywords via the API, the action function uses the word tag. The function would therefore be tag_list, not keyword_list.

CanWIN's CKAN Site Terms (Front end) CKAN API Terms Search Example
Keyword Tag https://canwin-datahub.ad.umanitoba.ca/data/api/3/action/tag_list
Dataset Package https://canwin-datahub.ad.umanitoba.ca/data/api/3/action/package_list
Facility Organization https://canwin-datahub.ad.umanitoba.ca/data/api/3/action/organization_list
Theme Group https://canwin-datahub.ad.umanitoba.ca/data/api/3/action/group_list

For a list of all CKAN's API functions, see the Action API reference.


The DataStore API

While the CKAN API allows for access to CKAN's core features, the DataStore API allows for manipulation of individual data resources (data files/tables). This is made possible by the CKAN DataStore extension, which provides an ad hoc database for storage of structured data from CKAN resources. When a resource is added to the DataStore, the Data API allows you to search, filter and update the data, without having to download and upload the entire data file.

In the DataStore, individual data elements are accessible and queryable. For example, one would be able to access individual spreadsheet rows via the API, as well as make queries over the spreadsheet contents. New data can be inserted, and existing data can be updated or deleted. You can also add a new column to an existing table, even if the DataStore resource already contains some data.

Like the CKAN API, the DataStore API also uses action functions. A commonly used action function is datastore_search, which allows a user to search data within a specific resource. Read more about how to use this function on the Steps to calling the API page.

Finding DataStore API commands on a resource page

For each structured resource on CanWIN's dataset pages (for example, a CSV file), a green Data API button will show up, as shown in Image 1 below. By clicking on this button, a user will be provided with examples of DataStore endpoints and queries for that particular resource (Image 2).

Image title

Image 1 – The Data API button for a structured resource (CSV file)

Image title

Image 2 – Data API endpoints and query examples