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.

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

Kreiraj https://homologa.cge.mg.gov.br/hr/api/3/action/datastore_create
Ažuriraj / Umetni https://homologa.cge.mg.gov.br/hr/api/3/action/datastore_upsert
Upit https://homologa.cge.mg.gov.br/hr/api/3/action/datastore_search
Upit (kroz SQL) https://homologa.cge.mg.gov.br/hr/api/3/action/datastore_search_sql

Primjer upita (prvih pet rezultata)

https://homologa.cge.mg.gov.br/hr/api/3/action/datastore_search?resource_id=26127067-35fe-40d1-98a9-4d0a85455f5c&limit=5

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

https://homologa.cge.mg.gov.br/hr/api/3/action/datastore_search?resource_id=26127067-35fe-40d1-98a9-4d0a85455f5c&q=jones

Primjer upita (kroz SQL naredbu)

https://homologa.cge.mg.gov.br/hr/api/3/action/datastore_search_sql?sql=SELECT * from "26127067-35fe-40d1-98a9-4d0a85455f5c" WHERE title LIKE 'jones'

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

          var data = {
            resource_id: '26127067-35fe-40d1-98a9-4d0a85455f5c', // the resource id
            limit: 5, // get 5 results
            q: 'jones' // query for 'jones'
          };
          $.ajax({
            url: 'https://homologa.cge.mg.gov.br/hr/api/3/action/datastore_search',
            data: data,
            dataType: 'jsonp',
            success: function(data) {
              alert('Total results found: ' + data.result.total)
            }
          });
        import urllib.request
        url = 'https://homologa.cge.mg.gov.br/hr/api/3/action/datastore_search?resource_id=26127067-35fe-40d1-98a9-4d0a85455f5c&limit=5&q=title:jones'  
        fileobj = urllib.request.urlopen(url)
        print(fileobj.read())