Data API

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

The Data API can be accessed via the following actions of the action API.

สร้าง https://data.haiphong.gov.vn/th/api/3/action/datastore_create
ปรับปรุง/เพิ่ม https://data.haiphong.gov.vn/th/api/3/action/datastore_upsert
เรียกดูข้อมูล https://data.haiphong.gov.vn/th/api/3/action/datastore_search

ตัวอย่างเรียกข้อมูล (5 ผลลัพธ์แรก)

https://data.haiphong.gov.vn/th/api/3/action/datastore_search?resource_id=b9fe1b77-d359-473b-a84e-ba4e8f6236d6&limit=5

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

https://data.haiphong.gov.vn/th/api/3/action/datastore_search?resource_id=b9fe1b77-d359-473b-a84e-ba4e8f6236d6&q=jones

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

          var data = {
            resource_id: 'b9fe1b77-d359-473b-a84e-ba4e8f6236d6', // the resource id
            limit: 5, // get 5 results
            q: 'jones' // query for 'jones'
          };
          $.ajax({
            url: 'https://data.haiphong.gov.vn/th/api/3/action/datastore_search',
            data: data,
            dataType: 'jsonp',
            success: function(data) {
              alert('Total results found: ' + data.result.total)
            }
          });
        import urllib.request
        url = 'https://data.haiphong.gov.vn/th/api/3/action/datastore_search?resource_id=b9fe1b77-d359-473b-a84e-ba4e8f6236d6&limit=5&q=title:jones'  
        fileobj = urllib.request.urlopen(url)
        print(fileobj.read())