# MGnify API
> MGnify as an API, powered by EMBL-EBI — the world's largest free resource for the analysis and archiving of microbiome sequencing data, and the metagenomics sister to PRIDE (proteomics) and MetaboLights (metabolomics). MGnify holds tens of thousands of public metagenomics and metabarcoding studies spanning the human gut microbiome, marine and freshwater environments, soils, wastewater, the built environment and host-associated communities. Search the studies by keyword, getting each study's MGnify accession (MGYS...), name, abstract, biome, sample count and the source sequencing BioProject; read a study's full metadata including its name and abstract, biome classification, number of samples, submitting centre, public status, data origination and last-update date; and browse the GOLD-style biome classification tree — from root:Host-associated:Human:Digestive system to root:Environmental:Aquatic:Marine — with per-biome sample and study counts, for discovery by environment. Ideal for microbiome and environmental-genomics research, dataset reuse and meta-analysis, bioinformatics pipelines and teaching. Study accessions look like MGYS00006862. Data from EMBL-EBI MGnify.

## Authentication
All requests require your oanor API key in the `x-oanor-key` header. Get one at https://www.oanor.com/developer/keys.

```bash
curl -H "x-oanor-key: oanor_live_…" "https://api.oanor.com/mgnify-api/..."
```

## Pricing
- **Free** (Free) — 562 calls/Mo, 2 req/s
- **Starter** ($7/Mo) — 21,400 calls/Mo, 6 req/s
- **Pro** ($20/Mo) — 90,800 calls/Mo, 15 req/s
- **Mega** ($56/Mo) — 393,000 calls/Mo, 40 req/s

## Endpoints

### Metagenomics

#### `GET /v1/biomes` — Biome classification tree

**Parameters:**
- `page` (query, optional, string) — Page (1-based)
- `limit` (query, optional, string) — Max biomes (1-200)

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/mgnify-api/v1/biomes"
```

**Response:**
```json
{
    "data": {
        "page": 1,
        "count": 50,
        "total": 491,
        "biomes": [
            {
                "biome": "root:Engineered",
                "samples_count": 291,
                "studies_count": null
            },
            {
                "biome": "root:Engineered:Biogas plant",
                "samples_count": 126,
                "studies_count": null
            },
            {
                "biome": "root:Engineered:Biogas plant:Wet fermentation",
                "samples_count": 111,
                "studies_count": null
            },
            {
                "biome": "root:Engineered:Bioreactor",
                "samples_count": 1003,
                "studies_count": null
            },
            {
                "biome": "root:Engineered:Bioreactor:Continuous culture",
                "samples_count": 648,
                "studies_count": null
            },
            {
                "biome": "root:Engineered:Bioreactor:Continuous culture:Marine intertidal flat sediment inoculum",
                "samples_count": 23,
                "studies_count": null
            },
            {
                "biome": "root:Engineered:Bioreactor:Continuous culture:Marine intertidal flat sediment inoculum:Wadden Sea-Germany",
                "samples_count": 5,
                "studies_count": null
            },
            {
                "biome": "root:Engineered:Bioreactor:Continuous culture:Marine sediment inoculum",
   
…(truncated, see openapi.json for full schema)
```

#### `GET /v1/studies` — Search metagenomics studies

**Parameters:**
- `q` (query, required, string) — Search text, e.g. marine Example: `marine`
- `page` (query, optional, string) — Page (1-based)
- `limit` (query, optional, string) — Max results (1-100)

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/mgnify-api/v1/studies?q=marine"
```

**Response:**
```json
{
    "data": {
        "page": 1,
        "count": 20,
        "query": "marine",
        "total": 953,
        "studies": [
            {
                "id": "MGYS00006861",
                "name": "Marine metagenomic library of Baltic Sea collected in Latvia",
                "biome": "root:Environmental:Aquatic:Marine",
                "abstract": "Marine metagenomic library of Baltic Sea from three distinct locations collected during the period from August to October 2024 in Latvia",
                "bioproject": "PRJEB88144",
                "last_update": "2026-01-16T10:55:30",
                "samples_count": 25
            },
            {
                "id": "MGYS00006848",
                "name": "EMG produced TPA metagenomics assembly of PRJNA553005 data set (Metagenomic views of microbial dynamics influenced by hydrocarbon seepages in sediments of Gulf of Mexico).",
                "biome": "root:Environmental:Aquatic:Marine:Sediment",
                "abstract": "The Third Party Annotation (TPA) assembly was derived from the primary whole genome shotgun (WGS) data set PRJNA553005, and was assembled with metaspades v3.15.3. This project includes samples from the following biomes: root:Environmental:Aquatic:Marine:Sediment.",
                "bioproject": "PRJEB75476",
                "last_update": "2025-08-26T14:50:09",
                "samples_count": 7
            },
            {
                "id": "MGYS00006491",
                "name": "EMG produced 
…(truncated, see openapi.json for full schema)
```

#### `GET /v1/study` — A study metadata

**Parameters:**
- `id` (query, required, string) — MGnify accession, e.g. MGYS00006862 Example: `MGYS00006862`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/mgnify-api/v1/study?id=MGYS00006862"
```

**Response:**
```json
{
    "data": {
        "study": {
            "id": "MGYS00006862",
            "url": "https://www.ebi.ac.uk/metagenomics/studies/MGYS00006862",
            "name": "Metagenome assembly of PRJNA715245 data set (human gut metagenome Metagenome)",
            "biome": "root:Host-associated:Human:Digestive system:Large intestine",
            "abstract": "The Third Party Annotation (TPA) assembly was derived from the primary data set PRJNA715245",
            "is_public": null,
            "bioproject": "PRJEB92327",
            "centre_name": "EMG",
            "last_update": "2026-04-24T07:54:59",
            "samples_count": 84,
            "data_origination": "SUBMITTED",
            "secondary_accession": "ERP175206"
        }
    },
    "meta": {
        "timestamp": "2026-06-01T16:24:08.688Z",
        "request_id": "736f0eee-fd5f-4ea0-8571-e5845ce5baf3"
    },
    "status": "ok",
    "message": "Study retrieved",
    "success": true
}
```

### Meta

#### `GET /v1/meta` — Usage notes

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/mgnify-api/v1/meta"
```

**Response:**
```json
{
    "data": {
        "note": "MGnify is EMBL-EBI's resource for the analysis and archiving of microbiome sequencing data — the metagenomics sister to PRIDE (proteomics) and MetaboLights (metabolomics). /v1/studies?search=marine = search public metagenomics & metabarcoding studies (gut microbiome, marine, soil, wastewater, host-associated and environmental), returning each study's MGnify accession (MGYS…), name, abstract, biome, sample count and source BioProject; /v1/study?id=MGYS00006862 = a study's full metadata (name, abstract, biome classification, sample count, submitting centre, public status, source BioProject, last update); /v1/biomes (paginate with page & limit) = the GOLD-style biome classification tree (e.g. root:Host-associated:Human:Digestive system:Large intestine, root:Environmental:Aquatic:Marine) with per-biome sample and study counts, for discovery by environment. Study accessions look like MGYS00006862. Data from EMBL-EBI MGnify. For proteomics datasets see the PRIDE API, for metabolomics MetaboLights, for protein sequences UniProt.",
        "source": "EMBL-EBI MGnify metagenomics API (ebi.ac.uk/metagenomics)",
        "endpoints": [
            "/v1/studies",
            "/v1/study",
            "/v1/biomes",
            "/v1/meta"
        ]
    },
    "meta": {
        "timestamp": "2026-06-01T16:24:08.776Z",
        "request_id": "d99bf91e-21ad-4fc5-aacd-a26c0c8fc877"
    },
    "status": "ok",
    "message": "Meta retrieved",
    "success": true
…(truncated, see openapi.json for full schema)
```


---
Marketplace page: https://www.oanor.com/api/mgnify-api
OpenAPI spec: https://www.oanor.com/api/mgnify-api/openapi.json
