Få tillgång till resursens data via ett webb-API med kraftfullt frågestöd.. Mer information finns i main CKAN Data API and DataStore documentation.
Data-API:et kan anropas via följande åtgärder från CKAN:s "action API".
Skapa | https://data.illinois.gov/sv/api/3/action/datastore_create |
---|---|
Uppdatera/Sätt in | https://data.illinois.gov/sv/api/3/action/datastore_upsert |
Fråga | https://data.illinois.gov/sv/api/3/action/datastore_search |
Fråga (via SQL) | https://data.illinois.gov/sv/api/3/action/datastore_search_sql |
https://data.illinois.gov/sv/api/3/action/datastore_search?resource_id=e8c4170f-25c8-4975-874e-2e92f8085c38&limit=5
https://data.illinois.gov/sv/api/3/action/datastore_search?resource_id=e8c4170f-25c8-4975-874e-2e92f8085c38&q=jones
https://data.illinois.gov/sv/api/3/action/datastore_search_sql?sql=SELECT * from "e8c4170f-25c8-4975-874e-2e92f8085c38" WHERE title LIKE 'jones'
Ett enkelt anrop via ajax (JSONP) till data-API:et via jQuery.
var data = { resource_id: 'e8c4170f-25c8-4975-874e-2e92f8085c38', // the resource id limit: 5, // get 5 results q: 'jones' // query for 'jones' }; $.ajax({ url: 'https://data.illinois.gov/sv/api/3/action/datastore_search', data: data, dataType: 'jsonp', success: function(data) { alert('Total results found: ' + data.result.total) } });
import urllib url = 'https://data.illinois.gov/sv/api/3/action/datastore_search?resource_id=e8c4170f-25c8-4975-874e-2e92f8085c38&limit=5&q=title:jones' fileobj = urllib.urlopen(url) print fileobj.read()