API podataka

Pristup resursima podataka kroz web API uz široku podršku upita. Further information in the main Data API and DataStore documentation.

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

Kreiraj https://data.haiphong.gov.vn/bs/api/3/action/datastore_create
Ažuriraj / Unesi https://data.haiphong.gov.vn/bs/api/3/action/datastore_upsert
Upit https://data.haiphong.gov.vn/bs/api/3/action/datastore_search

Primjer upita (prvih 5 rezultata)

https://data.haiphong.gov.vn/bs/api/3/action/datastore_search?resource_id=b6170719-0e1e-4635-ab13-02e0eca9b44d&limit=5

Primjer upita (rezultati koji sadrže 'jones')

https://data.haiphong.gov.vn/bs/api/3/action/datastore_search?resource_id=b6170719-0e1e-4635-ab13-02e0eca9b44d&q=jones

Jednostavan ajax (JSONP) upit prema API-ju podataka korištenjem jQuery.

          var data = {
            resource_id: 'b6170719-0e1e-4635-ab13-02e0eca9b44d', // the resource id
            limit: 5, // get 5 results
            q: 'jones' // query for 'jones'
          };
          $.ajax({
            url: 'https://data.haiphong.gov.vn/bs/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/bs/api/3/action/datastore_search?resource_id=b6170719-0e1e-4635-ab13-02e0eca9b44d&limit=5&q=title:jones'  
        fileobj = urllib.request.urlopen(url)
        print(fileobj.read())