เข้าถึงทรัพยากรข้อมูลผ่าน API ของเว็บด้วยภาษาสอบถามที่ทรงพลัง. Further information in the main CKAN Data API and DataStore documentation.
Data API สามารถเข้าถึงได้ด้วยการเรียกใช้ CKAN action API
สร้าง | https://geodirekt.sokigohosting.com/th/api/3/action/datastore_create |
---|---|
ปรับปรุง/เพิ่ม | https://geodirekt.sokigohosting.com/th/api/3/action/datastore_upsert |
เรียกดูข้อมูล | https://geodirekt.sokigohosting.com/th/api/3/action/datastore_search |
เรียกดูข้อมูล (ผ่าน SQL) | https://geodirekt.sokigohosting.com/th/api/3/action/datastore_search_sql |
https://geodirekt.sokigohosting.com/th/api/3/action/datastore_search?resource_id=e8d873cf-1dc5-4d8d-85f7-3ef52d276883&limit=5
https://geodirekt.sokigohosting.com/th/api/3/action/datastore_search?q=jones&resource_id=e8d873cf-1dc5-4d8d-85f7-3ef52d276883
https://geodirekt.sokigohosting.com/th/api/3/action/datastore_search_sql?sql=SELECT * from "e8d873cf-1dc5-4d8d-85f7-3ef52d276883" WHERE title LIKE 'jones'
คำขอแบบ ajax (JSONP) พื้นฐาน เพื่อร้องขอข้อมูลผ่าน API โดยใช้ jQuery
var data = { resource_id: 'e8d873cf-1dc5-4d8d-85f7-3ef52d276883', // the resource id limit: 5, // get 5 results q: 'jones' // query for 'jones' }; $.ajax({ url: 'https://geodirekt.sokigohosting.com/th/api/3/action/datastore_search', data: data, dataType: 'jsonp', success: function(data) { alert('Total results found: ' + data.result.total) } });
import urllib url = 'https://geodirekt.sokigohosting.com/th/api/3/action/datastore_search?resource_id=e8d873cf-1dc5-4d8d-85f7-3ef52d276883&limit=5&q=title:jones' fileobj = urllib.urlopen(url) print fileobj.read()