Skip to main content

A modern, async Python SDK for the RxNorm API that provides comprehensive access to drug information and terminology

Project description

pynorm-sdk

A modern, async Python SDK for the RxNorm API that provides comprehensive access to drug information and terminology.

This SDK implements the official RxNorm API. For detailed API documentation, see: https://lhncbc.nlm.nih.gov/RxNav/APIs/RxNormAPIs.html

Features

  • Complete RxNorm API Coverage: All 35+ endpoints implemented
  • Async/Await Support: Built with aiohttp for high-performance async operations
  • Type Safety: Full type hints with Pydantic v2 models
  • Error Handling: Custom exception hierarchy for specific error types
  • Production Ready: Comprehensive logging, session management, and error handling
  • Thoroughly Tested: 100% test coverage with real API integration tests

Installation

pip install pynorm-sdk

Quick Start

import asyncio
from pynorm import RxNormClient

async def main():
    async with RxNormClient() as client:
        # Check API health
        is_healthy = await client.check_health()
        print(f"API is healthy: {is_healthy}")
        
        # Search for a drug
        rxcuis = await client.find_rxcui_by_string("aspirin")
        if rxcuis:
            rxcui = rxcuis[0]
            print(f"Aspirin RXCUI: {rxcui}")
            
            # Get drug properties
            properties = await client.get_all_properties(rxcui)
            for prop in properties:
                print(f"{prop.propName}: {prop.propValue}")

asyncio.run(main())

API Coverage

Drug Search & Lookup

  • find_rxcui_by_string() - Find RXCUIs by drug name
  • find_rxcui_by_id() - Find RXCUIs by identifier (NDC, etc.)
  • get_approximate_match() - Fuzzy drug name matching
  • get_spelling_suggestions() - Get spelling corrections
  • get_drugs() - Search drugs by name

Concept Information

  • get_rx_concept_properties() - Get concept details
  • get_rx_norm_name() - Get concept name by RXCUI
  • get_all_properties() - Get all concept properties
  • get_rx_property() - Get specific properties

NDC Operations

  • get_ndcs() - Get NDCs for a concept
  • get_ndc_status() - Check NDC status
  • get_ndc_properties() - Get NDC properties
  • find_related_ndcs() - Find related NDCs

Relationships & Related Concepts

  • get_all_related_info() - Get all related concepts
  • get_related_by_type() - Get concepts by term type
  • get_related_by_relationship() - Get concepts by relationship

Filtering & Advanced Search

  • filter_by_property() - Filter concepts by properties
  • get_multi_ingred_brand() - Find multi-ingredient brands

Metadata & Configuration

  • get_id_types() - Available identifier types
  • get_prop_categories() - Property categories
  • get_prop_names() - Property names
  • get_term_types() - Term types
  • get_source_types() - Source vocabularies
  • get_rela_types() - Relationship types

Utility Functions

  • check_health() - API health check
  • get_rx_norm_version() - Get RxNorm version info
  • get_display_terms() - Auto-completion terms

Error Handling

The SDK provides specific exceptions for different error types:

from pynorm import RxNormClient
from pynorm.exceptions import RxNormHTTPError, RxNormValidationError

async with RxNormClient() as client:
    try:
        result = await client.find_rxcui_by_string("aspirin")
    except RxNormHTTPError as e:
        print(f"HTTP error: {e}")
    except RxNormValidationError as e:
        print(f"Validation error: {e}")

Configuration

The client can be configured with custom settings:

from pynorm import RxNormClient

# Custom configuration
async with RxNormClient(
    base_url="https://rxnav.nlm.nih.gov/REST",
    user_agent="MyApp/1.0"
) as client:
    # Your code here
    pass

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

pynorm_sdk-0.1.0.tar.gz (63.6 kB view details)

Uploaded Source

Built Distribution

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

pynorm_sdk-0.1.0-py3-none-any.whl (14.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pynorm_sdk-0.1.0.tar.gz
  • Upload date:
  • Size: 63.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pynorm_sdk-0.1.0.tar.gz
Algorithm Hash digest
SHA256 b0c6a5147050754ac08cd3f198381b5029972252007c53f399502763a0516c46
MD5 933ce52b80da316bc60df4b3510af41b
BLAKE2b-256 e9958d1485a3d74e2eed042495cc4112b35b6320ba9b57c184f0f413a0e64379

See more details on using hashes here.

Provenance

The following attestation bundles were made for pynorm_sdk-0.1.0.tar.gz:

Publisher: python-publish.yml on akauper/pynorm-sdk

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

File details

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

File metadata

  • Download URL: pynorm_sdk-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 14.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pynorm_sdk-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5d812f8950faa15f0ce0f804e4f6254420bea5de33567a440c3a5b1851fdeebe
MD5 cf226e1e566f8a077526039dfad6d383
BLAKE2b-256 d6c824953ae5e9da7a468993c2e901f2f419e8067a8e96b5c97c3a6377b0fcb4

See more details on using hashes here.

Provenance

The following attestation bundles were made for pynorm_sdk-0.1.0-py3-none-any.whl:

Publisher: python-publish.yml on akauper/pynorm-sdk

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