Schweizer Lernbegleiter

Schweizer Lernbegleiter · Actions GPT

OpenData Switzerland CKAN API

API for accessing datasets and related metadata on opendata.swiss.

  • GET /package_searchSearch for packages (datasets) with specified criteria.
  • GET /package_showGet details of a specific package (dataset).
  • GET /organization_listList all organizations.
Schéma original API
{
  "openapi": "3.0.0",
  "info": {
    "title": "OpenData Switzerland CKAN API",
    "description": "API for accessing datasets and related metadata on opendata.swiss.",
    "version": "1.0.0"
  },
  "servers": [
    {
      "url": "https://opendata.swiss/api/3/action/",
      "description": "Main API server for opendata.swiss"
    }
  ],
  "paths": {
    "/package_search": {
      "get": {
        "operationId": "searchPackages",
        "summary": "Search for packages (datasets) with specified criteria.",
        "parameters": [
          {
            "in": "query",
            "name": "fq",
            "required": false,
            "description": "Filter query to apply (e.g., tags:economy).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Search results for packages.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "help": {
                      "type": "string"
                    },
                    "success": {
                      "type": "boolean"
                    },
                    "result": {
                      "type": "object",
                      "properties": {
                        "results": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/Package"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/package_show": {
      "get": {
        "operationId": "showPackageDetails",
        "summary": "Get details of a specific package (dataset).",
        "parameters": [
          {
            "in": "query",
            "name": "id",
            "required": true,
            "description": "Unique identifier of the package.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Details of the specified package.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "help": {
                      "type": "string"
                    },
                    "success": {
                      "type": "boolean"
                    },
                    "result": {
                      "$ref": "#/components/schemas/Package"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/organization_list": {
      "get": {
        "operationId": "listOrganizations",
        "summary": "List all organizations.",
        "responses": {
          "200": {
            "description": "A list of organizations.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "help": {
                      "type": "string"
                    },
                    "success": {
                      "type": "boolean"
                    },
                    "result": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Package": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "title_for_slug": {
            "type": "string"
          },
          "issued": {
            "type": "string",
            "format": "date-time"
          },
          "type": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "groups": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "publisher": {
            "type": "object",
            "properties": {
              "name": {
                "type": "string"
              },
              "url": {
                "type": "string"
              }
            }
          },
          "organization": {
            "type": "object",
            "properties": {
              "name": {
                "type": "string"
              },
              "url": {
                "type": "string"
              },
              "package_count": {
                "type": "integer"
              }
            }
          },
          "name": {
            "type": "string"
          },
          "accrual_periodicity": {
            "type": "string"
          },
          "resources": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Resource"
            }
          }
        }
      },
      "Resource": {
        "type": "object",
        "properties": {
          "package_id": {
            "type": "string"
          },
          "issued": {
            "type": "string",
            "format": "date-time"
          },
          "id": {
            "type": "string"
          },
          "download_url": {
            "type": "string"
          },
          "media-type": {
            "type": "string"
          },
          "format": {
            "type": "string"
          },
          "rights": {
            "type": "string"
          },
          "created": {
            "type": "string",
            "format": "date-time"
          },
          "description": {
            "type": "string"
          },
          "num_resources": {
            "type": "integer"
          }
        }
      }
    }
  }
}