Skip to content

FAqT Service for CKAN Datasets

timrdf edited this page Jan 2, 2013 · 14 revisions

What is first

What we will cover

This page describes how to use the ckanclient within a FAqT Service to talk to a varying number of CKAN instances.

Let's get to it!

The following services implement how to communicate to a CKAN instance for every resource processed:

      print 'processing ' + input.subject
      base = input.subject.replace('/$','') 
      api  = base

      ckan = ckanclient.CkanClient(input.subject+'/api')
  • lift-ckan.py uses the default ckanclient, but will change it if the dataset is attributed to a CKAN instance:
      ckan = self.ckan
      if len(input.prov_wasAttributedTo) > 0:
         agent = input.prov_wasAttributedTo.first
         print 'CKAN: ' + agent.subject
         if ns.DATAFAQS['CKAN'] in agent.rdf_type:
            ckan = ckanclient.CkanClient(input.prov_wasAttributedTo.first.subject+'/api') 

For example, the following input will lead the FAqT Service to call http://hub.healthdata.gov/api (the /api is appended to the URI of the CKAN):

<http://hub.healthdata.gov/dataset/hospital-compare>
   a datafaqs:CKANDataset;
   rdfs:comment "Omitting datafaqs:ckan_identifier will fall back to parsing the URI.";
   prov:wasAttributedTo <http://hub.healthdata.gov>;
.
<http://hub.healthdata.gov>
   a datafaqs:CKAN;
   rdfs:comment "If the CKANDataset was attributed to a CKAN, ask that CKAN about it.";
.

What is next

Clone this wiki locally