Skip to main content

Production-ready Python client for the NLM UMLS REST APIs.

Project description

UMLS Python Client

Production-ready Python client for the NLM UMLS REST APIs.

The package keeps the original UMLSClient behavior for existing users and adds typed sync and async clients for new applications.

Installation

pip install umls-python-client

Development install:

pip install ".[dev]"

Authentication

UMLS requests require an API key from NLM: https://documentation.uts.nlm.nih.gov/rest/authentication.html

import os

api_key = os.environ["UMLS_API_KEY"]

Legacy Compatible Usage

UMLSClient preserves the existing JSON formatting defaults and camelCase namespaces.

from umls_python_client import UMLSClient

client = UMLSClient(api_key="YOUR_API_KEY")

results = client.searchAPI.search(
    search_string="diabetes",
    semantic_types="T047",
    semantic_groups="Disorders",
)
print(results)

raw_results = client.search_api.search(
    search_string="diabetes",
    return_indented=False,
)

Typed Sync Usage

from umls_python_client import TypedUMLSClient

with TypedUMLSClient(api_key="YOUR_API_KEY") as client:
    response = client.cui_api.get_cui_info("C0011849")
    concept = response.result
    print(concept.name)

Typed responses return UMLSResponse[T]. The original UMLS JSON is available through response.raw or response.to_dict(), and RDF/Turtle is available with response.to_rdf().

Async Usage

from umls_python_client import AsyncUMLSClient


async def main() -> None:
    async with AsyncUMLSClient(api_key="YOUR_API_KEY") as client:
        response = await client.search_api.search("diabetes", page_size=5)
        print(response.result)

API Namespaces

Namespace Legacy alias Coverage
search_api searchAPI /search/{version}, including semanticTypes and semanticGroups
cui_api cuiAPI CUI detail, atoms, preferred atom, definitions, relations
source_api sourceAPI Source concepts, atoms, preferred atom, hierarchy, attributes, relations
atom_api none AUI detail and hierarchy endpoints
crosswalk_api crosswalkAPI Source identifier crosswalk
semantic_network_api semanticNetworkAPI Semantic type lookup
metadata_api none /metadata/{version}/sources

Output Behavior

Legacy methods support:

  • format="json" or format="rdf"
  • return_indented=True for pretty JSON strings
  • return_indented=False for raw Python payloads
  • save_to_file=True and file_path="output-directory"

Typed methods raise structured exceptions on failures:

  • UMLSRequestError
  • UMLSHTTPError
  • UMLSDecodeError

Current NLM API Notes

The Search API changed on May 4, 2026. This client supports the current semanticTypes and semanticGroups filters and does not send obsolete pageNumber pagination parameters for endpoints where the current NLM docs no longer document pagination.

Official UMLS REST documentation: https://documentation.uts.nlm.nih.gov/rest/home.html

Testing

ruff check .
ruff format --check .
mypy src
pytest
python -m build

Live integration tests are optional and must be explicitly enabled by setting UMLS_API_KEY; default CI uses mocked transports only.

Releases

This repository uses Release Please to automate versioning and publishing. Commits merged to main should use Conventional Commit prefixes:

  • fix: for patch releases
  • feat: for minor releases
  • feat!: or fix!: for major releases

After releasable commits land on main, Release Please opens or updates a release PR. Merging that release PR creates the GitHub Release, builds the package, attaches dist/ artifacts to the release, and publishes to PyPI.

To publish the already-merged 1.1.0 modernization release, first merge the release workflow, configure PyPI trusted publishing, and then run the Release workflow manually with tag_name set to v1.1.0. The manual run creates the tag and GitHub Release if needed, verifies the package, uploads release artifacts, and publishes 1.1.0 to PyPI.

PyPI publishing uses trusted publishing, so no PyPI API token is required in GitHub secrets. Configure the PyPI project with:

  • Owner: palasht75
  • Repository: umls-python-client
  • Workflow: release-please.yml
  • Environment: pypi

License

Apache-2.0. See LICENSE.

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

umls_python_client-1.1.0.tar.gz (26.0 kB view details)

Uploaded Source

Built Distribution

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

umls_python_client-1.1.0-py3-none-any.whl (27.3 kB view details)

Uploaded Python 3

File details

Details for the file umls_python_client-1.1.0.tar.gz.

File metadata

  • Download URL: umls_python_client-1.1.0.tar.gz
  • Upload date:
  • Size: 26.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for umls_python_client-1.1.0.tar.gz
Algorithm Hash digest
SHA256 778f2b7e0c7aaab8c476658c1b8d7766ce63c83e5282e55e740c626f76e98e9b
MD5 da3d9959134211a56def4ae2b80e7a90
BLAKE2b-256 d8d57c0b1322ec756b13edc9e4e17c3df8b3a89e2638847919cd247e13e5a50d

See more details on using hashes here.

Provenance

The following attestation bundles were made for umls_python_client-1.1.0.tar.gz:

Publisher: release-please.yml on palasht75/umls-python-client

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file umls_python_client-1.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for umls_python_client-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0ade6884fdcf10fda8a5bde8e29b3fdb0a1f8ea76c2ae40854a0bd49de1220f0
MD5 f4cc9a92e507333836ed85b9637e18e1
BLAKE2b-256 1115207fd330f9031e907b453722abe2703d1865b891b7cb6190372754354473

See more details on using hashes here.

Provenance

The following attestation bundles were made for umls_python_client-1.1.0-py3-none-any.whl:

Publisher: release-please.yml on palasht75/umls-python-client

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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