Specimen API endpoint
One item of a specimen set, such as a single slice, section or well.
Table of contents
Endpoints
- Private portal:
https://www.brainstem.org/api/private/stem/specimen/(needs a token; one record: append<id>/) - Public portal:
https://www.brainstem.org/api/public/stem/specimen/(read-only, public projects, no token) - Response keys:
specimen(detail, create, update),specimens(list) - Permissions: inherited through
specimen_set→projects(fromproject) - Uniqueness:
specimen_set,local_identifierunique together - Schema payload:
typeselects a Specimen type; send its fields indetails.type_schema_versionis set by the server; do not send it.
Fields
[required] fields must be sent on create; [read-only] fields are returned but cannot be set. A nestable relation can be traversed in filters (filter{field.other}) and sideloaded with include[]=field.*; other relations can only be compared with ids (filter{field}=<id>). See the query syntax.
| Field | Description |
|---|---|
id | UUID string [read-only] |
specimen_set | specimenset id [required]; nestable |
local_identifier | string [required]; max 100 characters. Stable identifier for this specimen within its specimen set. |
type | one of the Specimen types [required] |
preparation_conditions | JSON object [read-only] |
status | one of planned, available, in_use, reserved, consumed, discarded, lost [required]. Current availability status of this specimen. |
quality | one of excellent, good, fair, poor, not_assessed. Quality assessment for this specimen. |
laterality | one of left, right, bilateral, not_applicable. Which side of the brain or body this specimen comes from. |
storage_location | string; max 100 characters; nullable. Current physical storage location, container, or slot. |
storage_conditions | string; max 100 characters; nullable. Current storage conditions, such as temperature and medium. |
termination_datetime | datetime; nullable. When this specimen was consumed, discarded, lost, or otherwise terminated. |
order | number; nullable. Ordering within the specimen set. |
source_specimen | specimen id; nullable; nestable. Specimen this specimen was derived from, if applicable. |
notes | string; nullable. Free-text notes about this specimen. |
details | JSON object |
type_schema_version | string [set by the server] |
created_at | datetime [read-only]; nullable |
updated_at | datetime [read-only] |
List
- Allowed portals: private, public
- Request method: GET
- URL:
https://www.brainstem.org/api/private/stem/specimen/ - Responses:
200OK;401Not authenticated;403Not allowed
Use example (Python API tool)
resp = client.load('specimen', load_all=True)
records = resp['specimens']
Use example (MATLAB API tool)
resp = client.load('specimen', 'load_all', true);
records = resp.specimens;
Response example
{
"specimens": [
{
"id": "<id>",
"specimen_set": "<specimenset-id>",
"local_identifier": "",
"type": "Slice",
"preparation_conditions": {},
"status": "available",
"quality": "excellent",
"laterality": "left",
"storage_location": "",
"storage_conditions": "",
"termination_datetime": "2024-03-22T10:30:00Z",
"order": 1,
"source_specimen": "<specimen-id>",
"notes": "",
"details": {
"...": "see the schema of the selected type"
},
"type_schema_version": "set by the server",
"created_at": "2024-03-22T10:30:00Z",
"updated_at": "2024-03-22T10:30:00Z"
}
],
"meta": {
"page": 1,
"per_page": 100,
"total_results": 1,
"total_pages": 1
}
}
Add
- Allowed portals: private
- Request method: POST
- URL:
https://www.brainstem.org/api/private/stem/specimen/ - Data: JSON object with at least the required fields
- Responses:
201Created;400Bad request (validation errors per field);403Not allowed
Use example (Python API tool)
resp = client.save('specimen', data={"specimen_set": "<specimenset-id>", "local_identifier": "<local_identifier>", "type": "CultureItem", "status": "available", "details": {"...": "see the schema of the selected type"}})
record = resp.json()['specimen']
Use example (MATLAB API tool)
created = client.save(struct('specimen_set', '<specimenset-id>', 'local_identifier', '<local_identifier>', 'type', 'CultureItem', 'status', 'available', 'details', struct()), 'specimen'); % struct() stands for the fields of the selected type
record = created.specimen;
Detail
- Allowed portals: private, public
- Request method: GET
- URL:
https://www.brainstem.org/api/private/stem/specimen/<id>/ - Responses:
200OK;403Not allowed;404Not found
Use example (Python API tool)
resp = client.load('specimen', id='<id>')
record = resp.json()['specimen']
Use example (MATLAB API tool)
out = client.load('specimen', 'id', '<id>');
record = out.specimen;
Response example
{
"specimen": {
"id": "<id>",
"specimen_set": "<specimenset-id>",
"local_identifier": "",
"type": "Slice",
"preparation_conditions": {},
"status": "available",
"quality": "excellent",
"laterality": "left",
"storage_location": "",
"storage_conditions": "",
"termination_datetime": "2024-03-22T10:30:00Z",
"order": 1,
"source_specimen": "<specimen-id>",
"notes": "",
"details": {
"...": "see the schema of the selected type"
},
"type_schema_version": "set by the server",
"created_at": "2024-03-22T10:30:00Z",
"updated_at": "2024-03-22T10:30:00Z"
}
}
Change
- Allowed portals: private
- Request method: PATCH
- URL:
https://www.brainstem.org/api/private/stem/specimen/<id>/ - Data: JSON object with the fields to change. Lists (
projects,tags, …) and JSON payloads (details, coordinates) are replaced as a whole: read the record first and send the full list or object. - Responses:
200OK;400Bad request;403Not allowed;404Not found
Use example (Python API tool)
resp = client.save('specimen', id='<id>', data={"local_identifier": "new value"})
Use example (MATLAB API tool)
client.save(struct('id', '<id>', 'local_identifier', 'new value'), 'specimen', 'method', 'patch');
Delete
- Allowed portals: private
- Request method: DELETE
- URL:
https://www.brainstem.org/api/private/stem/specimen/<id>/ - Responses:
204Deleted;400Still referenced by other records;403Not allowed;404Not found
Use example (Python API tool)
resp = client.delete('specimen', id='<id>')
Use example (MATLAB API tool)
client.delete('<id>', 'specimen');
Data model
The fields are described for the web forms on the Specimen data model page.