USNAN Python SDK/API Reference

From Network for Advanced NMR
Revision as of 17:30, 7 October 2025 by Mmaciejewski (talk | contribs) (Created page with "= '''API Reference''' = This section summarizes the main classes and methods exposed by the SDK. == '''usnan.USNANClient''' == The central interface to the API. '''Constructor:''' <syntaxhighlight lang="python"> client = usnan.USNANClient(base_url=None, timeout=30, num_retries=3) </syntaxhighlight> '''Attributes:''' * '''datasets''' – interface for dataset retrieval and search * '''facilities''' – interface for facility data * '''spectrometers''' – interface fo...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

API Reference

This section summarizes the main classes and methods exposed by the SDK.

usnan.USNANClient

The central interface to the API.

Constructor:

client = usnan.USNANClient(base_url=None, timeout=30, num_retries=3)

Attributes:

  • datasets – interface for dataset retrieval and search
  • facilities – interface for facility data
  • spectrometers – interface for spectrometer data
  • probes – interface for probe metadata

Datasets API

ds = client.datasets.get(363067)

Methods:

  • get(id) – retrieve dataset by ID
  • search(SearchConfig) – iterate over search results
  • download(ids, location="path") – download datasets to a local folder

Dataset objects expose:

  • id
  • title
  • experiment_name
  • num_dimension
  • spectrometer_identifier
  • facility_identifier
  • public_time

Facilities API

fac = client.facilities.get("UCHC-Mullen")
fac.spectrometers
fac.probes

SearchConfig

Defines dataset search criteria.

cfg = usnan.models.SearchConfig(records=100)
cfg.add_filter("is_knowledgebase", value=True, match_mode="equals")
cfg.add_filter("num_dimension", value=3, match_mode="equals")

Parameters:

  • field – name of dataset attribute
  • value – filter value
  • match_mode – comparison type (equals, contains, greater, less)
  • operator – logical combination (AND, OR)