Metabolomics WorkBench REST service
MW REST API (v1.1, 11/27/2023) Download API (pdf)
The Metabolomics WorkBench REST service enables access to a variety of data (including metabolite structures, study metadata and experimental results) using HTTP requests. These requests may be carried out using a web browser or may be embedded in 3rd party applications or scripts to enable programmatic access. Most modern programming languages including PHP, Perl, Python, Java and Javascript have the capability to create HTTP request and interact with datasets such as this REST service.
The REST URL consists of three main parts, separated by forward slashes, after the common prefix specifying the invariant base URL:(https://www.metabolomicsworkbench.org/rest/)
- The context specification dictates which type of resource to access and is chosen from one of the following: <study | compound | refmet | metstat | gene | protein | moverz>
- The input specification is composed of 2 required parameters separated by forward slashes. The first parameter is the input item which depends on the context. The 2nd parameter is an appropriate input value for the chosen item. Examples of an input specification are:
/compound/pubchem_cid/311/
/compound/formula/C20H34O/
/study/study_id/ST000001/
/study/study_title/diabetes/
/refmet/name/Cholesterol/
/refmet/match/LysoPC16:0/
/gene/gene_symbol/acaca/
/protein/uniprot_id/Q13085/
Exceptions to this input specification occur when the 'moverz' context (MS search) is selected. In this case the input value must consist of 3 parts separated by forward slashes: <m/z value>/<adduct>/<tolerance(Daltons)>, e.g. '635.52/M+H/0.2'. In the case of the 'exactmass' input item the input value must consist of 2 parts separated by forward slashes: <lipid bulk abbreviation>/<adduct>, e.g. 'PC(34:1)/M+H' and the output items are ignored. - The output specification is composed of a required output item parameter and an optional output format parameter. The list of possible output items depends on the value chosen for the context. In the case of the "compound" context one or more (separated by commas) of 'regno', 'formula','exactmass', 'inchi_key', 'name', 'sys_name', 'smiles', 'lm_id', 'pubchem_cid', 'hmdb_id', 'kegg_id', 'chebi_id', 'metacyc_id' may be specified. More conveniently, an output type of 'all' may be specified to retrieve all compound-related fields. Also an output type of 'classification' retrieves the LIPID MAPS/ClassyFire classification hierarchy. In the case of the "study" context, allowed output types are 'summary', 'factors', 'analysis', 'metabolites' and 'data'. The default output format is JSON which is amenable to manipulation and parsing by various programming languages. Optionally a text ouput format may be specified, for example:
/compound/pubchem_cid/311/all/txt
Exceptions to this output specification occur when either 'molfile' (molfile is downloaded) or 'png' (png image is displayed in browser) is chosen as an output item in the "compound" context. The metstat context has 8 slots delimited by semicolons: /rest/metstat/<ANALYSIS_TYPE>;<POLARITY>;<CHROMATOGRAPHY>;<SPECIES>;<SAMPLE SOURCE>;<DISEASE>;<KEGG_ID>;<REFMET_NAME> One may skip slots but the semicolons must be entered to ensure that the proper category is assigned to each slot (see examples below). See the MetStat form pulldown menus to view allowed items for each category or the Bubble plot lists for species, sample source and disease association. The interactive "REST url" creator below shows most of the currently available options for this service.
The table below contains several examples of REST urls.
REST (REpresentational State Transfer) is an architectural style consisting of a coordinated set of architectural constraints applied to components, connectors, and data elements, within a distributed hypermedia system. REST ignores the details of component implementation and protocol syntax in order to focus on the roles of components, the constraints upon their interaction with other components, and their interpretation of significant data elements. Fielding, Roy T. (2000). "Chapter 5: Representational State Transfer (REST)". Architectural Styles and the Design of Network-based Software Architectures (Ph.D.). University of California, Irvine. Fielding, Roy T.; Taylor, Richard N. (May 2002), "Principled Design of the Modern Web Architecture" (PDF), ACM Transactions on Internet Technology (TOIT) (New York: Association for Computing Machinery) 2 (2): 115-150, doi:10.1145/514183.514185, ISSN 1533-5399 REST Wikipedia page
JSON (JavaScript Object Notation) is a lightweight data-interchange format which human readable and also convenient for computers to parse and generate. JSON is a text format that is completely language independent but uses conventions that are familiar to most common programming languages. Official JSON website