huwise-utils-py
A Python library for the Huwise Automation API.
Features
- Type-safe configuration with Pydantic-based
HuwiseConfig - Object-oriented API with
HuwiseDatasetclass 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; setHUWISE_DOMAINfor 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
Using HuwiseDataset (Recommended)
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.
Related Projects
- 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.
Further Links
License
This project is licensed under the MIT License. See the LICENSE file for details.
Metadata
Release files for huwise-utils-py 1.5.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| huwise_utils_py-1.5.1.tar.gz | 28.0 kB | Without provenance | Details for huwise_utils_py-1.5.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| huwise_utils_py-1.5.1-py3-none-any.whl | Python 3 | none | any | Details for huwise_utils_py-1.5.1-py3-none-any.whl |
Total release size: 61.2 kB
Release files / huwise_utils_py-1.5.1.tar.gz
| Download URL | huwise_utils_py-1.5.1.tar.gz |
|---|---|
| Size | 28.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
db682d7588d11c179a15611e6e4f01ac71db946a1197bd49cf1c5162f75cf154
|
|
BLAKE2b-256 checksum How to use checksums |
497bfc114905c345c552b0cf11ccdd27516c2c8e17730b882f2be128bc8b911d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.11.8 {"installer":{"name":"uv","version":"0.11.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / huwise_utils_py-1.5.1-py3-none-any.whl
| Download URL | huwise_utils_py-1.5.1-py3-none-any.whl |
|---|---|
| Size | 33.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cefa0043dfd8e5c23187cc802958911a39873440dc98b9b640bcece224284a43
|
|
BLAKE2b-256 checksum How to use checksums |
bd933936a93862589ce6eb33eb0a7bf3a901b894927d256206637900f6ba68bc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.11.8 {"installer":{"name":"uv","version":"0.11.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for huwise-utils-py 1.5.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.