MG-RAST API Overview

The MG-RAST API covers most of the functionality available through the MG-RAST website, with access to annotations, analyses, metadata and access to the MG-RAST user inbox to view contents as well as upload files. All sequence data and data products from intermediate stages in the analysis pipeline are available for download. Other resources provide services not available through the website, e.g. the m5nr resource lets you query the m5nr database.

Each query to the API is represented as a URI beginning with "http://api.mg-rast.org/" and has a defined structure to pass the requests and parameters to the API server.

The URI queries can be used from the command line, e.g. using curl, in a browser, or incorporated in a shell script or program.

Each URI has the form

"http://api.mg-rast.org/{version}/{resourcepath}?{querystring}"

The {version} value (currently '1') explicitly directs the request to a specific version of the API, if it is omitted the latest API version will be used.

The resource path is constructed from the path parameters listed below to define a specific resource and the optional query string is used to filter the results obtained for the resource. For example:

http://api.mg-rast.org/1/annotation/sequence/mgm4447943.3?evalue=10&type=organism&source=SwissProt

In this example the resource path "annotation/sequence/mgm4447943.3" defines a request for the annotated sequences for the MG-RAST job with ID 4447943.3.

The optional query string "evalue=10&type=organism&source=SwissProt" modifies the results by setting an evalue cutoff, annotation type and database source.

The API provides an authentication mechanism for access to private MG-RAST jobs and users' inbox. The 'auth_key' (or 'webkey') is a 25 character long string (e.g. 'j6FNL61ekNarTgqupMma6eMx5') which is used by the API to identify an MG-RAST user account and determine access rights to metagenomes. Note that the auth_key is valid for a limited time after which queries using the key will be rejected. You can create a new auth_key or view the expiration date and time of an existing auth_key on the MG-RAST website. An account can have only one valid auth_key and creating a new key will invalidate an existing key.

All public data in MG-RAST is available without an auth_key. All API queries for private data which either do not have an auth_key or use an invalid or expired auth_key will get a "insufficient permissions to view this data" response.

The auth_key can be included in the query string like:

http://api.mg-rast.org/1/annotation/sequence/mgm4447943.3?evalue=10&type=organism&source=SwissProt&auth=j6FNL61ekNarTgqupMma6eMx5

or in a request using curl like:

curl -X GET -H "auth: j6FNL61ekNarTgqupMma6eMx5" "http://api.mg-rast.org/1/annotation/sequence/mgm4447943.3?evalue=10&type=organism&source=SwissProt"

Note that for the curl command the quotes are necessary for the query to be passed to the API correctly.

If an optional parameter passed through the query string has a list of values only the first will be used. When multiple values are required, e.g. for multiple md5 checksum values, they can be passed to the API like:

curl -X POST -d '{"data":["000821a2e2f63df1a3873e4b280002a8","15bf1950bd9867099e72ea6516e3d602"]}' "http://api.mg-rast.org/m5nr/md5"

In some cases, the data requested is in the form of a list with a large number of entries. In these cases the limit and offset parameters can be used to step through the list, for example:

http://api.mg-rast.org/1/project?order=name&limit=20&offset=100

will limit the number of entries returned to 20 with an offset of 100. If these parameters are not provided default values of limit=10 and offset=0 are used. The returned JSON structure will contain the 'next' and 'prev' (previous) URIs to simplify stepping through the list.

The data returned may be plain text, compressed gzipped files or a JSON structure.

Most API queries are 'synchronous' and results are returned immediately. Some queries may require a substantial time to compute results, in these cases you can select the asynchronous option by adding '&asynchronous=1' to the end of the query string. This query will then return a URL which will return the query results when they are ready.


annotation

Description

All annotations of a metagenome for a specific annotation type and source

info - request

Description

Returns description of parameters and attributes.

This is a synchronous GET request. This request has no parameters.

sequence - request

Description

tab delimited annotated sequence stream

This is a stream GET request.

Parameters

Example

Return Attributes

sequence - request

Description

tab delimited annotated sequence stream

This is a stream POST request.

Parameters

Example

Return Attributes

similarity - request

Description

tab delimited blast m8 with annotation

This is a stream GET request.

Parameters

Example

Return Attributes

similarity - request

Description

tab delimited blast m8 with annotation

This is a stream POST request.

Parameters

Example

Return Attributes


compute

Description

Calculate various statistics for given input data.

info - request

Description

Returns description of parameters and attributes.

This is a synchronous GET request. This request has no parameters.

alphadiversity - request

Description

Calculate alpha diversity value for given ID and taxon level.

This is a synchronous or asynchronous GET request.

Parameters

Example

Return Attributes

rarefaction - request

Description

Calculate rarefaction x-y coordinates for given ID and taxon level.

This is a synchronous or asynchronous GET request.

Parameters

Example

Return Attributes

blast - request

Description

Produce NCBI-BLAST sequence alinments for given md5sum and its hits.

This is a synchronous or asynchronous GET request.

Parameters

Example

Return Attributes

normalize - request

Description

Calculate normalized values for given input data.

This is a synchronous POST request.

Parameters

Example

Return Attributes

distance - request

Description

Calculate a distance matrix for given input data.

This is a synchronous POST request.

Parameters

Example

Return Attributes

heatmap - request

Description

Calculate a dendrogram for given input data.

This is a synchronous POST request.

Parameters

Example

Return Attributes

pcoa - request

Description

Calculate a PCoA for given input data.

This is a synchronous POST request.

Parameters

Example

Return Attributes


darkmatter

Description

An analysis file from the processing of a metagenome from a specific stage in its analysis

info - request

Description

Returns description of parameters and attributes.

This is a synchronous GET request. This request has no parameters.

instance - request

Description

Returns a darkmatter sequence file.

This is a synchronous GET request.

Parameters

Example

Return Attributes


download

Description

An analysis file from the processing of a metagenome from a specific stage in its analysis

info - request

Description

Returns description of parameters and attributes.

This is a synchronous GET request. This request has no parameters.

instance - request

Description

Returns a single sequence file.

This is a synchronous GET request.

Parameters

Example

Return Attributes

history - request

Description

Summary of MG-RAST analysis-pipeline workflow and commands.

This is a synchronous GET request.

Parameters

Example

Return Attributes

setlist - request

Description

Returns a list of sets of sequence files for the given id.

This is a synchronous GET request.

Parameters

Example

Return Attributes


inbox

Description

inbox receives user inbox data upload, requires authentication, see http://blog.metagenomics.anl.gov/mg-rast-v3-2-faq/#api_submission for details

info - request

Description

Returns description of parameters and attributes.

This is a synchronous GET request. This request has no parameters.

view - request

Description

lists the contents of the user inbox

This is a synchronous GET request.

Parameters

Example

Return Attributes

view_pending - request

Description

view status of AWE inbox actions

This is a synchronous GET request.

Parameters

Example

Return Attributes

upload - request

Description

receives user inbox data upload, auto-uncompress if has .gz or .bz2 file extension

This is a synchronous POST request.

Parameters

Example

Return Attributes

delete - request

Description

delete indicated file from inbox

This is a synchronous DELETE request.

Parameters

Example

Return Attributes

unpack - request

Description

unpacks an archive upload into mutlple inbox files. supports: .zip, .tar, .tar.gz, .tar.bz2

This is a synchronous POST request.

Parameters

Example

Return Attributes

file_info - request

Description

get basic file info - returns results and updates shock node

This is a synchronous GET request.

Parameters

Example

Return Attributes

validate_metadata - request

Description

validate metadata spreadsheet in inbox

This is a synchronous GET request.

Parameters

Example

Return Attributes

seq_stats - request

Description

runs sequence stats on file in user inbox - submits AWE job

This is a asynchronous GET request.

Parameters

Example

Return Attributes

cancel - request

Description

cancel (delete) given AWE job ID

This is a synchronous GET request.

Parameters

Example

Return Attributes

rename - request

Description

rename indicated file from inbox

This is a synchronous POST request.

Parameters

Example

Return Attributes

sff_to_fastq - request

Description

create fastq file from sff file - submits AWE job

This is a asynchronous POST request.

Parameters

Example

Return Attributes

demultiplex - request

Description

demultiplex seq file with barcode file - submits AWE job

This is a asynchronous POST request.

Parameters

Example

Return Attributes

pair_join - request

Description

merge overlapping paired-end fastq files - submits AWE job

This is a asynchronous POST request.

Parameters

Example

Return Attributes

pair_join_demultiplex - request

Description

merge overlapping paired-end fastq files and demultiplex based on index file - submits AWE job

This is a asynchronous POST request.

Parameters

Example

Return Attributes


library

Description

A library of metagenomic sequences from some environment linked to a specific sample

info - request

Description

Returns description of parameters and attributes.

This is a synchronous GET request. This request has no parameters.

query - request

Description

Returns a set of data matching the query criteria.

This is a synchronous GET request.

Parameters

Example

Return Attributes

instance - request

Description

Returns a single data object.

This is a synchronous GET request.

Parameters

Example

Return Attributes


m5nr

Description

M5NR provides data through a comprehensive non-redundant protein / rRNA database

info - request

Description

Returns description of parameters and attributes.

This is a synchronous GET request. This request has no parameters.

ontology - request

Description

Return functional hierarchy

This is a synchronous GET request.

Parameters

Example

Return Attributes

taxonomy - request

Description

Return organism hierarchy

This is a synchronous GET request.

Parameters

Example

Return Attributes

sources - request

Description

Return all sources in M5NR

This is a synchronous GET request.

Parameters

Example

Return Attributes

accession - request

Description

Return annotation of given source protein ID

This is a synchronous GET request.

Parameters

Example

Return Attributes

md5 - request

Description

Return annotation(s) or sequence of given md5sum (M5NR ID)

This is a synchronous GET request.

Parameters

Example

Return Attributes

function - request

Description

Return annotations for function names containing the given text

This is a synchronous GET request.

Parameters

Example

Return Attributes

organism - request

Description

Return annotations for organism names containing the given text

This is a synchronous GET request.

Parameters

Example

Return Attributes

sequence - request

Description

Return annotation(s) for md5sum (M5NR ID) of given sequence

This is a synchronous GET request.

Parameters

Example

Return Attributes

accession - request

Description

Return annotations of given source protein IDs

This is a synchronous POST request.

Parameters

Example

Return Attributes

md5 - request

Description

Return annotations or sequences of given md5sums (M5NR ID)

This is a synchronous POST request.

Parameters

Example

Return Attributes

function - request

Description

Return annotations for function names containing the given texts

This is a synchronous POST request.

Parameters

Example

Return Attributes

function_id - request

Description

Return annotations for given function IDs

This is a synchronous POST request.

Parameters

Example

Return Attributes

organism - request

Description

Return annotations for organism names containing the given texts

This is a synchronous POST request.

Parameters

Example

Return Attributes

sequence - request

Description

Return annotations for md5s (M5NR ID) of given sequences

This is a synchronous POST request.

Parameters

Example

Return Attributes

create - request

Description

Create cassandra keyspace for new M5NR version, requires admin auth token

This is a synchronous POST request.

Parameters

Return Attributes

insert - request

Description

Insert data into given cassandra table for new M5NR version, requires admin auth token

This is a synchronous POST request.

Parameters

Return Attributes


matrix

Description

A profile in biom format that contains abundance counts

info - request

Description

Returns description of parameters and attributes.

This is a synchronous GET request. This request has no parameters.

organism - request

Description

Returns a BIOM v1.0 object as described here: http://biom-format.org/documentation/format_versions/biom-1.0.html

This is a asynchronous GET request.

Parameters

Example

Return Attributes

function - request

Description

Returns a BIOM v1.0 object as described here: http://biom-format.org/documentation/format_versions/biom-1.0.html.

This is a asynchronous GET request.

Parameters

Example

Return Attributes


metadata

Description

Metagenomic metadata is data providing information about one or more aspects of a set sequences from a sample of some environment

info - request

Description

Returns description of parameters and attributes.

This is a synchronous GET request. This request has no parameters.

patch - request

Description

This is a synchronous GET request.

Parameters

Return Attributes

template - request

Description

Returns static template for metadata object relationships and types

This is a synchronous GET request.

Parameters

Example

Return Attributes

cv - request

Description

Returns static controlled vocabularies used in metadata. By default returns all CVs at latest version. If label and version options used, returns those specific values.

This is a synchronous GET request.

Parameters

Example

Return Attributes

ontology - request

Description

Returns static ontology used in metadata for the given name and version.

This is a synchronous GET request.

Parameters

Example

Return Attributes

ontology - request

Description

Update metadata CV ontology with new version, requires admin auth token

This is a synchronous POST request.

Parameters

Return Attributes

version - request

Description

Returns all versions available for given ontology.

This is a synchronous GET request.

Parameters

Example

Return Attributes

view - request

Description

Returns list of unique metadata values submitted by users for given label

This is a synchronous GET request.

Parameters

Example

Return Attributes

export - request

Description

Returns full nested metadata for a project in same format as template, or metadata for a single metagenome.

This is a synchronous GET request.

Parameters

Example

Return Attributes

import - request

Description

Create project with given metadata spreadsheet and metagenome IDs, either upload or shock node

This is a synchronous POST request.

Parameters

Example

Return Attributes

update - request

Description

Update project with given metadata spreadsheet and metagenome IDs, either upload or shock node

This is a synchronous POST request.

Parameters

Example

Return Attributes

validate - request

Description

Validate given metadata spreadsheet, either upload or shock node

This is a synchronous POST request.

Parameters

Example

Return Attributes

validate - request

Description

Validate given metadata value

This is a synchronous GET request.

Parameters

Example

Return Attributes


metagenome

Description

A metagenome is an analyzed set sequences from a sample of some environment

info - request

Description

Returns description of parameters and attributes.

This is a synchronous GET request. This request has no parameters.

query - request

Description

Returns a set of data matching the query criteria.

This is a synchronous GET request.

Parameters

Example

Return Attributes

instance - request

Description

Returns a single data object.

This is a synchronous GET request.

Parameters

Example

Return Attributes


mixs

Description

info - request

Description

Returns description of parameters and attributes.

This is a synchronous GET request. This request has no parameters.

instance - request

Description

Retrieve MiXS Profile object for given ID

This is a synchronous GET request.

Parameters

Example

Return Attributes

query - request

Description

Listing of avaiable MiXS Profiles in MG-RAST

This is a synchronous GET request.

Parameters

Return Attributes

validate - request

Description

Validate a MiXS Profile against current schema

This is a synchronous POST request.

Parameters

Return Attributes

upload - request

Description

Upload a new MiXS Profile to MG-RAST

This is a synchronous POST request.

Parameters

Return Attributes

update - request

Description

Update an existing MiXS Profile in MG-RAST

This is a synchronous POST request.

Parameters

Return Attributes

schema - request

Description

Retrieve current MiXS Schema

This is a synchronous GET request.

Parameters

Return Attributes

schema - request

Description

Update current MiXS Schema

This is a synchronous POST request.

Parameters

Return Attributes


profile

Description

A feature profile in json format that contains abundance and similarity values along with annotations

info - request

Description

Returns description of parameters and attributes.

This is a synchronous GET request. This request has no parameters.

instance - request

Description

Submits profile creation

This is a asynchronous GET request.

Parameters

Example

Return Attributes

status - request

Description

Return profile status and/or results

This is a synchronous GET request.

Parameters

Example

Return Attributes


project

Description

A project is a composition of samples, libraries and metagenomes being analyzed in a global context.

info - request

Description

Returns description of parameters and attributes.

This is a synchronous GET request. This request has no parameters.

query - request

Description

Returns a set of data matching the query criteria.

This is a synchronous GET request.

Parameters

Example

Return Attributes

instance - request

Description

Returns a single data object.

This is a synchronous GET request.

Parameters

Example

Return Attributes


researchobject

Description

Research Object Manifest for MG-RAST Metagenome

info - request

Description

Returns description of parameters and attributes.

This is a synchronous GET request. This request has no parameters.

manifest - request

Description

Returns a single manifest object.

This is a synchronous GET request.

Parameters

Return Attributes


sample

Description

A metagenomic sample from some environment.

info - request

Description

Returns description of parameters and attributes.

This is a synchronous GET request. This request has no parameters.

query - request

Description

Returns a set of data matching the query criteria.

This is a synchronous GET request.

Parameters

Example

Return Attributes

instance - request

Description

Returns a single data object.

This is a synchronous GET request.

Parameters

Example

Return Attributes


search

Description

Elastic search for Metagenomes

info - request

Description

Returns description of parameters and attributes.

This is a synchronous GET request. This request has no parameters.

upsert - request

Description

Elastic Upsert

This is a synchronous POST request.

Parameters

Return Attributes

query - request

Description

Elastic search

This is a synchronous GET request.

Parameters

Example

Return Attributes


submission

Description

submission runs input through a series of validation and pre-processing steps, then submits the results to the MG-RAST anaylsis pipeline. this requires authentication

info - request

Description

Returns description of parameters and attributes.

This is a synchronous GET request. This request has no parameters.

list - request

Description

list all submissions by user

This is a synchronous GET request.

Parameters

Return Attributes

status - request

Description

get status of submission from ID

This is a synchronous GET request.

Parameters

Return Attributes

delete - request

Description

delete all files and running processes for given submission ID

This is a synchronous DELETE request.

Parameters

Return Attributes

submit - request

Description

start new submission

This is a asynchronous POST request.

Parameters

Return Attributes

ebi-submit - request

Description

start new EBI submission

This is a asynchronous POST request.

Parameters

Return Attributes


validation

Description

validates templates for correct structure and data to fit a valid template

info - request

Description

Returns description of parameters and attributes.

This is a synchronous GET request. This request has no parameters.

template - request

Description

Checks if the referenced JSON structure is a valid template

This is a synchronous GET request.

Parameters

Example

Return Attributes

data - request

Description

Returns a single data object.

This is a synchronous GET request.

Parameters

Example

Return Attributes