Search code examples
ckan

Search API in CKAN using a specific field


I want to use CKAN API to select a specific dataset using a specific field in my schema. The package search API does not work on specific dataset. Does anyone have a solution to this?


Solution

  • You can search on any default field using the q=<field_name>:<term> syntax, eg:

    https://demo.ckan.org/api/action/package_search?q=name:sample*

    https://demo.ckan.org/api/action/package_search?q=version:1.0

    This can also be applied to custom fields added with ckanext-scheming, eg:

    https://open.canada.ca/data/api/action/package_search?q=jurisdiction:federal

    If you actually want to select just one dataset and you know its id or name you can use package_show:

    https://demo.ckan.org/api/action/package_show?id=sample-dataset-1

    https://demo.ckan.org/api/action/package_show?id=c322307a-b871-44fe-a602-32ee8437ff04