stefangrotz / OpenDataGermanyGPT

A ChatGPT GPT that can acces open data portals using the CKAN API and SPARQL for Germany, Switzerland and Austria
https://chat.openai.com/g/g-uiJQsroGg-open-data-portals-germany
MIT License
60 stars 8 forks source link

Auto generated action files for all portals from Wikidata #2

Open stefangrotz opened 8 months ago

stefangrotz commented 8 months ago

If we want to support all available CKAN APIs in the DACH region, generating the API files automatically makes sense.

First concept: https://github.com/stefangrotz/OpenDataGermanyGPT/blob/main/actions/create-api-files.py

Todo:

stefangrotz commented 8 months ago

Here is a query for all CKAN portals in the DACH region:

SELECT ?portal ?portalLabel ?countryLabel ?hasApiEndpoint ?website ("CKAN" AS ?protocol)  # Adding CKAN as a static value for protocol
WHERE {
  ?portal wdt:P31 wd:Q27031827;                        # Searching for instances of Open Data Portals
          wdt:P17 ?country.                            # Restricting to a country, variable ?country
          VALUES ?country { wd:Q183 wd:Q40 wd:Q39 }    # Germany (Q183), Austria (Q40), Switzerland (Q39)
          OPTIONAL { ?portal wdt:P6269 ?hasApiEndpoint }   # Searching for API Endpoint properties (if available)
          OPTIONAL { ?portal wdt:P6269 ?apiEndpoint.    # Searching for API Endpoint properties (if available)
                     ?apiEndpoint wdt:P2700 wd:Q105592698;   # Ensuring the API uses the CKAN protocol
                     BIND(CONCAT(STR(?apiEndpoint)) AS ?hasApiEndpoint) }
          OPTIONAL { ?portal wdt:P856 ?website }           # Searching for the official website (if available)
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en". 
                           ?portal rdfs:label ?portalLabel .
                           ?country rdfs:label ?countryLabel . }
}
ORDER BY DESC(?hasApiEndpoint)
stefangrotz commented 8 months ago

I updated the action creation script to use a JSON from wikidata.

Edit: latest update also directly queries wikidata.

TODO:

stefangrotz commented 8 months ago

There is now a GitHub action to create all V3 portals: https://github.com/stefangrotz/OpenDataGermanyGPT/actions