CKAN API podataka

Pristup resursima podataka kroz web API uz široku podršku upita. Further information in the main CKAN Data API and DataStore documentation.

Završne točke »

API-ju podataka je moguće pristupiti korištenjem CKAN API akcija

Kreiraj https://ckan.hoda.jp/hr/api/3/action/datastore_create
Ažuriraj / Umetni https://ckan.hoda.jp/hr/api/3/action/datastore_upsert
Upit https://ckan.hoda.jp/hr/api/3/action/datastore_search
Upit (kroz SQL) https://ckan.hoda.jp/hr/api/3/action/datastore_search_sql
Slanje upita »
Primjer upita (prvih pet rezultata)

https://ckan.hoda.jp/hr/api/3/action/datastore_search?resource_id=354556b7-478b-48ce-bf51-2871e4bab1e4&limit=5

Primjer upita (rezultati koji sadrže 'jones')

https://ckan.hoda.jp/hr/api/3/action/datastore_search?resource_id=354556b7-478b-48ce-bf51-2871e4bab1e4&q=jones

Primjer upita (kroz SQL naredbu)

https://ckan.hoda.jp/hr/api/3/action/datastore_search_sql?sql=SELECT * from "354556b7-478b-48ce-bf51-2871e4bab1e4" WHERE title LIKE 'jones'

Primjer: Javascript »

Jednostavan ajax (JSONP) upit prema API-ju podataka korištenjem jQuery.

  var data = {
    resource_id: '354556b7-478b-48ce-bf51-2871e4bab1e4', // the resource id
    limit: 5, // get 5 results
    q: 'jones' // query for 'jones'
  };
  $.ajax({
    url: 'https://ckan.hoda.jp/hr/api/3/action/datastore_search',
    data: data,
    dataType: 'jsonp',
    success: function(data) {
      alert('Total results found: ' + data.result.total)
    }
  });
Primjer: Python »
import urllib
url = 'https://ckan.hoda.jp/hr/api/3/action/datastore_search?resource_id=354556b7-478b-48ce-bf51-2871e4bab1e4&limit=5&q=title:jones'  
fileobj = urllib.urlopen(url)
print fileobj.read()