CKAN 数据 API

通过 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://datahub.h2awsm.org/zh_Hans_CN/api/3/action/datastore_create
更新 / 插入 https://datahub.h2awsm.org/zh_Hans_CN/api/3/action/datastore_upsert
查询 https://datahub.h2awsm.org/zh_Hans_CN/api/3/action/datastore_search
查询 (通过 SQL) https://datahub.h2awsm.org/zh_Hans_CN/api/3/action/datastore_search_sql
查询中 »
查询实例(头5条结果)

https://datahub.h2awsm.org/zh_Hans_CN/api/3/action/datastore_search?resource_id=a1c3d287-a849-4ea2-9722-7e56fc21720c&limit=5

查询实例(结果中含 'jones')

https://datahub.h2awsm.org/zh_Hans_CN/api/3/action/datastore_search?resource_id=a1c3d287-a849-4ea2-9722-7e56fc21720c&q=jones

查询示例(通过 SQL 语句)

https://datahub.h2awsm.org/zh_Hans_CN/api/3/action/datastore_search_sql?sql=SELECT * from "a1c3d287-a849-4ea2-9722-7e56fc21720c" WHERE title LIKE 'jones'

示例:Javascript »

使用 Jquery 向 数据 API 发起简单的 ajax (JSONP) 请求

        var data = {
          resource_id: 'a1c3d287-a849-4ea2-9722-7e56fc21720c', // the resource id
          limit: 5, // get 5 results
          q: 'jones' // query for 'jones'
        };
        $.ajax({
          url: 'https://datahub.h2awsm.org/zh_Hans_CN/api/3/action/datastore_search',
          data: data,
          dataType: 'jsonp',
          success: function(data) {
            alert('Total results found: ' + data.result.total)
          }
        });
示例:Python »
      import urllib
      url = 'https://datahub.h2awsm.org/zh_Hans_CN/api/3/action/datastore_search?resource_id=a1c3d287-a849-4ea2-9722-7e56fc21720c&limit=5&q=title:jones'  
      fileobj = urllib.urlopen(url)
      print fileobj.read()