4 Apr 2019
16 Oct 2018
Contact API support directly via email (api-support@lifenome.com) or report a bug or feature request on the Trello board (Trello account must be created and permission must be granted to the board by the API support team. The board itself contains information on how to use the issue tracker).
Lifenome API is the REST web service which exposes functionalities for the following resources:
https://api.lifenome.com
OAuth2 - an open protocol to allow secure authorization in a simple and standard method from web, mobile and desktop applications.
The OAuth 2.0 grant that machine-to-machine interfaces utilize in order to access an API, is the Client Credentials Grant.
With Client Credentials Grant (defined in RFC 6749, section 4.4) a Non Interactive Client (a CLI, a daemon, or a Service running on your backend), can directly ask Auth0 for an access_token, by using its Client Credentials (Client Id and Client Secret) to authenticate. In this case the token represents the Non Interactive Client itself, instead of an end user.
You can ask Lifenome API for tokens for any of your authorized applications with issuing the following API call:
curl --request POST \
--url https://lifenome.auth0.com/oauth/token \
--header 'content-type: application/json' \
--data '{"client_id": "<CLIENT_ID>", "client_secret": "<CLIENT_SECRET>", "audience": "https://api.lifenome.com/profiles", "grant_type": "client_credentials"}'
Response:
{
"access_token": "<ACCESS_TOKEN>",
"token_type": "Bearer"
}
You can now extract the access_token
property from the response to make authorized requests to your API.
You can use this Bearer token with an Authorization Header in your request to obtain authorized access to your API.
curl --request GET \
--url https://api.lifenome.com/<ENDPOINT>/ \
--header 'authorization: Bearer <ACCESS_TOKEN>'
Security scheme type: | OAuth2 |
---|---|
clientCredentials OAuth Flow | Token URL: https://lifenome.auth0.com/oauth/token Scopes:
|
This section lists one possible usage scenario for the Lifenome API with the demonstration of the complete workflow - starting from the authentication procedure and finishing with the reading of the trait assessments for the newly created profile. In order to read the genetic trait assessments for the existing genetic data, API client needs to:
Steps 1-8. are described in the following sections.
First, authentication token must be obtained by calling the authentication endpoint:
curl --url "https://lifenome.auth0.com/oauth/token" \
--request POST \
--header 'content-type: application/json' \
--data '{"client_id": "<CLIENT_ID>", "client_secret": "<CLIENT_SECRET>", "audience": "https://api.lifenome.com/profiles", "grant_type": "client_credentials"}'
Also, token can be extracted into environment variable using e.g. jq tool:
export ACCESS_TOKEN=$(curl --url 'https://lifenome.auth0.com/oauth/token' --request POST --header 'content-type: application/json' --data '{"grant_type":"client_credentials","client_id": "<CLIENT_ID>","client_secret": "<CLIENT_SECRET>","audience": "https://api.lifenome.com/profiles"}' | jq -r '.access_token')
Fetched access token must be included into the Authorization header for every subsequent request to protected resources of the API.
Note that <CLIENT_ID>
and <CLIENT_SECRET>
can be obtained by contacting the API support.
Every genetic file that will be analyzed must be connected to a Profile resource. Before uploading of the genetic file and obtaining the assessment data, profile must be created:
curl --url "https://api.lifenome.com/profiles/" \
--request POST \
--header "Authorization: Bearer ${ACCESS_TOKEN}" \
--header "Content-Type: application/json" \
--data '{"first_name": "John", "last_name": "Doe", "age": 32}'
{
"id": "<PROFILE_ID>",
"email": "",
"first_name": "John",
"last_name": "Doe",
"gender": 0,
"age": 32,
"ethnicity": 0
}
Successful operation will return status code 201 Created
and the added profile will be assigned with the unique profile id string (<PROFILE_ID>
) that will be used for accessing operations on the profile.
Using the profile id, the profile that was just created will be available at the profile endpoint:
curl --url "https://api.lifenome.com/profiles/<PROFILE_ID>/" \
--header "Authorization: Bearer ${ACCESS_TOKEN}" \
--header "Content-Type: application/json"
{
"id": "<PROFILE_ID>",
"email": "",
"first_name": "John",
"last_name": "Doe",
"gender": 0,
"age": 32,
"ethnicity": 0
}
Also, added profile will be listed at the profile collection endpoint:
curl --url "https://api.lifenome.com/profiles/" \
--header "Authorization: Bearer ${ACCESS_TOKEN}" \
--header "Content-Type: application/json"
[
{
"id": "<PROFILE_ID>",
"email": "",
"first_name": "John",
"last_name": "Doe",
"gender": 0,
"age": 32,
"ethnicity": 0
}
]
Genetic files are uploaded directly to Lifenome storage servers by first fetching the time-limited secure storage URL for the corresponding profile (<PROFILE_ID>
) using the endpoint:
curl --url "https://api.lifenome.com/profiles/<PROFILE_ID>/genotype/upload/" \
--request GET \
--header "Authorization: Bearer ${ACCESS_TOKEN}" \
--header "Content-Type: application/json"
{
"url": "<UPLOAD_URL>"
}
Genetic file itself (<FILE_PATH>
) can be uploaded directly to the provided <UPLOAD_URL>
:
curl -X PUT -H 'content-type: text/plain' --data-binary @<FILE_PATH> "<UPLOAD_URL>"
Please note the method PUT
used for the upload (POST
will not work).
When the file upload completes, Lifenome backend will automatically start processing the file. Results will be available for retrieval once all the calculations are completed. Currently, the only way to test if the asynchronous automatic processing finished is to poll the Profile Traits endpoint (see sections 5. and 6. in this chapter). Also, file processing can be initiated using the synchronous call that will block the caller using the operation:
curl --url "https://api.lifenome.com/profiles/<PROFILE_ID>/genotype/upload/" \
--request POST \
--header "Authorization: Bearer ${TOKEN}" \
--header "Content-Type: application/json"
Lifenome API calculates genetic assessments for the selected set of Traits. Every trait is represented with the unique trait code. List of all traits assigned to the given API client, with included pricing type, is exposed at the endpoint:
curl --url "https://api.lifenome.com/traits/" \
--request GET \
--header "Authorization: Bearer ${ACCESS_TOKEN}" \
--header "Content-Type: application/json"
[
{
"trait" : {
"code": "trait_code_1",
"name": "Trait 1",
"overview": "<p>This is the description of Trait 1.</p>",
"connotation": "risky"
},
"type": "basic"
},
{
"trait" : {
"code": "trait_code_2",
"name": "Trait 2",
"overview": "<p>This is the description of Trait 2.</p>",
"connotation": "risky"
},
"type": "basic"
},
{
"trait" : {
"code": "trait_code_3",
"name": "Trait 3",
"overview": "<p>This is the description of Trait 3.</p>",
"connotation": "good"
},
"type": "free"
},
{
"trait" : {
"code": "trait_code_4",
"name": "Trait 4",
"overview": "<p>This is the description of Trait 4.</p>",
"connotation": "good"
},
"type": "basic"
},
...
]
The endpoint returns list of Trait objects with trait code and additional trait metadata. All traits obtained from this endpoint will be considered for computation for the given API client.
In general, access to trait assessments is charged according to the existing pricing models. However, free traits can be assigned to clients. Each trait in the previous response includes trait type field which defines the pricing model. In the example, access to all traits will be charged, with the exception of Trait 3. Please use this endpoint to obtain list of free traits defined for your API client.
Some traits may not be available for the selected profile, regardless of the pricing model defined by type attribute. For example, maybe genetic data is incomplete and required genetic markers are missing for the particular trait. In order to get annotated list of traits that are analyzed and connected to a certain profile, Profile Traits endpoint must be called:
curl --url "https://api.lifenome.com/profiles/<PROFILE_ID>/traits/" \
--request GET \
--header "Authorization: Bearer ${ACCESS_TOKEN}" \
--header "Content-Type: application/json"
[
{
"trait": {
"code": "trait_code_1",
"name": "Trait 1",
"overview": "<p>This is the description of Trait 1.</p>",
"connotation": "risky"
},
"status": "available"
},
{
"trait": {
"code": "trait_code_2",
"name": "Trait 2",
"overview": "<p>This is the description of Trait 2.</p>",
"connotation": "risky"
},
"status": "available"
},
{
"trait": {
"code": "trait_code_3",
"name": "Trait 3",
"overview": "<p>This is the description of Trait 3.</p>",
"connotation": "good"
},
"status": "computed"
},
{
"trait": {
"code": "trait_code_4",
"name": "Trait 4",
"overview": "<p>This is the description of Trait 4.</p>",
"connotation": "good"
},
"status": "unavailable"
},
...
]
Response contains list of trait objects with trait codes and statuses. Detailed description of statuses is available here. If the Profile Traits endpoint returns empty response, this means that the genetic file is missing or the file upload/processing is still in progress.
Profile traits endpoint can be used for quick access to all free trait assessments in a single call, if there are any free traits defined for the client. If score
query parameter is provided for the GET
method on the Profile traits endpoint, the response will include assessment data for the computed traits (free traits are always automatically computed, unless it is not possible to compute them, e.g. incomplete genetic data):
curl --url "https://api.lifenome.com/profiles/<PROFILE_ID>/traits/?score" \
--request GET \
--header "Authorization: Bearer ${ACCESS_TOKEN}" \
--header "Content-Type: application/json"
[
{
"trait": {
"code": "trait_code_3",
"name": "Trait 3",
"overview": "<p>This is the description of Trait 3.</p>",
"connotation": "good"
},
"status": "computed",
"assessment_level": 1,
"recommendations": "...",
"percentile": 45.0,
"snps": ["rs12345"]
}
]
In order to read assessments for the selected set of (non-free) traits, assessment computation needs to be initiated. Note that computation can only be initiated for the traits that have available
value for the status attribute. If the trait assessments cannot be computed for a given profile, those traits will have status=unavailable
(e.g. incomplete genetic data). Moreover, if there are free traits assigned to your client, those traits will be automatically computed (status=computed
) and trait assessments can be retrieved without initiating the computation (Trait 3 in the previous example).
Assessment computation for the set of traits can be initiated with the call:
curl --url "https://api.lifenome.com/profiles/<PROFILE_ID>/traits/" \
--request POST \
--header "Authorization: Bearer ${ACCESS_TOKEN}" \
--header "Content-Type: application/json" \
--data '{"trait_codes": ["trait_code_1", "trait_code_2"]}'
[
{
"trait": {
"code": "trait_code_1",
"name": "Trait 1",
"overview": "<p>This is the description of Trait 1.</p>",
"connotation": "risky"
},
"status": "computed",
"assessment_level": 0,
"recommendations": "...",
"percentile": 15.0,
"snps": ["rs978739"]
},
{
"trait": {
"code": "trait_code_2",
"name": "Trait 2",
"overview": "<p>This is the description of Trait 2.</p>",
"connotation": "risky"
},
"status": "computed",
"assessment_level": 0,
"recommendations": "...",
"percentile": 5.0,
"snps": ["rs1175549"]
}
]
Response already includes list of trait codes with statuses and computed assessments. Request can include arbitrary number of trait codes, but only those traits with status=available
will be computed. Note that statuses of the computed traits will be changed to computed
.
Assessment for the previously computed selected profile trait can be fetched anytime using the known <PROFILE_ID>
and <TRAIT_CODE>
with the call:
curl --url "https://api.lifenome.com/profiles/<PROFILE_ID>/traits/<TRAIT_CODE>/" \
--request GET \
--header "Authorization: Bearer ${ACCESS_TOKEN}" \
--header "Content-Type: application/json"
{
"trait": {
"code": "trait_code_1",
"name": "Trait 1",
"overview": "<p>This is the description of Trait 1.</p>",
"connotation": "risky"
},
"status": "computed",
"assessment_level": 0,
"recommendations": "...",
"percentile": 15.0,
"snps": ["rs978739"]
}
Additionally, computation of the assessments can also be initiated anytime for a single trait using the same endpoint (with PUT
operation) and the response will include full computed assessment data:
curl --url "https://api.lifenome.com/profiles/<PROFILE_ID>/traits/<TRAIT_CODE>/" \
--request PUT \
--header "Authorization: Bearer ${ACCESS_TOKEN}" \
--header "Content-Type: application/json"
{
"trait": {
"code": "trait_code_x",
"name": "Trait x",
"overview": "<p>This is the description of Trait x.</p>",
"connotation": "risky"
},
"status": "computed",
"assessment_level": 0,
"recommendations": "...",
"percentile": 45.0,
"snps": ["rs12345"]
}
When creating genotype profiles using the API, client needs to submit files that contain genetic data. Genetic data is provided in the simple textual file, usually with .txt
or .csv
extensions, but the API also supports upload of compressed archives (.zip
, .gz
and .tar.gz
).
Genetic data stored inside textual files is divided into header and genetic data. All header lines are prefixed with #
character:
# header line 1
# header line 2
# ...
genetic data line 1
genetic data line 2
...
Lines that contain genetic data (SNPs) are formatted according to following rule:
RSID<sep>CHR[optional]<sep>POS[optional]<sep>A1<sep>A2
RSID
is the required SNP identifier and it must begin with prefix rs
.
CHR
is the optional chromosome identification. Allowed values
are numbers 1-23 or characters X
, Y
. Optionally, the value can
be prefixed with chr
.
POS
is the optional position within the chromosome (integer).
A1
is the required first allele for the given SNP (one of ATCG-
)
A2
is the required second allele for the given SNP (one of ATCG-
)
Note that <sep>
can be any valid separator (space, comma, tab). Also, separator can be repeated any number of times. Additionally, separator between alleles is optional.
Described file format is designed to support parsing of textual files from most popular data providers. For instance, samples from 23andme, ancestry.com or FamilyTreeDNA adhere to the presented data format and, as such, can be submitted directly to the API, without any extra file content manipulation. In addition to files fetched from the mentioned services, any textual file that is formatted according to the previously defined rules will be accepted by the API.
The following section presents some of the most common file formats supported by the API. The samples are taken from the popular genetic data providers. Note that some header lines are omitted from the examples.
# This data file generated by 23andMe ...
# rsid chromosome position genotype
rs1 1 734462 AA
...
#AncestryDNA raw data download ...
rsid chromosome position allele1 allele2
rs1 1 82154 A G
...
# name,chromosome,position,allele1,allele2
rs1,17,7579472,G,G
...
Profile resources are used to store person's metadata and person's genotype data which are used to compute genetic assessments of various traits.
Following endpoints expose operations on Profile resources:
Creates a new profile.
Authorization required | string Authorization header with access token. |
Profile object that needs to stored.
first_name | string First name |
last_name | string Last name |
gender | int Enum:0 1 2 Male = |
age | int Age |
ethnicity | int Enum:0 1 2 3 4 5 European (White) = |
Created
Invalid input
Production server
Returns list of all existing profiles.
Authorization required | string Authorization header with access token. |
Success
Unauthorized
Production server
curl "https://api.lifenome.com/profiles/" \ --header "Authorization: Bearer ${ACCESS_TOKEN}" \ --header "Content-Type: application/json"
Reads data for the existing profile.
profile_id required | string <uuid> Profile identifier |
Authorization required | string Authorization header with access token. |
Success
Unauthorized
Not Found
Production server
curl "https://api.lifenome.com/profiles/<PROFILE_ID>/" \ --header "Authorization: Bearer ${ACCESS_TOKEN}" \ --header "Content-Type: application/json"
Updates existing profile. This operation will perform complete update
which means that all properties of profile will be updated.
Properties missing in request body will be set to default value.
If you like to perform partial update then use PATCH
operation.
profile_id required | string <uuid> Profile identifier |
Authorization required | string Authorization header with access token. |
Profile object that needs to stored.
first_name | string First name |
last_name | string Last name |
gender | int Enum:0 1 2 Male = |
age | int Age |
ethnicity | int Enum:0 1 2 3 4 5 European (White) = |
Success
Unauthorized
Not Found
Production server
Partially updates existing profile. This operation will only update
properties which are present in request body. All other properties of
the profile will not be changed.
If you like to perform complete update then use PUT
operation.
profile_id required | string <uuid> Profile identifier |
Authorization required | string Authorization header with access token. |
Profile object that needs to stored.
first_name | string First name |
last_name | string Last name |
gender | int Enum:0 1 2 Male = |
age | int Age |
ethnicity | int Enum:0 1 2 3 4 5 European (White) = |
Success
Unauthorized
Not Found
Production server
Deletes profile and all existing files.
profile_id required | string <uuid> Profile identifier |
Authorization required | string Authorization header with access token. |
Success
Unauthorized
Not Found
Production server
curl -X delete \ "https://api.lifenome.com/profiles/<PROFILE_ID>/" \ --header "Authorization: Bearer ${ACCESS_TOKEN}"
Returns genotype metadata for the existing profile. Returns empty object if genetic file was not previously uploaded.
profile_id required | string <uuid> Profile identifier |
Authorization required | string Authorization header with access token. |
Success
Unauthorized
Not Found
Production server
curl "https://api.lifenome.com/profiles/<PROFILE_ID>/genotype/" \ --header "Authorization: Bearer ${ACCESS_TOKEN}" \ --header "Content-Type: application/json"
Profile Traits resources are child resources of the Profile resource. Following endpoints expose operations on Profile Traits resources:
Lists Profile's Traits annotated with assessment status. A trait assessment status can be:
available
: Assessment can be computed for a given trait. Note that client needs to initiate computation in order to fetch the assessment. In order to initiate computation, method Initiate computation for a set of traits can be used.unavailable
: Assessment can not be computed for a given trait. The most common reason is that profile's genotype data does not contain genetic markers required for a trait assessment computation.computed
: Assessment is already computed for the trait and the data is ready to be fetched by a client. Note: free traits will be automatically computed, if possible.Additionally, for the GET
method, if parameter score
is specified, then response will also include any existing assessment data.
Note: In case of non-existing genetic data or if the file processing is still in progress, response will contain empty list.
profile_id required | string <uuid> Profile identifier |
score | string Example: score=profiles%2F%7Bprofile_id%7D%2Ftraits%2F%3Fscore Adding this parameter to the request will fetch traits together with assessment data. Be aware that this means that only traits for which assessments are computed will be included in the response. |
Authorization required | string Authorization header with access token. |
Success
Unauthorized
Production server
curl --url "https://api.lifenome.com/profiles/<PROFILE_ID>/traits/" \ --request GET \ --header "Authorization: Bearer ${ACCESS_TOKEN}" \ --header "Content-Type: application/json"
Initiates the trait assessment computation for a given set of Profile Traits. List of trait codes is provided in the request body. Available trait codes can be obtained from the Client traits endpoint or the Profile Traits endpoint (includes trait statuses). This operation also immediately returns the assessment data for a given set of profile traits in order to avoid additional calls to Trait assessment endpoint.
profile_id required | string <uuid> Profile identifier |
Authorization required | string Authorization header with access token. |
List of trait codes for which assessment calculation will be initiated.
Trait code
Success
Unauthorized
Production server
Returns assessment for a given profile trait.
profile_id required | string <uuid> Profile identifier |
trait_code required | string Trait code |
Authorization required | string Authorization header with access token. |
Success
Unauthorized
Production server
curl --url "https://api.lifenome.com/profiles/<PROFILE_ID>/traits/<TRAIT_CODE>/" \ --request GET \ --header "Authorization: Bearer ${ACCESS_TOKEN}" \ --header "Content-Type: application/json"
Initiates assessment computation for the given profile trait and returns computed assessment.
profile_id required | string <uuid> Profile identifier |
trait_code required | string Trait code |
Authorization required | string Authorization header with access token. |
Success
Unauthorized
Production server
curl --url "https://api.lifenome.com/profiles/<PROFILE_ID>/traits/<TRAIT_CODE>/" \ --request PUT \ --header "Authorization: Bearer ${ACCESS_TOKEN}" \ --header "Content-Type: application/json"
Lifenome's fast and secure genotype storage is powered by Google Cloud infrastructure. Genetic files are uploaded directly to storage servers using time-limited secure URLs generated on-the-fly resulting in secure and scalable solution for genetic file uploading. Upon completion of the file upload, Lifenome backend will automatically start processing the uploaded file. For security reasons, time-limited secure URLs provide access to storage for only limited amount of time (currently 3 minutes). When the received URL expires, storage API will return appropriate response and client must ask for a new URL. The API currently supports only textual files (e.g. .txt
, .csv
, .tsv
) with content type text/plain
.
Returns secure URL for a time-limited access to profile's genotype storage. After the URL is fetched, client must upload the file directly to the given URL using the PUT
method with corresponding content type, usually text/plain
(see code snippet).
profile_id required | string <uuid> Profile identifier |
content-type | string Content type of the genotype file to be uploaded. Currently supported content types are "text/plain" (default) and "application/zip". Provided content type must be given on file upload. |
Authorization required | string Authorization header with access token. |
Success
Unauthorized
Not Found
Production server
curl --request GET --url https://api.lifenome.com/profiles/<PROFILE_ID>/genotype/upload/ --header "Authorization: Bearer ${ACCESS_TOKEN}" --header "Content-Type: application/json" curl -X PUT -H 'content-type: text/plain' --data-binary @file.csv "<UPLOAD_URL>"
This operation is used for starting synchronous processing of the previously uploaded genotype file. Note that genotype file processing will be initiated automatically. However, calling this endpoint will block the caller until file is processed and thus polling is avoided.
profile_id required | string <uuid> Profile identifier |
Authorization required | string Authorization header with access token. |
Success
Unauthorized or called before genetic data upload.
Not Found
Production server
curl --request POST --url https://api.lifenome.com/profiles/<PROFILE_ID>/genotype/upload/ --header "Authorization: Bearer ${TOKEN}"
Fetches list of traits configured for the authenticated user. Every trait object contains trait code and the additional metadata, including the pricing information. Note that this call lists all traits that are available to the API client, regardless of the fact that assessment for some traits might not be possible to compute for some Profiles. In order to get annotated list of traits linked to specific Profile, see this endpoint.
q | string This parameter is used for filtering the response trait set. If the string value is given, the response will contain only those traits whose trait codes or trait names contain the given string. |
Authorization required | string Authorization header with access token. |
List of traits
Unauthorized access
Unexpected error
Production server
curl --url "https://api.lifenome.com/traits/" \ --request GET \ --header "Authorization: Bearer ${ACCESS_TOKEN}" \ --header "Content-Type: application/json"