Skip to main content

Python client for the Netrias harmonization API

Project description

Netrias Client

"""Explain how to install and exercise the Netrias harmonization client."""

Install with uv

  • Install uv once (or update): curl -LsSf https://astral.sh/uv/install.sh | sh
  • Sync dependencies for a project that consumes the client:
    uv add netrias_client
    uv add python-dotenv  # optional helper for loading .env files
    
  • Prefer uv run <command> for executing scripts so the managed environment is reused automatically.

Alternative: pip

python -m pip install netrias_client
python -m pip install python-dotenv  # optional

Quickstart Script

Reference script (save as main.py) showing a full harmonization round-trip:

#!/usr/bin/env -S uv run python
# /// script
# requires-python = ">=3.13"
# dependencies = ["netrias_client", "python-dotenv"]
# ///

"""Exercise the packaged Netrias client against the live APIs."""

import asyncio
import os
from pathlib import Path
from typing import Final

from dotenv import load_dotenv
from netrias_client import NetriasClient

load_dotenv(override=True)

CSV_PATH: Final[Path] = Path("data/primary_diagnosis_1.csv")


async def main() -> None:
    client = NetriasClient()
    client.configure(api_key=_resolve_api_key())

    manifest = await client.discover_cde_mapping_async(
        source_csv=CSV_PATH,
        target_schema="ccdi",
    )

    _ = await client.harmonize_async(
        source_path=CSV_PATH,
        manifest=manifest,
    )


def _resolve_api_key() -> str:
    api_key = os.getenv("NETRIAS_API_KEY")
    if api_key:
        return api_key
    msg = "Set NETRIAS_API_KEY in your environment or .env file"
    raise RuntimeError(msg)


if __name__ == "__main__":
    asyncio.run(main())

Steps

  1. Install or update uv (see above).
  2. Export NETRIAS_API_KEY (or add it to a local .env).
  3. Adjust CSV_PATH to point at the source CSV you want to harmonize.
  4. Run uv run python main.py.

The client logs its configuration (minus secrets) during configure(...) and reports harmonization status plus output paths as the workflow progresses, so no extra print statements are required.

configure() Options

NetriasClient.configure(...) accepts additional tuning knobs. You can mix and match the ones you need:

Parameter Type Purpose
api_key str Required. Bearer token for authenticating with the Netrias services.
timeout `float None`
log_level `LogLevel str
confidence_threshold `float None`
discovery_use_gateway_bypass `bool None`
log_directory `Path str

Configure only the options you need; unspecified values fall back to sensible defaults.

Usage Notes

  • discover_cde_mapping_async(...) samples CSV values and returns a manifest-ready payload; call discover_cde_mapping(...) only from non-async code paths.
  • Call harmonize(...) (sync) or harmonize_async(...) (async) with the manifest to download a harmonized CSV. The result object reports status, description, and the output path.
  • The package exposes __version__ so callers can assert the installed release.
  • Optional extras (netrias_client[aws]) add boto3 helpers for the temporary gateway bypass.

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

netrias_client-0.0.3.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.

netrias_client-0.0.3-py3-none-any.whl (31.9 kB view details)

Uploaded Python 3

File details

Details for the file netrias_client-0.0.3.tar.gz.

File metadata

  • Download URL: netrias_client-0.0.3.tar.gz
  • Upload date:
  • Size: 26.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.23

File hashes

Hashes for netrias_client-0.0.3.tar.gz
Algorithm Hash digest
SHA256 1d69d830c6dd9b523a8d430fda0467c6955df0eebb2bf04691a1922d69445d20
MD5 15fa54771b6faa8646aca7771556f50b
BLAKE2b-256 70f44d2ebffa379dfddac7efc5ab46e6dcf9eb7e4cce88cba7f7dbdc0cdca195

See more details on using hashes here.

File details

Details for the file netrias_client-0.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for netrias_client-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 1357bc81c043e3377dba2faa6320d6c935b1a81c7c12f4868df909046be142da
MD5 fb15b40cd80e506de27bc47d75d803cf
BLAKE2b-256 3b940f2d3c5f6de8e415bcbf56cf0c17622becc3deefcfad592426a41e256679

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