Skip to main content

A Python client for interacting with the DAB API.

Project description

DAB API Client (Terms)

A Python client to fetch terms from the DAB Terms API. This repository contains a minimal client for retrieving controlled vocabulary terms (e.g., instruments) from the Blue-Cloud/GeoDAB service using a token and view.

Package name: dab_api_client Top-level module: DAB_TERMS_API

Features

  • Retrieve terms from the DAB Terms API with a single call
  • Simple object model: Term and Terms containers
  • Small dependency footprint (requests)

Installation

The package is not published on PyPI yet. You can install it from source:

  • Using pip and a local path

    • pip install .
  • Or in editable/development mode

    • pip install -e .

Requirements:

  • Python 3.7+
  • requests

If using the provided test/example that performs semantic analysis, you will also need a separate dependency my_semantic_analyzer (not included in this repo).

Quick start

Below is a minimal example illustrating how to fetch terms.

from DAB_TERMS_API.DAB_API import TermsAPI

# Provided by the Blue-Cloud/GeoDAB environment
token = "blue-cloud-terms-maris-bv"
view = "blue-cloud-terms"

# What type of terms to fetch and how many
term_type = "instrument"
max_terms = 20

api = TermsAPI(token=token, view=view)
terms = api.get_terms(type=term_type, max=max_terms)

# Iterate the received terms
for term in terms.get_terms():
    print(term.get_value(), term.get_count())

API Reference (light)

Notes:

  • The API currently prints some debug information (counts and sample outputs) to stdout.
  • The Terms container simply stores the raw list of Term objects in the attribute terms and exposes it via get_terms().

Example with semantic analyzer (optional)

The included test.py shows how to integrate the fetched terms with an external semantic analyzer library. That library is not part of this package; install and configure it separately if you intend to use that workflow.

from DAB_TERMS_API.DAB_API import TermsAPI
from my_semantic_analyzer.semantic_analyzer import *

api = TermsAPI(token="blue-cloud-terms-maris-bv", view="blue-cloud-terms")
terms = api.get_terms(type="instrument", max=20)

analyzer = SemanticAnalyzer()
terms_to_analyze = [t.get_value().replace('(', '').replace(')', '') for t in terms.get_terms()]

match_types = [Matchtype("exactMatch")]
match_properties = [MatchProperty("altLabel"), MatchProperty("prefLabel")]

results = analyzer.analyzeTerms(terms_to_analyze, match_types, match_properties)
print("Matches:", len(results.get_matches()))

Development

  • Code lives in DAB_TERMS_API/DAB_API.PY
  • Packaging metadata is defined in setup.py (project name: dab_api_client)
  • Long description is sourced from this README.md

To run the example/test (after installing deps):

  • python test.py

License

license="GPL-3.0".

Project Links

Helper scripts to create a virtual environment

If you prefer an automated setup, this repo includes simple helpers:

  • Windows (PowerShell):
    • ./create_venv.ps1
  • macOS/Linux (bash):
    • ./create_venv.sh

Both scripts will create .venv, upgrade pip, and (if present) install dependencies from requirments.txt.

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

dab_py-0.1.0.tar.gz (16.0 kB view details)

Uploaded Source

Built Distribution

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

dab_py-0.1.0-py3-none-any.whl (16.3 kB view details)

Uploaded Python 3

File details

Details for the file dab_py-0.1.0.tar.gz.

File metadata

  • Download URL: dab_py-0.1.0.tar.gz
  • Upload date:
  • Size: 16.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.2

File hashes

Hashes for dab_py-0.1.0.tar.gz
Algorithm Hash digest
SHA256 5e61e4d96be9fc0ab56ff4b69772b3fe025959e2c923e7851eb4324f6962958d
MD5 5cd446a361f622a082f15b732e85919e
BLAKE2b-256 8057f763aaf955a33ea075eb96d7f87080e26210d36fc94d2407d0a8c9d3a722

See more details on using hashes here.

File details

Details for the file dab_py-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: dab_py-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 16.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.2

File hashes

Hashes for dab_py-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1d4f2cb432dc4e808b9d764743768b22636f2831b29392b27a06c7b150c20570
MD5 a3576bfb4630b9bc5dd90f6acc4df204
BLAKE2b-256 4ff3d674152c0417512a5d4ac12301f80621d79a96d1a4015a33ad7913c4846a

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