VirJenDB

Documentation

last update

2026-May-05

VirJenDB

v1.0

This page is up-to-date!

VirJenDB API

The VirJenDB API provides programmatic access to search, retrieve, and download viral genome data, and is available through the Swagger UI at https://api2.virjendb.org/swagger.

Overview of Endpoints

Endpoint Method Description
/v2/search POST Search the VirJenDB dataset
/v2/download POST Download search results or selected records
/v2/sequence POST Retrieve sequences by accession
/v2/datasets_download GET Download precomputed datasets
/v2/metadata POST Query metadata fields
/v2/metadata_download POST Download metadata field definitions

1. Search Endpoint

POST /v2/search

Search the VirJenDB dataset using structured JSON queries.

Request Body

{
  "items": [
    {
      "operator": "or",
      "metadataField": "string",
      "searchTerm": "string"
    }
  ],
  "filter": [
    { "field": "", "value": "" }
  ],
  "pageSize": 50,
  "pageNumber": 1,
  "sortColumn": "string",
  "sortOrder": "asc"
}

Fields

Field Description
items Array of search clauses. Each item contains operator, metadataField, and searchTerm.
filter Additional filters in { field, value } form.
pageSize Number of results per page. The API documents a maximum of 10,000.
pageNumber Page number to return.
sortColumn Field used to sort the results.
sortOrder Sort direction: asc or desc.

Notes

Responses

Code Description
200 Successful response
422 Validation error

Example Request

Search for records where the metadata field Host Species matches Escherichia coli.

{
  "items": [
    {
      "operator": "",
      "metadataField": "Host Species",
      "searchTerm": "Escherichia coli"
    }
  ],
  "filter": [],
  "pageSize": 50,
  "pageNumber": 1,
  "sortColumn": "",
  "sortOrder": "asc"
}

2. Download Endpoint

POST /v2/download

Download data based on search results or selected accession IDs.

Supported Data Types

Supported File Types

Request Body

The download request contains two top-level parts:

Download Object

Field Description
download.scope Controls which records are included in the download.
download.information Controls which data is exported.
download.fileType Output file type.
download.metadata Optional metadata fields to include.
download.selected_ids Accession IDs used when scope is selection.

Download Scope (download.scope)

Value Description
selection Download specific records listed in download.selected_ids.
max Download records that match the search object.
all Listed in Swagger, but not described in detail there. Treat this as undocumented unless the backend confirms its behavior.

selection

max

Information Type (download.information)

Value Description
metadata Export metadata fields for each record
virjendb_accessions Export only VirJenDB accession IDs
sequences Export sequence data in FASTA format

Details

metadata

virjendb_accessions

sequences

File Type (download.fileType)

Type Description
csv Comma-separated values
tsv Tab-separated values
json JSON output
xml XML output
fasta FASTA output, only for sequence downloads

Search Object in Downloads

When download.scope is max, the search object follows the same structure as the /v2/search endpoint.

It supports:

Important Notes

Errors

Code Meaning
400 Bad request, invalid parameters, or unsupported combination
404 No results found
422 Validation error
500 Internal server error

Example Request

Download sequences for records where Host Species = Escherichia coli.

{
  "download": {
    "scope": "max",
    "information": "sequences",
    "fileType": "fasta",
    "metadata": ["Host Species", "Molecule Type"]
  },
  "search": {
    "items": [
      {
        "metadataField": "Host Species",
        "searchTerm": "Escherichia coli"
      }
    ],
    "filter": [],
    "pageSize": 50,
    "pageNumber": 1,
    "sortColumn": "",
    "sortOrder": "asc"
  }
}

3. Sequence Endpoint

POST /v2/sequence

Retrieve genome sequences using VirJenDB accession IDs.

Request Body

{
  "virjendb_accessions": [
    "vj000000000010",
    "vj000005747069"
  ]
}

Notes

4. Dataset Download

GET /v2/datasets_download

Download pre-generated VirJenDB dataset files.

Query Parameter

Name Description
filename Dataset file to download

Available Filenames

Example

filename=virjendbv1_full_dataset_sequence.csv.gz

5. Metadata Endpoints

Query Metadata Fields

POST /v2/metadata

Filter and retrieve metadata field definitions.

Request Body

{
  "field_name": [],
  "privacy": [],
  "tags": [],
  "submission_requiredness": [],
  "submission_fieldtype": [],
  "submission_validation": [],
  "match_mode": "and",
  "summary": false
}

Notes

Download Metadata Fields

POST /v2/metadata_download

Download metadata definitions as a file.

Request Body

{
  "field_name": [],
  "file_type": "csv"
}

Notes

dditional Resources

Table of Contents