Execute.route_login_platform = 'https://<hostname>.emedgene.com/api/auth/v2/api_login/'
payload = {"username": user_name, "password": password}
response = requests.post(route_login_platform, json=payload)
access_token = response.json().get('access_token')
token_type = response.json().get('token_type')
print(f'{token_type.capitalize()} {access_token}')route_login_platform = 'https://<hostname>.emg.illumina.com/api/auth/v2/api_login/'
payload = {"username": user_name, "password": password}
response = requests.post(route_login_platform, json=payload)
access_token = response.json().get('access_token')
token_type = response.json().get('token_type')
bearer_token = f'{token_type.capitalize()} {access_token}'
print(bearer_token)import base64
api_key = 'my-api-key'
route_token_platform = 'https://<hostname>.login.illumina.com/platform-services-manager/Token'
# Prepare the API Key
client_id_apikey = f'emedgene:{api_key}'
client_id_apikey_bytes = client_id_apikey.encode("ascii")
client_id_apikey_base64_bytes_encoded = base64.b64encode(client_id_apikey_bytes)
client_id_decoded = client_id_apikey_base64_bytes_encoded.decode("ascii")
# Use the API Key
headers = {
'Authorization': f'Basic {client_id_decoded}'
}
params = {
"audience": "emedgene",
"grant_type": "api_key"
}
response = requests.post(route_token_platform, params=params, headers=headers)
access_token = response.json().get('access_token')
token_type = response.json().get('token_type')
bearer_token = f'{token_type.capitalize()} {access_token}'
print(bearer_token)curl -X 'POST' 'https://<hostname>.emg.illumina.com/api/some/command/path/'
-H 'Authorization': 'Bearer your-auth-token'
-d '{"DataName": "DataValue", ...}' import requests
url = 'https://<hostname>.emg.illumina.com/api/some/command/path'
headers = {
'Authorization': 'Bearer your-auth-token',
}
data = {
'DataName': 'DataValue',
}
response = requests.post(url=url, headers=headers, json=data)import requests
url = 'https://<hostname>.emg.illumina.com/api/some/command/path'
headers = {
'Authorization': 'Bearer your-auth-token',
}
response = requests.get(url=url, headers=headers)import requests
headers = {
'Authorization': 'Bearer your-auth-token',
}
# Store the API response in a response variable
response = requests.get('https://<hostname>.emg.illumina.com/api/test', headers=headers)# Display the response status code
print(f"Response status code: {response.status_code}")
# Display the data from the request
print(response.json().get("hits"))import json
# Print JSON data in readable format with indentation and sorting.
print(json.dumps(response.json().get("hits"), indent=3, sort_keys=True))import requests
params = {
'from': 5, # get the 6th case
'size': 10 # get 10 cases
}
headers = {
'Authorization': 'Bearer your-auth-token',
}
# Store the API response in a response variable
response = requests.get('https://<hostname>.emg.illumina.com/api/test', params=params, headers=headers)url = 'https://<hostname>.emg.illumina.com/api/storage'
headers = {
'Authorization': 'Bearer your-auth-token',
}
response = requests.get(url, headers=headers)
print(response.json().get("hits"))url = 'https://<hostname>.emedgene.com/api/cases/v2/cases'
headers = {
'Authorization': 'Bearer your-auth-token'
}
data = {...}
response = requests.post(url, json=data, headers=headers)case_name = response.json().get("name")url = f'https://<hostname>.emg.illumina.com/api/test/{case_name}?test_fields=status'
headers = {
'Authorization': 'Bearer your-auth-token'
}
response = requests.get(url, headers=headers)
print(response.json())url = f'https://<hostname>.emg.illumina.com/api/test/{case_name}'
headers = {
'Authorization': 'Bearer your-auth-token'
}
response = requests.get(url, headers=headers)
print(response.json())url = f'https://<hostname>.emg.illumina.com/api/test/{case_name}?test_fields=status&test_fields=participants&test_fields=patients'
headers = {
'Authorization': 'Bearer your-auth-token'
}
response = requests.get(url, headers=headers)
print(response.json())url = f'https://<hostname>.emg.illumina.com/api/candidates/{case_name}'
headers = {
'Authorization': 'Bearer your-auth-token'
}
response = requests.get(url, headers=headers)
print(response.json().get("hits"))url = f'https://<hostname>.emg.illumina.com/api/test/{case_name}/export'
headers = {
'Authorization': 'Bearer your-auth-token'
}
response = requests.get(url, headers=headers)
print(response.json().get("hits"))



This page provides several code examples demonstrating how to use the platform for common scenarios. While you don't need to follow or implement every example, they can serve as useful starting points
import requests
route_case_creation_url = 'https://<hostname>.emg.illumina.com/api/cases/v2/cases/'
payload = {
"sharing_level": 0,
"should_upload": False,
"test_data": {
"analysis_type": None,
"boostGenes": False,
"consanguinity": False,
"disease_penetrance": 100,
"disease_severity": "",
"diseases": [],
"gene_list": {
"id": 1,
"type": "all",
"visible": False
},
"incidental_findings": None,
"inheritance_modes": [],
"labels": [],
"notes": "",
"patients": {
"other": [],
"proband": {
"dead": False,
"detailed_ethnicity": {
"maternal": [],
"paternal": []
},
"fastq_sample": "<proband sample name>",
"gender": "<proband gender>",
"healthy": False,
"id": "proband",
"ignore": False,
"notes": "",
"phenotypes": [
{
"id": "phenotypes/<EMG_PHENOTYPE_0011856>",
"name": "Pica"
},
{
"id": "phenotypes/<EMG_PHENOTYPE_0000969>",
"name": "Edema"
}
],
"quality": "",
"relationship": "Test Subject",
"zygosity": ""
}
},
"sample_type": "<fastq or vcf>",
"samples": [
{
"directoryPath": "",
"fastq": "<proband sample name>",
"sampleFiles": [
{
"filename": "<proband file 1>.fastq.gz",
"path": "<full path/proband file 1>.fastq.gz",
"size": <file size>,
"status": "uploaded",
"storage_id": <storage provider id>
},
{
"filename": "<proband file 2>.fastq.gz",
"path": "<full path/proband file 2>.fastq.gz",
"size": <file size>,
"status": "uploaded",
"storage_id": <storage provider id>
}
],
"sampleType": "<fastq or vcf>",
"status": "uploaded",
"storage_id": <storage provider id>
}
],
"selected_preset_set": None,
"sequence_info": {
"intersect_bed_id": None,
"kit": "<kit name>",
"kit_id": <kit id>
},
"type": "<case type>"
}
}
headers = {'Authorization': 'Bearer <your-auth-token>'}
response = requests.post(route_case_creation_url, json=payload, headers=headers)# Check response status:
status = response.json().get("Status")
# Get the case name:
case_name = response.json().get("name")import requests
# Define the email addresses you want to search for
emails_to_search = ["[email protected]", "[email protected]"]
participant_ids = []
user_url = 'https://<hostname>.emg.illumina.com/api/user/org_users/'
response = requests.get(user_url, headers=headers)
if response.status_code == 200:
users = response.json().get("hits", [])
for user in users:
if user.get("email") in emails_to_search:
participant_ids.append(user.get("id"))assign_url = f'https://<hostname>.emg.illumina.com/api/participant/{case_name}'
payload = {"action": "assign", "ids": participant_ids}
response = requests.post(url=assign_url, json=payload, headers=headers)
if response.status_code == 200:
print(f"Participants {participant_ids} assigned to case {case_name}.")
else:
print(f"Failed to assign participants to case {case_name}. Response: {response.json()}")import requests
url = 'https://<hostname>.emg.illumina.com/api/test/{case_name}/info'
headers = {
'Authorization': 'Bearer <your-auth-token>'
}
response = requests.get(url=url, headers=headers)
# Output the case information
print(response.json())import requests
url = 'https://<hostname>.emg.illumina.com/api/candidates/{case_name}'
headers = {
'Authorization': 'Bearer <your-auth-token>'
}
response = requests.get(url=url, headers=headers)
# Output the variants with tags and their information
print(response.json())case_name = case.get("name")
update_url = f'https://<hostname>.emg.illumina.com/api/test/{case_name}'
payload = {"status": "custom_status_1"}
response = requests.put(url=update_url, json=payload, headers=headers)
if response.status_code == 200:
print(f"Case {case_name} updated to 'custom_status_1'.")
else:
print(f"Failed to update case {case_name}. Response: {response.json()}")from datetime import datetime, timedelta
# Calculate the date 24 hours ago
from_status_change_date = (datetime.now() - timedelta(days=1)).isoformat()
url = f'https://<hostname>.emg.illumina.com/api/test?from_status_change_date={from_status_change_date}&status=finalized'
response = requests.get(url=url, headers=headers)
finalized_cases = response.json()url = 'https://<hostname>.emg.illumina.com/api/test/{case_name}/reports/English/null/?candidates=true&full_export=true&incidental=true'
headers = {
'Authorization': 'Bearer <your-auth-token>'
}
response = requests.get(url=url, headers=headers)
print(response.json())import requests
case_name = "EMG123456789"
url = f'https://<hostname>.emg.illumina.com/api/test/<case_name>/preset_group'
headers = {'Authorization': 'Bearer <your-api-key>'}
# Define the gene lists to be added on top of the existing preset group
first_gene_list_name = "my gene list"
first_gene_list_id = 1
second_gene_list_name = "my gene list 2"
second_gene_list_id = 2
data = {
"name": "<name-of-new-custom-preset-group>",
"filter": {
"search": [
{
"id": first_gene_list_id,
"name": first_gene_list_name,
"type": "gene list",
"value": first_gene_list_name
},
{
"id": second_gene_list_id,
"name": second_gene_list_name,
"type": "gene list",
"value": second_gene_list_name
}
]
}
}
response = requests.post(url, json=data, headers=headers)
if response.status_code == 201:
print("Custom preset group created successfully.")
else:
print(f"Failed to create custom preset group. Status code: {response.status_code}")










