APIs

RxClass API

getClassGraphBySource

Information returned
Classes along the path from a specified class to the root of a class hierarchy
Service domain
https://rxnav.nlm.nih.gov
HTTP request
GET  /REST/rxclass/classGraph.xml?classId=value&source=value

Description

Get the ancestors of a class specified by source and classId. The ancestors are returned as a graph of nodes and edges.

The source, which restricts the results to a particular class type, should be specified when using a MeSH identifier because some MeSH concepts exist in more than one RxClass tree. getClassGraphBySource returns only one tree. To find all trees that contain a concept, use getClassContexts.

This resource returns an array of nodes (rxclassMinConceptItem) and an array of edges (rxclassEdge) that link the nodes.

Parameters

ParameterLocationUseDescriptionDefault
formatPathOptional

Notation for results

One of:
.xml
Get results in XML
.json
Get results in JSON
.xml
classIdQueryRequiredClass identifier
sourceQueryOptionalClass type

(See getClassTypes for the menu.)

All query parameters are case-insensitive.

Note that HTTP requires that query parameters be "URL encoded". For full information on URL encoding, please refer to IETF RFC 3986, "Uniform Resource Identifier".

Output structure

Results are available as either XML or JSON.

  • The XML result has the root element rxclassdata. It is described in the XML Schema for the RxClass API; the relevant element structure is summarized below. Elements that would be empty might be left out.

  • The JSON result is an object {...}, analogous to the content of the XML rxclassdata. Fields that might occur multiple times in the XML are expressed as an array. Fields that would be empty might be null or left out. Numbers are expressed as strings.

Both XML and JSON results follow the same outline:

rxclassdata
Root element in XML, or anonymous object in JSON
rxclassGraph
Collection of classes and edges
rxclassMinConceptItem (array)
Drug class
classId
Class identifier (an ID in the namespace of the class source)
className
Class name
classType
Class type (ATC1-4, CHEM, DISPOS, EPC, VA, etc.)
classUrl
Link to the class source
rxclassEdge (array)
Edge
classId1
Class1's identifier (an ID in the namespace of the class source)
rela
"isa" indicates that classId1 designates a subclass of classId2
classId2
Class2's identifier (an ID in the namespace of the class source)

Example: Graph for the 'Arthritis, infectious' class (MeSH id=D001170)

XML: https://rxnav.nlm.nih.gov/REST/rxclass/classGraph?classId=D001170&source=disease

JSON: https://rxnav.nlm.nih.gov/REST/rxclass/classGraph.json?classId=D001170&source=disease

An XML result is shown below.

<rxclassdata>
    <rxclassGraph>
        <rxclassMinConceptItem>
            <classId>D001168</classId>
            <className>Arthritis</className>
            <classType>DISEASE</classType>
        </rxclassMinConceptItem>
        <rxclassMinConceptItem>
            <classId>D001170</classId>
            <className>Arthritis, Infectious</className>
            <classType>DISEASE</classType>
        </rxclassMinConceptItem>
        <rxclassMinConceptItem>
            <classId>D007239</classId>
            <className>Infections</className>
            <classType>DISEASE</classType>
        </rxclassMinConceptItem>
        <rxclassMinConceptItem>
            <classId>D007592</classId>
            <className>Joint Diseases</className>
            <classType>DISEASE</classType>
        </rxclassMinConceptItem>
        <rxclassMinConceptItem>
            <classId>D009140</classId>
            <className>Musculoskeletal Diseases</className>
            <classType>DISEASE</classType>
        </rxclassMinConceptItem>
        <rxclassMinConceptItem>
            <classId>X1</classId>
            <className>Diseases, Life Phases, Behavior Mechanisms and Physiologic States</className>
            <classType>DISEASE</classType>
        </rxclassMinConceptItem>
        <rxclassMinConceptItem>
            <classId>X3</classId>
            <className>Disease</className>
            <classType>DISEASE</classType>
        </rxclassMinConceptItem>
        <rxclassEdge>
            <classId1>D001168</classId1>
            <rela>isa</rela>
            <classId2>D007592</classId2>
        </rxclassEdge>
        <rxclassEdge>
            <classId1>D001170</classId1>
            <rela>isa</rela>
            <classId2>D001168</classId2>
        </rxclassEdge>
        <rxclassEdge>
            <classId1>D001170</classId1>
            <rela>isa</rela>
            <classId2>D007239</classId2>
        </rxclassEdge>
        <rxclassEdge>
            <classId1>D007239</classId1>
            <rela>isa</rela>
            <classId2>X3</classId2>
        </rxclassEdge>
        <rxclassEdge>
            <classId1>D007592</classId1>
            <rela>isa</rela>
            <classId2>D009140</classId2>
        </rxclassEdge>
        <rxclassEdge>
            <classId1>D009140</classId1>
            <rela>isa</rela>
            <classId2>X3</classId2>
        </rxclassEdge>
        <rxclassEdge>
            <classId1>X3</classId1>
            <rela>isa</rela>
            <classId2>X1</classId2>
        </rxclassEdge>
    </rxclassGraph>
</rxclassdata>