Read-only mirror of https://github.com/opendatabs/huwise-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
2026-04-29 11:18:24 +02:00
.github/workflows Migrate ods-utils-py to huwise-utils-py with DCC standards compliance 2026-02-06 16:33:39 +01:00
docs Add first-class helpers for custom metadata fields and dataset tags 2026-04-29 01:01:46 +02:00
scripts Update version to 1.3.0, enhance documentation, and add new DCAT-AP-CH metadata operations 2026-02-09 22:39:29 +01:00
src/huwise_utils_py Update to version 1.5.1. 2026-04-29 11:14:26 +02:00
tests Add optional override_remote_value support for metadata setters. 2026-04-29 11:01:57 +02:00
.env.example Migrate ods-utils-py to huwise-utils-py with DCC standards compliance 2026-02-06 16:33:39 +01:00
.gitignore Migrate ods-utils-py to huwise-utils-py with DCC standards compliance 2026-02-06 16:33:39 +01:00
.pre-commit-config.yaml Migrate ods-utils-py to huwise-utils-py with DCC standards compliance 2026-02-06 16:33:39 +01:00
debugging_script.py Add LICENSE_MAP and fix license getter/setter to handle both metadata fields 2026-02-07 12:13:19 +01:00
LICENSE Hide uid from public API and documentation, add dataset_ids to bulk_get_metadata 2026-02-07 22:39:49 +01:00
mkdocs.yml Update version to 1.3.0, enhance documentation, and add new DCAT-AP-CH metadata operations 2026-02-09 22:39:29 +01:00
pyproject.toml Update to version 1.5.1. 2026-04-29 11:14:26 +02:00
README.md Update to version 1.4.2 and add dataset resource management APIs 2026-04-28 23:49:02 +02:00
README_FOR_DEVELOPERS.md Update to version 1.4.1 2026-04-27 15:20:53 +02:00
renovate.json Update renovate.json 2025-05-14 16:11:05 +02:00
uv.lock Update to version 1.5.1. 2026-04-29 11:14:26 +02:00

huwise-utils-py

A Python library for the Huwise Automation API.

PyPI version Python 3.12+ License: MIT

Features

  • Type-safe configuration with Pydantic-based HuwiseConfig
  • Object-oriented API with HuwiseDataset class and method chaining
  • Async support for high-performance bulk operations
  • Airflow-friendly logging via Python stdlib logging
  • Dependency injection support for testable code
  • Backwards compatible function-based API available

Installation

Using uv (recommended):

uv add huwise-utils-py

Or via pip:

pip install huwise-utils-py

Requirements

  • Python Version: 3.12 or higher
  • Domain: Optional (defaults to data.bs.ch; set HUWISE_DOMAIN for other portals)
  • API Key: Required for Automation API operations

Quick Start

Configuration

Create a .env file:

HUWISE_API_TYPE=automation/v1.0

If your portal is not data.bs.ch, also set:

HUWISE_DOMAIN=your-portal.example.org

Set your API key:

HUWISE_API_KEY=your-api-key
from huwise_utils_py import HuwiseDataset

# Create a dataset instance from its ID
dataset = HuwiseDataset.from_id("100123")

# Read metadata
title = dataset.get_title()
description = dataset.get_description()

# Update with method chaining
dataset.set_title("New Title", publish=False).set_description("New description").publish()

# Create a new dataset
created = HuwiseDataset.create(
    metadata={"default": {"title": {"value": "My New Dataset"}}},
    dataset_id="my-new-dataset",
    is_restricted=False,
    resource_source_url="https://data-bs.ch/stata/fgi/stac/AFBA_Abfuhrzonen.geojson",
    resource_title="my-new-dataset.geojson",
)

# Update dataset-level schema/configuration
created.update_configuration(dataset_id="my-renamed-dataset", is_restricted=True)

# Append a dataset field configuration processor
created.append_field_configuration(
    {
        "type": "rename",
        "label": "Rename field",
        "from_name": "old_name",
        "to_name": "new_name",
    }
)

Using Functions

from huwise_utils_py import get_dataset_title, set_dataset_title

# Read
title = get_dataset_title(dataset_id="100123")

# Write
set_dataset_title("New Title", dataset_id="100123")

# Create
from huwise_utils_py import create_dataset
new_dataset = create_dataset(
    metadata={"default": {"title": {"value": "My New Dataset"}}},
    dataset_id="my-new-dataset",
    resource_source_url="https://data-bs.ch/stata/fgi/stac/AFBA_Abfuhrzonen.geojson",
    resource_title="my-new-dataset.geojson",
)

# Upsert an HTTP resource (idempotent create/update)
from huwise_utils_py import upsert_dataset_resource_http
upsert_dataset_resource_http(
    dataset_id="100095stac",
    source_url="https://data-bs.ch/stata/fgi/stac/AFBA_Abfuhrzonen.geojson",
    title="100095stac.geojson",
)

Bulk Operations

from huwise_utils_py import bulk_get_metadata, bulk_get_metadata_async
import asyncio

# Synchronous
metadata = bulk_get_metadata(dataset_ids=["100123", "100456", "100789"])

# Asynchronous (10-100x faster for many datasets)
metadata = asyncio.run(bulk_get_metadata_async(dataset_ids=["100123", "100456", "100789"]))

API Key Setup

To use huwise-utils-py, create an API key with these permissions:

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

For OGD Basel, create your API key here.

Important: Add **/.env to your .gitignore to protect your credentials.

Documentation

Full documentation is available at opendatabs.github.io/huwise-utils-py.

API Reference

This library is a Python client for the Huwise Automation API. The Automation API enables programmatic management of datasets, metadata, resources, security, and more on Huwise (ex Opendatasoft) portals.

For the complete API specification including all available endpoints, request/response schemas, and authentication details, see the official Automation API documentation.

  • odsAutomationR - An R package for accessing the Automation API, developed by the Canton of Thurgau. If you're working in R, this package provides similar functionality.

License

This project is licensed under the MIT License. See the LICENSE file for details.