通过 API 来访问与查询数据. Further information in the main CKAN Data API and DataStore documentation.
The Data API can be accessed via the following actions of the CKAN action API.
创建 | https://vital-strategies.l3.ckan.io/zh_CN/api/3/action/datastore_create |
---|---|
更新 / 插入 | https://vital-strategies.l3.ckan.io/zh_CN/api/3/action/datastore_upsert |
查询 | https://vital-strategies.l3.ckan.io/zh_CN/api/3/action/datastore_search |
查询 (通过 SQL) | https://vital-strategies.l3.ckan.io/zh_CN/api/3/action/datastore_search_sql |
https://vital-strategies.l3.ckan.io/zh_CN/api/3/action/datastore_search?resource_id=a49404d0-76c5-4016-ab68-4fbfdb111a1c&limit=5
https://vital-strategies.l3.ckan.io/zh_CN/api/3/action/datastore_search?resource_id=a49404d0-76c5-4016-ab68-4fbfdb111a1c&q=jones
https://vital-strategies.l3.ckan.io/zh_CN/api/3/action/datastore_search_sql?sql=SELECT * from "a49404d0-76c5-4016-ab68-4fbfdb111a1c" WHERE title LIKE 'jones'
使用 Jquery 向 数据 API 发起简单的 ajax (JSONP) 请求
var data = { resource_id: 'a49404d0-76c5-4016-ab68-4fbfdb111a1c', // the resource id limit: 5, // get 5 results q: 'jones' // query for 'jones' }; $.ajax({ url: 'https://vital-strategies.l3.ckan.io/zh_CN/api/3/action/datastore_search', data: data, dataType: 'jsonp', success: function(data) { alert('Total results found: ' + data.result.total) } });
import urllib url = 'https://vital-strategies.l3.ckan.io/zh_CN/api/3/action/datastore_search?resource_id=a49404d0-76c5-4016-ab68-4fbfdb111a1c&limit=5&q=title:jones' fileobj = urllib.urlopen(url) print fileobj.read()