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