MyNixOS website logo
Description

Query the FDA Global Substance Registration System (GSRS) API.

Provides functions to query the FDA Global Substance Registration System (GSRS) REST API (<https://gsrs.ncats.nih.gov/api/v1/>). Enables programmatic access to substance records, UNII identifiers, synonyms, external codes, and chemical structures for over 170,000 registered substances.

rgsrs

R-CMD-check

Tidy R client for the FDA Global Substance Registration System (GSRS) REST API. Retrieve substance metadata, synonyms, cross-reference codes, and chemical structure information for any of the 170 000+ registered substances.

No API key required.

Installation

# install.packages("pak")
pak::pak("c1au6i0/rgsrs")

Functions

FunctionDescription
gsrs_search()Free-text or Lucene-syntax search
gsrs_substance()Substance metadata by UNII (vectorised)
gsrs_names()All registered synonyms for a UNII
gsrs_codes()Cross-reference codes for a UNII, with optional code_system filter
gsrs_unii_from_name()Resolve a substance name to its UNII
gsrs_structure()Chemical structure data (SMILES, formula, MW, InChI, …) by UNII
gsrs_structure_search()Substructure / similarity / exact search by SMILES
gsrs_chem_info()Chemical structure info from any identifier: name, CAS, UNII, InChIKey, or SMILES
gsrs_hierarchy()Parent/child relationship tree for a UNII
gsrs_all()Convenience wrapper: substance + names + codes + structure + hierarchy
gsrs_browse()Page through the full GSRS substance catalogue
gsrs_vocabularies()Retrieve controlled vocabulary terms
write_dataframes_to_excel()Write a named list of data frames to .xlsx

Usage

library(rgsrs)

# Search
gsrs_search("aspirin", top = 5)

# Fetch by UNII (aspirin = R16CO5Y76E)
gsrs_substance("R16CO5Y76E")

# All synonyms
gsrs_names("R16CO5Y76E")

# Cross-references – all systems
gsrs_codes("R16CO5Y76E")

# Cross-references – CAS only
gsrs_codes("R16CO5Y76E", code_system = "CAS")

# Name → UNII
gsrs_unii_from_name(c("aspirin", "ibuprofen"))

# Chemical structure info by name
gsrs_chem_info(c("aspirin", "ibuprofen"), type = "name")

# Chemical structure info by CAS number
gsrs_chem_info(c("50-78-2", "15687-27-1"), type = "cas")

# Chemical structure info by UNII
gsrs_chem_info("R16CO5Y76E", type = "unii")

# Chemical structure info by InChIKey
gsrs_chem_info("BSYNRYMUTXBXSQ-UHFFFAOYSA-N", type = "inchikey")

# Chemical structure info by SMILES (exact match)
gsrs_chem_info("CC(=O)Oc1ccccc1C(=O)O", type = "smiles")

# Everything at once
out <- gsrs_all("R16CO5Y76E")
str(out, max.level = 1)

All functions accept a verbose argument (default TRUE) and return tidy data frames with a query column tracking the input identifier. Failed lookups return NULL with a warning rather than throwing an error.

License

MIT © 2026 Claudio Zanettini.

Metadata

Version

0.1.0

License

Unknown

Platforms (80)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    uefi
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-freebsd
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64-uefi
  • aarch64-windows
  • aarch64_be-none
  • arc-linux
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-linux
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • sh4-linux
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-uefi
  • x86_64-windows