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://test-data.gov.hr/ckan/api/3/action/datastore_create
Ažuriraj / Umetni https://test-data.gov.hr/ckan/api/3/action/datastore_upsert
Upit https://test-data.gov.hr/ckan/api/3/action/datastore_search
Upit (kroz SQL) https://test-data.gov.hr/ckan/api/3/action/datastore_search_sql
Slanje upita »
Primjer upita (prvih pet rezultata)

https://test-data.gov.hr/ckan/api/3/action/datastore_search?resource_id=62ed041f-047c-4a0e-a1fe-044b7fdb6187&limit=5

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

https://test-data.gov.hr/ckan/api/3/action/datastore_search?resource_id=62ed041f-047c-4a0e-a1fe-044b7fdb6187&q=jones

Primjer upita (kroz SQL naredbu)

https://test-data.gov.hr/ckan/api/3/action/datastore_search_sql?sql=SELECT * from "62ed041f-047c-4a0e-a1fe-044b7fdb6187" WHERE title LIKE 'jones'

Primjer: Javascript »

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

        var data = {
          resource_id: '62ed041f-047c-4a0e-a1fe-044b7fdb6187', // the resource id
          limit: 5, // get 5 results
          q: 'jones' // query for 'jones'
        };
        $.ajax({
          url: 'https://test-data.gov.hr/ckan/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://test-data.gov.hr/ckan/api/3/action/datastore_search?resource_id=62ed041f-047c-4a0e-a1fe-044b7fdb6187&limit=5&q=title:jones'  
      fileobj = urllib.urlopen(url)
      print fileobj.read()