- We assume that you completed second tutorial Providing genetic files and that you have:
- Access token stored in
ACCESS_TOKEN
environment variable - Created Sample object and stored sample ID in
SAMPLE_ID
environment variable - Created Genotype with valid genetic file
- Access token stored in
List available Report Types
Available Reports that API client can generate depends on Tenant configuration.
API client can fetch list of available reports by invoking List
Reports
operation.
Reports are uniquely identified by code
property of returned Report object.
curl --request GET \
--url "https://se1.lifenome.com/platform-api/api/core-api/reports/" \
--header "Authorization: Bearer ${ACCESS_TOKEN}"
{
"count": 2,
"next": null,
"previous": null,
"results": [
{
"code": "nutrigenomics",
"name": "Nutrigenomics Report",
"description": "",
"input_schema": null
},
{
"code": "fitnome",
"name": "Fitnome",
"description": "",
"input_schema": null
}
]
}
In the example above, tenant can choose from two reports: nutrigenomics
and fitnome
.
The exact results will depend on Tenant configuration.
Lets assume that we want to create nutrigenomics
report and that we store report code in env variable:
REPORT_CODE="nutrigenomics"
Create a SampleReport object
SampleReport object is created by invoking Create Report
operation:
curl --request POST \
--url "https://se1.lifenome.com/platform-api/api/core-api/samples/${SAMPLE_ID}/reports/" \
--header "Content-Type: application/json" \
--header "Authorization: Bearer ${ACCESS_TOKEN}" \
--data "{\"report\": \"${REPORT_CODE}\", \"report_data\": null}"
Successful response will include a representation of created SampleReport. Returned representation of SampleReport includes report code and report data sent with create request and list of documents that are created for the SampleReport. For most Tenants the list of documents will include one Document. For some Tenants, with multiple represenatations of the same Report (e.g. localized content) the list will contain all defined representation.
{
"report": "nutrigenomics",
"report_data": null,
"documents": [
{
"url": "https://storage.googleapis.com/...nutrigenomics--en.pdf?X-Goog-Algorithm=GOOG4-RSA-SHA256...cdde",
"filename": "samples/b8ed73bd...21c/reports/nutrigenomics.pdf",
"bucket": "life...appspot.com",
"content_type": "application/pdf",
"language": "en",
"created_at": "2024-01-30T08:21:18.835160Z"
}
]
}
Created SampleReport is uniquely identified with returned report
(report_code
) attribute and the sample_id
and it can be retrieved by providing the same report_code
and sample_id
when invoking
Get Report
operation:
curl --request GET \
--url "https://se1.lifenome.com/platform-api/api/core-api/samples/${SAMPLE_ID}/reports/${REPORT_CODE}/" \
--header "Content-Type: application/json" \
--header "Authorization: Bearer ${ACCESS_TOKEN}"
The response should be exactly the same as when the sample was created:
{
"report": "nutrigenomics",
"report_data": null,
"documents": [
{
"url": "https://storage.googleapis.com/...nutrigenomics--en.pdf?X-Goog-Algorithm=GOOG4-RSA-SHA256...cdde",
"filename": "samples/b8ed73bd...21c/reports/nutrigenomics.pdf",
"bucket": "life...appspot.com",
"content_type": "application/pdf",
"language": "en",
"created_at": "2024-01-30T08:21:18.835160Z"
}
]
}
Download PDF document for given report
User can download PDF representation of generated documents from url
attribute
of SampleReport JSON representation.
- Fetch SampleReport details with temporarily signed upload URL
- Download PDF file from temporarily signed URL
curl --request GET \
--url "https://se1.lifenome.com/platform-api/api/core-api/samples/${SAMPLE_ID}/reports/${REPORT_CODE}/" \
--header "Content-Type: application/json" \
--header "Authorization: Bearer ${ACCESS_TOKEN}"
The response should be exactly the same as when the sample was created:
{
"report": "nutrigenomics",
"report_data": null,
"documents": [
{
"url": "https://storage.googleapis.com/...nutrigenomics--en.pdf?X-Goog-Algorithm=GOOG4-RSA-SHA256...cdde",
"filename": "samples/b8ed73bd...21c/reports/nutrigenomics.pdf",
"bucket": "life...appspot.com",
"content_type": "application/pdf",
"language": "en",
"created_at": "2024-01-30T08:21:18.835160Z"
}
]
}
Successful response will contain temporarily signed download URL
(DOWNLOAD_URL
) in the url
field, which can then be used in the second
step, where PDF file is actually downloaded:
curl --request GET \
--url ${DOWNLOAD_URL} \
--output nutrigenomics.pdf
This command will download PDF report and store it in nutrinome.pdf
file.