Supplier API endpoint
The shared list of companies and labs that supply consumables, hardware and animals.
Table of contents
Endpoints
- Private portal:
https://www.brainstem.org/api/private/resources/supplier/(needs a token; one record: append<id>/) - Public portal:
https://www.brainstem.org/api/public/resources/supplier/(read-only, public projects, no token) - Response keys:
supplier(detail, create, update),suppliers(list) - Permissions: see the permissions page
- Uniqueness:
nameunique across BrainSTEM - Deleting: refused (400) while
consumable,consumableapproval,hardwaredevice,hardwaredeviceapproval,subjectrecords point to 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] |
name | string [required]; max 100 characters |
description | string; max 2000 characters |
website | string; max 200 characters |
comments | string |
List
- Allowed portals: private, public
- Request method: GET
- URL:
https://www.brainstem.org/api/private/resources/supplier/ - Responses:
200OK;401Not authenticated;403Not allowed
Use example (Python API tool)
resp = client.load('supplier', load_all=True)
records = resp['suppliers']
Use example (MATLAB API tool)
resp = client.load('supplier', 'load_all', true);
records = resp.suppliers;
Response example
{
"suppliers": [
{
"id": "<id>",
"name": "Supplier 1",
"description": "",
"website": "",
"comments": ""
}
],
"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/resources/supplier/ - 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('supplier', data={"name": "Supplier 1"})
record = resp.json()['supplier']
Use example (MATLAB API tool)
created = client.save(struct('name', 'Supplier 1'), 'supplier');
record = created.supplier;
Detail
- Allowed portals: private, public
- Request method: GET
- URL:
https://www.brainstem.org/api/private/resources/supplier/<id>/ - Responses:
200OK;403Not allowed;404Not found
Use example (Python API tool)
resp = client.load('supplier', id='<id>')
record = resp.json()['supplier']
Use example (MATLAB API tool)
out = client.load('supplier', 'id', '<id>');
record = out.supplier;
Response example
{
"supplier": {
"id": "<id>",
"name": "Supplier 1",
"description": "",
"website": "",
"comments": ""
}
}
Change
- Allowed portals: private
- Request method: PATCH
- URL:
https://www.brainstem.org/api/private/resources/supplier/<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('supplier', id='<id>', data={"name": "Supplier 1 (renamed)"})
Use example (MATLAB API tool)
client.save(struct('id', '<id>', 'name', 'Supplier 1 (renamed)'), 'supplier', 'method', 'patch');
Delete
- Allowed portals: private
- Request method: DELETE
- URL:
https://www.brainstem.org/api/private/resources/supplier/<id>/ - Responses:
204Deleted;400Still referenced by other records;403Not allowed;404Not found
Use example (Python API tool)
resp = client.delete('supplier', id='<id>')
Use example (MATLAB API tool)
client.delete('<id>', 'supplier');
Data model
The fields are described for the web forms on the Supplier data model page.