CKAN Data API

パワフルなクエリサポートがあるweb APIを通してリソースデータにアクセス. より詳しい情報は main CKAN Data API and DataStore documentationを参照してください。

エンドポイント »

Data APIはCKAN action APIの次のようなアクションを通してアクセスすることができます。

作成 https://hub.mph.in.gov/ja/api/3/action/datastore_create
更新 / 挿入 https://hub.mph.in.gov/ja/api/3/action/datastore_upsert
クエリ https://hub.mph.in.gov/ja/api/3/action/datastore_search
クエリ (SQL使用) https://hub.mph.in.gov/ja/api/3/action/datastore_search_sql
クエリ »
クエリ例 (最初の5件)

https://hub.mph.in.gov/ja/api/3/action/datastore_search?resource_id=c99b341f-7d1e-4866-be8f-03ee4452fc8a&limit=5

クエリ例 ('jones'を含む結果)

https://hub.mph.in.gov/ja/api/3/action/datastore_search?resource_id=c99b341f-7d1e-4866-be8f-03ee4452fc8a&q=jones

クエリ例 (SQL文使用)

https://hub.mph.in.gov/ja/api/3/action/datastore_search_sql?sql=SELECT * from "c99b341f-7d1e-4866-be8f-03ee4452fc8a" WHERE title LIKE 'jones'

例: Javascript »

jQueryを使用したdata APIへの単純なajax (JSONP) リクエスト

        var data = {
          resource_id: 'c99b341f-7d1e-4866-be8f-03ee4452fc8a', // the resource id
          limit: 5, // get 5 results
          q: 'jones' // query for 'jones'
        };
        $.ajax({
          url: 'https://hub.mph.in.gov/ja/api/3/action/datastore_search',
          data: data,
          dataType: 'jsonp',
          success: function(data) {
            alert('Total results found: ' + data.result.total)
          }
        });
例: Python »
      import urllib
      url = 'https://hub.mph.in.gov/ja/api/3/action/datastore_search?resource_id=c99b341f-7d1e-4866-be8f-03ee4452fc8a&limit=5&q=title:jones'  
      fileobj = urllib.urlopen(url)
      print fileobj.read()