Få tillgång till resursens data via ett webb-API med kraftfullt frågestöd.. Further information in the 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.openstate.eu/sv/api/3/action/datastore_create |
---|---|
Uppdatera/Sätt in | https://data.openstate.eu/sv/api/3/action/datastore_upsert |
Fråga | https://data.openstate.eu/sv/api/3/action/datastore_search |
Fråga (via SQL) | https://data.openstate.eu/sv/api/3/action/datastore_search_sql |
https://data.openstate.eu/sv/api/3/action/datastore_search?resource_id=24bb6b50-a038-401d-b879-3a4a0a2fb1a9&limit=5
https://data.openstate.eu/sv/api/3/action/datastore_search?q=jones&resource_id=24bb6b50-a038-401d-b879-3a4a0a2fb1a9
https://data.openstate.eu/sv/api/3/action/datastore_search_sql?sql=SELECT * from "24bb6b50-a038-401d-b879-3a4a0a2fb1a9" WHERE title LIKE 'jones'
Ett enkelt anrop via ajax (JSONP) till data-API:et via jQuery.
var data = { resource_id: '24bb6b50-a038-401d-b879-3a4a0a2fb1a9', // the resource id limit: 5, // get 5 results q: 'jones' // query for 'jones' }; $.ajax({ url: 'https://data.openstate.eu/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.openstate.eu/sv/api/3/action/datastore_search?resource_id=24bb6b50-a038-401d-b879-3a4a0a2fb1a9&limit=5&q=title:jones' fileobj = urllib.urlopen(url) print fileobj.read()