Skip to main content

A Python wrapper library for the Huwise Automation API

Project description

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

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,
)

# 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",
)

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

huwise_utils_py-1.4.0.tar.gz (22.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

huwise_utils_py-1.4.0-py3-none-any.whl (27.2 kB view details)

Uploaded Python 3

File details

Details for the file huwise_utils_py-1.4.0.tar.gz.

File metadata

  • Download URL: huwise_utils_py-1.4.0.tar.gz
  • Upload date:
  • Size: 22.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","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}

File hashes

Hashes for huwise_utils_py-1.4.0.tar.gz
Algorithm Hash digest
SHA256 94a1b715d42d67a2437b08f6ebc6bba70287e9c723d880cee646f5c683bf7b9c
MD5 dc80f292504674d848b628ac4498d7cb
BLAKE2b-256 7f85c680f37d1fd4625fcc44e9981714444be753ecb152a1205ea7fa972442fe

See more details on using hashes here.

File details

Details for the file huwise_utils_py-1.4.0-py3-none-any.whl.

File metadata

  • Download URL: huwise_utils_py-1.4.0-py3-none-any.whl
  • Upload date:
  • Size: 27.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","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}

File hashes

Hashes for huwise_utils_py-1.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 578582570358d4c435020fb1dc170004e531352afd5f8dbb0f7c68c92ee19a98
MD5 b919329edbb4a27a2ffeb1d660a96b12
BLAKE2b-256 d047387d21062ac538753cefd03dba30af0e43b74dcfc8ea64290436d5d0a7ed

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page