CKAN Data API

Zugriff auf Ressourcen per Web-Schnittstelle mit umfangreichen Suchmöglichkeiten. Weiterführende Information in der zentralen CKAN Data API und DataStore Dokumentation.

API-Schnittstelle »

Die Daten-Schnittstelle (Data-API) kann über folgende Schnittstellenbefehle der CKAN Action API erreicht werden.

Erstellen http://opendata.city.niigata.lg.jp/de/api/3/action/datastore_create
Aktualisieren / Einfügen http://opendata.city.niigata.lg.jp/de/api/3/action/datastore_upsert
Abfrage http://opendata.city.niigata.lg.jp/de/api/3/action/datastore_search
Abfrage (mit SQL) http://opendata.city.niigata.lg.jp/de/api/3/action/datastore_search_sql
Abfrage läuft »
Abfragebeispiel (erste 5 Ergebnisse)

http://opendata.city.niigata.lg.jp/de/api/3/action/datastore_search?resource_id=687d5db8-df85-4312-a360-8e444764325e&limit=5

Abfragebeispiel (Ergebnisse die 'jones' enthalten)

http://opendata.city.niigata.lg.jp/de/api/3/action/datastore_search?resource_id=687d5db8-df85-4312-a360-8e444764325e&q=jones

Abfragebeispiel (mit SQL Befehl)

http://opendata.city.niigata.lg.jp/de/api/3/action/datastore_search_sql?sql=SELECT * from "687d5db8-df85-4312-a360-8e444764325e" WHERE title LIKE 'jones'

Beispiel: Javascript »

Eine einfache AJAX (JSONP) Abfrage des Data API mit jQuery.

        var data = {
          resource_id: '687d5db8-df85-4312-a360-8e444764325e', // the resource id
          limit: 5, // get 5 results
          q: 'jones' // query for 'jones'
        };
        $.ajax({
          url: 'http://opendata.city.niigata.lg.jp/de/api/3/action/datastore_search',
          data: data,
          dataType: 'jsonp',
          success: function(data) {
            alert('Total results found: ' + data.result.total)
          }
        });
Beispiel: Python »
      import urllib
      url = 'http://opendata.city.niigata.lg.jp/de/api/3/action/datastore_search?resource_id=687d5db8-df85-4312-a360-8e444764325e&limit=5&q=title:jones'  
      fileobj = urllib.urlopen(url)
      print fileobj.read()