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=82194bb6-0664-4811-8a72-e85cc35b326c&limit=5
https://data.illinois.gov/sv/api/3/action/datastore_search?resource_id=82194bb6-0664-4811-8a72-e85cc35b326c&q=jones
https://data.illinois.gov/sv/api/3/action/datastore_search_sql?sql=SELECT * from "82194bb6-0664-4811-8a72-e85cc35b326c" WHERE title LIKE 'jones'
Ett enkelt anrop via ajax (JSONP) till data-API:et via jQuery.
var data = { resource_id: '82194bb6-0664-4811-8a72-e85cc35b326c', // 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=82194bb6-0664-4811-8a72-e85cc35b326c&limit=5&q=title:jones' fileobj = urllib.urlopen(url) print fileobj.read()