How to add an external reference to a sample using the JSON API
User requirements
I want to link a BioSamples accession with an external repositories or an external resource even if I’m not the owner of the sample
Requirements
You need a Webin submission account to proceed with this recipe. Please refer our AUTHENTICATION GUIDE for more information.
Steps
1. Get the JSON Web Token from Webin Authentication Service
Start by getting your JWT to use in your application. Please refer our authentication guide for this step.
2. Produce a BioSamples curation object in JSON format
In order to add an external reference in a sample without being the sample owner you need to use a BioSamples curation object. Since we just want to add link(s) and not change any existing link, what you need to do is add such link(s) to the externalReferencesPost field.
Let’s say, for example, you have a MGnify sample - e.g. ERS645361 - and you want to link it back to the corresponding
BioSamples sample entry SAMEA3219512.
{
"sample" : "SAMEA3219152",
"curation" : {
"attributesPre" : [],
"attributesPost" : [],
"externalReferencesPre" : [],
"externalReferencesPost" : [ {
"url" : "https://www.ebi.ac.uk/metagenomics/api/v1/samples/ERS645361"
} ]
}
}
We are now ready to submit the curation object to BioSamples
3. Submit the curation object using a POST request to the
You can now submit a POST request to BioSamples, using any service/app you prefer. Here we are going to do that using cURL
$ curl 'https://www.ebi.ac.uk/biosamples/samples/SAMEA3219152/curationlinks' -i -X POST -H 'Content-Type: application/json' -H 'Authorization: Bearer $TOKEN' -d '{
"sample" : "SAMEA3219152",
"curation" : {
"attributesPre" : [],
"attributesPost" : [],
"externalReferencesPre" : [],
"externalReferencesPost" : [ {
"url" : "https://www.ebi.ac.uk/metagenomics/api/v1/samples/ERS645361"
} ]
}
}'
If the response is successful (2xx code), you should be able to see the new link available on the sample page at https://www.ebi.ac.uk/biosamples/samples/SAMEA3219152
Templates
Here the template for the curation object to add a new relation to a BioSamples sample
New external reference curation template
{
"sample" : <accession-of-the-interested-sample>,
"curation" : {
"attributesPre" : [],
"attributesPost" : [],
"externalReferencesPre" : [],
"externalReferencesPost" : [ {
"url" : <the-url-to-the-external-reference-you-want-to-add>
} ]
}
}