Read-only mirror of https://github.com/opendatabs/ods-utils-py — Kanton Basel-Stadt. Issues & pull requests at the source.
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2025-12-12 16:09:02 +01:00
.github/workflows Merge pull request #21 from opendatabs/renovate/actions-checkout-4.x 2025-05-15 07:52:20 +02:00
src/ods_utils_py Add publish parameter to set_template_metadata function 2025-08-27 09:49:18 +02:00
tests Change test name 2024-10-09 11:57:18 +02:00
.gitignore Add my debugging script to .gitignore 2024-10-24 11:13:33 +02:00
debugging_script.py Update dataset_id from int to str everywhere 2024-10-24 11:50:30 +02:00
LICENSE Update author 2024-10-11 13:27:45 +02:00
MANIFEST.in Add MANIFEST.in 2024-10-11 14:32:56 +02:00
pyproject.toml Add pyproject.toml and python requirement of >=3.11 2024-10-11 14:17:14 +02:00
README.md Update README.md 2025-06-12 08:46:41 +02:00
README_FOR_DEVELOPERS.md Change .ods_utils_py.env to .env and update READMEs accordingly 2025-06-04 12:37:06 +02:00
renovate.json Update renovate.json 2025-05-14 16:11:05 +02:00
requirements.txt Update requirements and replace == by >= to remove dependency issues when updating other packages that are used next to ods-utils-py 2025-12-12 16:07:27 +01:00
setup.py Update requirements and replace == by >= to remove dependency issues when updating other packages that are used next to ods-utils-py 2025-12-12 16:07:27 +01:00

ods-utils-py

With ods-utils-py, the Automation API from Opendatasoft can be accessed directly from Python. A valid API key is required (Create an API key). The source code is publicly available on GitHub.

Installation

Installation via pip:

pip install ods-utils-py

Requirements

  • Python Version: 3.11 or higher
  • API Key: A valid API key from Opendatasoft

Getting Started

Set up API Key

To use ods-utils-py, a valid API key from Opendatasoft is required.

For OGD Basel, the API key can be created here.

For key creation on other platforms, click on the username button in the top right corner to open account settings. Under API Keys, custom keys with the appropriate permissions can be created.

The name should describe its purpose, for example, "ods_utils_py - <Initial Key Name>"

The API key requires the following 4 permissions:

  • Browse all datasets
  • Create new datasets
  • Edit all datasets
  • Publish own datasets

The API key is then required as an environment variable.

Set up Environment Variables

Next, the environment variables must be defined. For this, add a .env file in the root directory with the following content. If a .env already exists, just append the following content:

ODS_API_KEY=your_ods_api_key

ODS_DOMAIN=data.bs.ch
ODS_API_TYPE=automation/v1.0

Important: Make sure to add **/.env to your .gitignore to not upload the credentials to the internet!

Usage

Here's a simple example to retrieve the number of datasets:

import ods_utils_py as ods_utils

num_datasets = ods_utils.get_number_of_datasets()
print(f"We currently have {num_datasets} datasets.")

A list of all currently implemented functions can be found on GitHub.

If a desired function does not exist, it can be implemented via _requests_utils:

import ods_utils_py as ods_utils

response = ods_utils._requests_utils.requests_get("https://www.example.com")
print(response.text)

Note: Most of these functions should eventually be integrated into ods_utils_py if they use the Automation API.


The complete documentation of the Automation API 1.0 can be found here.


License

This project is licensed under the MIT License. See the LICENSE file in the repository for the full license text.