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.):
Get a full JSON metadata representation of a dataset or resource:
Search for datasets or resources matching a query:
Get an activity stream of recently changed datasets:
In the above examples, the action functions are
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|
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).