USNAN Python SDK

From Network for Advanced NMR
Jump to navigationJump to search
USNAN Python SDK Navigation

USNAN Python SDK

The USNAN Python SDK provides programmatic access to data and metadata from the USNAN Network API. It enables researchers to discover, query, and download datasets, as well as navigate between related entities such as facilities, spectrometers, probes, and knowledgebase resources.

This SDK complements the Data_Browser and other web tools available through the USNAN web portal, offering a scripting interface for automation, reproducibility, and integration into computational workflows.

Overview

The SDK wraps the RESTful API available at https://api.nmrhub.org/ and provides convenient Python classes for accessing:

  • Datasets
  • Facilities
  • Spectrometers
  • Probes
  • Knowledgebase (KB) records

The SDK performs lazy fetching of linked objects, provides caching for repeated queries, and includes methods for dataset download and filtering.

Installation

The SDK is available from PyPI.

pip install usnan

or install directly from GitHub for the latest version:

pip install git+https://github.com/NanNMR/PythonSDK.git

Quick Start

import usnan

client = usnan.USNANClient()

# Get facility information
mullen = client.facilities.get("UCHC-Mullen")
print(mullen.long_name)

# Search datasets
search = (
    usnan.models.SearchConfig(records=10)
      .add_filter("is_knowledgebase", value=True, match_mode="equals")
)
for ds in client.datasets.search(search):
    print(ds.id, ds.title)

# Download a dataset
client.datasets.download([ds.id for ds in client.datasets.search(search)], location="downloads")

Links

License

The SDK is released under the MIT License.

Contact

For questions, please contact the USNAN development team at support@usnan.org.