1

Is the purpose of CKAN Rest API to get meta-data information of the actual data? Like revisions, available resources under a dataset?

http://demo.ckan.org/api/1/rest/dataset/formula-1 http://demo.ckan.org/api/2/rest/dataset/formula-1

It is so confusing with two different API versions and moreover how to navigate to the actual data with REST API? I was expecting to filter the data using REST API out of the box like http://demo.ckan.org/api/1/rest/dataset/formula-1/resources/f6b468e8-c7fe-4534-98b3-189030cb49dd/extensao/html

formula-1 has a resource with id f6b468e8-c7fe-4534-98b3-189030cb49dd and contains attribute 'extensao' with content as html

Cannot access even with Action API http://demo.ckan.org/api/action/datastore_search?resource_id=f6b468e8-c7fe-4534-98b3-189030cb49dd

Note: I already know that on action api one could use filters (if action api works) but it's not what I am looking for since it is not REST.

AMKhan
  • 131
  • 1
  • 4

1 Answers1

2

The purpose of the REST API was to expose the metadata stored in CKAN. It doesn't expose the data in CKAN's datastore.

The second version of the API is very similar to the first, but when you ask for lists of packages or groups it returns them expressed as ids rather than names. This is less readable, but names occasionally change, so using ids is more helpful to machines that want to keep track of things. If you can identify what's confusing in the docs then we could improve them, or simply create a pull request yourself.

I was expecting to filter the data using REST API out of the box like http://demo.ckan.org/api/1/rest/dataset/formula-1/resources/f6b468e8-c7fe-4534-98b3-189030cb49dd/extensao/html

You're trying to dig into the resource using the path of the URL. I'm not clear that is in any common definition of RESTful. CKAN doesn't support it anyway.

Cannot access even with Action API http://demo.ckan.org/api/action/datastore_search?resource_id=f6b468e8-c7fe-4534-98b3-189030cb49dd

That searches in the CKAN Datastore. It gives error Not found: Resource \"f6b468e8-c7fe-4534-98b3-189030cb49dd\" was not found because that resource has not been put in the Datastore. The Datastore only works with tabular data, but this dataset is a JSON file i.e. hierarchical data. You could do filtering if it had been a CSV.

CKAN's REST api was deprecated a couple of years ago. The Action API is better in lots of respects and is maintained.

D Read
  • 3,175
  • 1
  • 15
  • 25
  • Thanks for the reply. If I got you right, action API is the new way to access resources and I can forgot about REST api since it's deprecated (we haven't started using CKan fully yet so it's no point in using deprecated API). Should I be using any extension on top of CKan for what I am looking for (A REST API on the data)? Or is there any way CKan offers it by default. – AMKhan Feb 26 '16 at 11:40
  • It's officially deprecated, but there are a few bits like some of the utils and the revision stuff which has not made it to the Action API. In addition, some users are really happy to use a simple RESTful API for simple purposes, and there is no sign of it being removed from CKAN afaict. – D Read Sep 20 '16 at 15:20