API Beginner Guide
This guide provides instructions on using the Curate API to create, update, and search for variants and genes, and on exporting Curate data to a CSV.
API Introduction
Operations from the Emedgene Curate's graphical user interface (GUI) can also be performed by using the Emedgene Curate's API.
Following are some basic examples of how to use Emedgene Curate's API with Python.
For instructions on using the API with other programming languages, please refer to their respective documentation.
Prerequisites
An installed copy of Python (https://www.python.org/)
The Python package installer, pip (https://pip.pypa.io/)
The requests library installed (run
pip install requests
)Each API call requires the user to have the corresponding role. See User roles for more information.
Authentication
In order to perform a secure session with Emedgene's API servers you should first accomplish the authentication phase and retrieve the bearer token. To accomplish this, follow the Authentication steps here.
API Reference
The different API commands can be found at https://<hostname>.emedgene.com/api/kms/apidoc/swagger or https://<hostname>.emg.illumina.com/api/kms/apidoc/swagger
It is useful to explore possible APIs and get an overview of the available parameters.
Creating Python requests from curl
The examples in the API Reference page use curl (Client URL), while Python uses requests. To convert from curl to Python follow the converstion steps here.
Examples
Variant
Create a New Variant
To create a new variant, send a POST
request with the required variant details.
Request Example (Python):
import requests
url = "https://<hostname>.emg.illumina.com/api/kms/variants/v2/variants"
headers = {
"Authorization": "Bearer <your-auth-token>"
}
data = {
"chromosome": "3",
"start": 122004036,
"ref": "T",
"alt": "C",
"human_reference": "GRCh38",
"variant_type": "SNV"
}
response = requests.post(url, json=data, headers=headers)
Response Fields:
The API response includes multiple fields, but the key values needed for future updates are:
id
: The unique identifier of the variant.variant_interpretation_ids
: A list of interpretation IDs associated with the variant.
These fields are required for updating the variant later.
Search for a Variant by chromosome position
To retrieve variant details by chromosome position, send a GET
request.
Request Example (Python):
import requests
chromsome = <chr>
start = <pos>
ref = <ref>
url = f"https://<hostname>.emg.illumina.com/api/api/kms/variants/v2/variants/search"
headers = {
"Authorization": "Bearer <your-auth-token>"
}
params = {
"human_reference": ref,
chromosome: chr,
start: start,
operator="AND"
}
response = requests.post(url, params=params, headers=headers)
Update an Existing Variant
To modify a variant, use the PATCH
method with the variant ID and interpretation ID retrieved from the creation response.
Request Example (Python):
import requests
variant_id = <variant-id> # Retrieved from the initial API response
interpretation_id = <interpretation-id> # Retrieved from the initial API response
url = f"https://<hostname>.emg.illumina.com/api/kms/variants/v2/variants/{variant_id}/interpretations/{interpretation_id}"
headers = {
"Authorization": "Bearer <your-auth-token>"
}
data = {
"id": variant_id,
"interpretationId": interpretation_id,
"transcript": "NM_XXXXXX" # The updated transcript value
}
response = requests.patch(url, json=data, headers=headers)
Delete a Variant
To delete a variant, use the DELETE
method with the variant ID from the response of the create, update, or search API responses.
import requests
variant_id = <variant-id> # Retrieved from the initial API response
url = f"https://<hostname>.emg.illumina.com/api/kms/variants/v2/variants/{variant_id}"
headers = {
"Authorization": "Bearer <your-auth-token>"
}
response = requests.delete(url, headers=headers)
Gene
Create a New Gene
New genes can only be created using a valid HGNC ID.
Request Example (Python):
import requests
url = "https://<hostname>.emg.illumina.com/api/kms/genes/v1/genes"
headers = {
"Authorization": "Bearer <your-auth-token>"
}
data = {"id": "EMG_GENE_HGNC:XXXXX"} # Replace with the relevant HGNC ID
response = requests.post(url, json=data, headers=headers)
Response Fields:
The API response contains multiple fields, but the key ones required for future updates are:
id
: The unique identifier of the gene.gene_interpretations
: A list of interpretation IDs associated with the gene.
Search for a Gene by HGNC ID
To retrieve gene details by HGNC ID, send a GET
request.
Request Example (Python):
import requests
hgnc_id = <hgnc-id>
url = f"https://<hostname>.emg.illumina.com/api/kms/genes/v1/genes/search"
headers = {
"Authorization": "Bearer <your-auth-token>"
}
params = {"q": hgnc_id} # q is the key name for HGNC ID
response = requests.post(url, params=params, headers=headers)
It is also possible to search by NCBI ID in the same way as searching by HGNC ID.
Update an Existing Gene
To modify a gene, use the PATCH
method with the gene ID and interpretation ID retrieved from the creation or search response.
Request Example (Python):
import requests
gene_id = <gene-id> # Retrieved from the initial API response
interpretation_id = <interpretation-id> # Retrieved from the initial API response
url = f"https://<hostname>.emg.illumina.com/api/kms/genes/v1/genes/{gene_id}/interpretations/{interpretation_id}"
headers = {
"Authorization": "Bearer <your-auth-token>"
}
data = {
"gene_id": gene_id,
"id": interpretation_id,
"transcript_ref_sequence": "NM_XXXXXX" # The updated transcript value
}
response = requests.patch(url, json=data, headers=headers)
Export
In order to export all curated variants or genes as a CSV file, use the following API endpoints:
Variants Export:
/api/kms/export/v1/export/variants
Genes Export:
/api/kms/export/v1/export/genes
Each request returns a pre-signed URL, which can be used to download the exported file directly from a browser. Since its generation, the URL is valid for 12 hours.
Note: The export is updated every 24 hours, so any changes made in Curate will be reflected in the following day's export.
Request Example (Python):
import requests
url = f"https://<hostname>.emg.illumina.com/api/kms/export/v1/export/variants"
headers = {
"Authorization": "Bearer <your-auth-token>"
}
response = requests.get(url, headers=headers)
Response Structure:
{"url":"https://s3.amazonaws.com/..........."}
It's possible to download the file by pasting the response URL in the browser.
The variant CSV will provide the following fields:
Variant Type
Pathogenicity
Chromosome
Position
End
REF
ALT
Interpretation
Notes
Diseases (OMIM ID)
Overlap %
The gene CSV will provide the following fields:
Gene Name
Group Type
Chromosome (37)
Start (37)
End (37)
Chromosome (38)
Start (38)
End (38)
NCBI ID
HGNC ID
Strand
Locus type
Interpretation
Note
Transcript reference sequence
Created epoch
Notes
Replace
<hostname>
with the correct API server hostname.Replace
<your-auth-token>
with a valid authentication token.Ensure IDs used in update requests match those received from the initial response.
Last updated
Was this helpful?