CKAN資料API

透過一擁有強大查詢功能支援的網路API來存取資源之資料. 進一步的資訊位於 CKAN Data API 及 DataStore 文件.

可使用下列之CKAN action API所提供的功能來存取資料API。

建立 http://ckan.hoda.jp/zh_Hant_TW/api/3/action/datastore_create
更新 / 插入 http://ckan.hoda.jp/zh_Hant_TW/api/3/action/datastore_upsert
查詢 http://ckan.hoda.jp/zh_Hant_TW/api/3/action/datastore_search

查詢之範例 (前5個結果)

http://ckan.hoda.jp/zh_Hant_TW/api/3/action/datastore_search?resource_id=85fc191f-43bd-44f4-9fc9-b9e470d9f663&limit=5

查詢之範例 (包含字串 'jones' 的結果)

http://ckan.hoda.jp/zh_Hant_TW/api/3/action/datastore_search?resource_id=85fc191f-43bd-44f4-9fc9-b9e470d9f663&q=jones

使用jQuery對資料API發出一個簡單的ajax(JSONP)請求。

          var data = {
            resource_id: '85fc191f-43bd-44f4-9fc9-b9e470d9f663', // the resource id
            limit: 5, // get 5 results
            q: 'jones' // query for 'jones'
          };
          $.ajax({
            url: 'http://ckan.hoda.jp/zh_Hant_TW/api/3/action/datastore_search',
            data: data,
            dataType: 'jsonp',
            success: function(data) {
              alert('Total results found: ' + data.result.total)
            }
          });
        import urllib.request
        url = 'http://ckan.hoda.jp/zh_Hant_TW/api/3/action/datastore_search?resource_id=85fc191f-43bd-44f4-9fc9-b9e470d9f663&limit=5&q=title:jones'  
        fileobj = urllib.request.urlopen(url)
        print(fileobj.read())