CKAN Data API

เข้าถึงทรัพยากรข้อมูลผ่าน API ของเว็บด้วยภาษาสอบถามที่ทรงพลัง. Further information in the main CKAN Data API and DataStore documentation.

ปลายทาง »

Data API สามารถเข้าถึงได้ด้วยการเรียกใช้ CKAN action API

สร้าง https://data.city.fukuyama.hiroshima.jp/th/api/3/action/datastore_create
ปรับปรุง/เพิ่ม https://data.city.fukuyama.hiroshima.jp/th/api/3/action/datastore_upsert
เรียกดูข้อมูล https://data.city.fukuyama.hiroshima.jp/th/api/3/action/datastore_search
เรียกดูข้อมูล (ผ่าน SQL) https://data.city.fukuyama.hiroshima.jp/th/api/3/action/datastore_search_sql
กำลังเรียกข้อมูล »
ตัวอย่างเรียกข้อมูล (5 ผลลัพธ์แรก)

https://data.city.fukuyama.hiroshima.jp/th/api/3/action/datastore_search?resource_id=dc48c5be-6efc-49d0-8f1f-63a965b8d184&limit=5

ตัวอย่างเรียกข้อมูล (ผลลัพธ์มีคำว่า 'jones')

https://data.city.fukuyama.hiroshima.jp/th/api/3/action/datastore_search?resource_id=dc48c5be-6efc-49d0-8f1f-63a965b8d184&q=jones

ตัวอย่างเรียกข้อมูล (โดยการใช้คำสั่ง SQL)

https://data.city.fukuyama.hiroshima.jp/th/api/3/action/datastore_search_sql?sql=SELECT * from "dc48c5be-6efc-49d0-8f1f-63a965b8d184" WHERE title LIKE 'jones'

ตัวอย่าง: Javascript »

คำขอแบบ ajax (JSONP) พื้นฐาน เพื่อร้องขอข้อมูลผ่าน API โดยใช้ jQuery

        var data = {
          resource_id: 'dc48c5be-6efc-49d0-8f1f-63a965b8d184', // the resource id
          limit: 5, // get 5 results
          q: 'jones' // query for 'jones'
        };
        $.ajax({
          url: 'https://data.city.fukuyama.hiroshima.jp/th/api/3/action/datastore_search',
          data: data,
          dataType: 'jsonp',
          success: function(data) {
            alert('Total results found: ' + data.result.total)
          }
        });
ตัวอย่าง: Python »
      import urllib
      url = 'https://data.city.fukuyama.hiroshima.jp/th/api/3/action/datastore_search?resource_id=dc48c5be-6efc-49d0-8f1f-63a965b8d184&limit=5&q=title:jones'  
      fileobj = urllib.urlopen(url)
      print fileobj.read()