เข้าถึงทรัพยากรข้อมูลผ่าน API ของเว็บด้วยภาษาสอบถามที่ทรงพลัง. Further information in the main CKAN Data API and DataStore documentation.
Data API สามารถเข้าถึงได้ด้วยการเรียกใช้ CKAN action API
สร้าง | https://gdcatalognhic.nha.co.th/th/api/3/action/datastore_create |
---|---|
ปรับปรุง/เพิ่ม | https://gdcatalognhic.nha.co.th/th/api/3/action/datastore_upsert |
เรียกดูข้อมูล | https://gdcatalognhic.nha.co.th/th/api/3/action/datastore_search |
คำขอแบบ ajax (JSONP) พื้นฐาน เพื่อร้องขอข้อมูลผ่าน API โดยใช้ jQuery
var data = { resource_id: '2295b9dd-d275-4b0d-94e7-37d89772863c', // the resource id limit: 5, // get 5 results q: 'jones' // query for 'jones' }; $.ajax({ url: 'https://gdcatalognhic.nha.co.th/th/api/3/action/datastore_search', data: data, dataType: 'jsonp', success: function(data) { alert('Total results found: ' + data.result.total) } });
import urllib url = 'https://gdcatalognhic.nha.co.th/th/api/3/action/datastore_search?limit=5&resource_id=2295b9dd-d275-4b0d-94e7-37d89772863c&q=title:jones' fileobj = urllib.urlopen(url) print fileobj.read()