Skip to main content

Open Opus

A lightweight Python package that provides a stable interface to the Open Opus API.

This project exists to decouple application code from the Open Opus API's raw response formats and availability characteristics.


Requirements

  • Python >= 3.10

Installation

Library only:

pip install openopus

Quick Start

from openopus import OpenOpus

svc = OpenOpus()

# List all composers
composers = svc.composers()

# Search by name (partial match)
results = svc.composers_by_name("Bach")

# Fetch a single composer
bach = svc.composer(196)

# Get all works by a composer
works = svc.works(196)

# Get works filtered by genre
keyboard_works = svc.works(196, genre="Keyboard")

# Get detailed info for a single work
work = svc.work_detail(1234)

# Get all valid period names
periods = svc.periods()

# Get composers from a specific period
baroque = svc.composers_by_period("Baroque")

# Pick a random composer or work
surprise = svc.random_composer()
surprise_work = svc.random_work(196)

API Reference

OpenOpus(cache=None)

Main service class. Accepts an optional cache instance (defaults to an in-memory TTLCache with a 1-hour TTL).

Composer methods

Method Description
composers() Return all composers
composer(composer_id) Return a single Composer by ID
composers_by_name(name) Partial-match search by name
composers_by_period(period) Filter by classical period
random_composer() Return a randomly selected composer
periods() Return the set of valid period strings

Work methods

Method Description
works(composer_id, genre="all") Return works by a composer, optionally filtered by genre
work_detail(work_id) Return detailed info for a single work
random_work(composer_id) Return a randomly selected work by a composer

Models

Composer

Field Type Description
id int Unique composer ID
name str Full name
birth str | None Birth year/date
death str | None Death year/date
epoch str Musical period
portrait str | None Portrait image URL

Work

Field Type Description
id int Unique work ID
title str Work title
genre str Genre (e.g. "Keyboard", "Orchestral")
subtitle str | None Subtitle or nickname

Caching

All responses are cached automatically. The default cache is TTLCache(ttl_seconds=3600). You can supply your own compatible object (anything with get(key) and set(key, value) methods), or use the built-in cache control methods:

from openopus.cache import TTLCache

cache = TTLCache(3600)
svc = OpenOpus(cache=cache)

# Remove a single entry
cache.invalidate("composers")

# Wipe everything
cache.clear()

Error Handling

Exception When raised
openopus.errors.OpenOpusError Non-200 HTTP response from the API, or invalid argument (e.g. unknown period)
openopus.errors.UpstreamUnavailable Network timeout or connection failure
from openopus.errors import OpenOpusError, UpstreamUnavailable

try:
    works = svc.works(196)
except UpstreamUnavailable:
    print("API unreachable, try again later")
except OpenOpusError as e:
    print(f"API error: {e}")

Development

# Install dependencies
pip install -e ".[dev]"

# Run tests
pytest

Metadata

Release files for openopus 0.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for openopus 0.0.4
File Size Uploaded Provenance Actions
openopus-0.0.4.tar.gz 6.8 kB With provenance Details for openopus-0.0.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for openopus 0.0.4
File Interpreter ABI Platform Actions
openopus-0.0.4-py3-none-any.whl Python 3 none any Details for openopus-0.0.4-py3-none-any.whl

Total release size: 13.2 kB

Release files / openopus-0.0.4.tar.gz

Download URL openopus-0.0.4.tar.gz
Size 6.8 kB
Tags Source
SHA-256 checksum
How to use checksums
aa6e82f4fcada5c5c4fa6c01660ccf05b84be89c4e4c1073a68c159c836d5307
BLAKE2b-256 checksum
How to use checksums
6776a6e06547e82aba68cb35f3d397f8485ce882db578283edc36d8568243cc6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 11, 2026.

Transparency log

Release files / openopus-0.0.4-py3-none-any.whl

Download URL openopus-0.0.4-py3-none-any.whl
Size 6.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
57217463bfeb35a7859fd8b1b0d54cb581e426bc8149e5ab4a17d4b3bed91b8c
BLAKE2b-256 checksum
How to use checksums
8e6bbbb42fbd2191068987e8e8137da5e32dacaa8e05c0c47598cc2c5def6420
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 11, 2026.

Transparency log

Security for openopus 0.0.4

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for openopus-0.0.4.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 11, 2026.

Transparency log

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page