brainstem Endpoint¶
This reference builds on understanding of the BrainStem system. If you would like to get started using BrainStem, please see the following sections of the Reference documentation:
BrainStem GET commands are implemented with HTTP GET
calls, and SET commands are implemented with HTTP PUT
calls.
The entity and operation fields are mapped directly to BrainStem API calls, minus the get
and set
prefixes on the operations.
The parameters for the command are given as slash-separated path entries:
GET http://<IPADDRESS>:<PORT>/api/v1/brainstem/<SERIALNUM>/<ENTITY>/<INDEX>/<COMMAND>
GET http://<IPADDRESS>:<PORT>/api/v1/brainstem/<SERIALNUM>/<ENTITY>/<INDEX>/<COMMAND> {BODY}
Parameter |
Request Type |
Description |
---|---|---|
IPADDRESS |
GET, PUT |
IP Address of BrainD server hosting RESTful endpoints. |
PORT |
GET, PUT |
Port that BrainD server is listening for connections. Default is |
SERIALNUM |
GET, PUT |
Serial Number of the BrainStem device being accessed |
ENTITY |
GET, PUT |
BrainStem Entity, e.g. |
INDEX |
GET, PUT |
Entity Index |
COMMAND |
GET, PUT |
Operation to perform on entity without |
BODY |
PUT |
HTTP |
Note
The following BrainStem Entities are unsupported at this time: app
, i2c
, powerDelivery
Examples¶
GET Command¶
curl http://127.0.0.1:9005/api/v1/brainstem/3C43352C/system/0/inputvoltage
import requests
import json
response = requests.get('http://127.0.0.1:9005/api/v1/brainstem/3C43352C/system/0/inputvoltage')
json_data = response.json()
print(json.dumps(json_data, indent=4))
The output will be similar to the following:
1{
2 "timestamp": "2023-09-20T17:53:32.480Z",
3 "request": {
4 "endpointName": "/api/v1/brainstem/3C43352C/system/0/inputvoltage",
5 "parameters": {}
6 },
7 "response": {
8 "value": 22974139,
9 "rawValue": 22974139
10 }
11}
SET Command¶
curl -X PUT -d '{"value": "New Port Name"}' http://127.0.0.1:9005/api/v1/brainstem/3C43352C/port/2/name
import requests
import json
payload = {}
payload['value'] = 'New Port Name'
response = requests.put('http://127.0.0.1:9005/api/v1/brainstem/3C43352C/port/2/name', json=payload)
json_data = response.json()
print(json.dumps(json_data, indent=4))
The output will be similar to the following:
1{
2 "timestamp": "2023-09-20T17:55:15.134Z",
3 "request": {
4 "endpointName": "/api/v1/brainstem/3C43352C/port/2/name",
5 "parameters": {
6 "value": "New Port Name"
7 }
8 },
9 "response": {}
10}
GET Command with no response¶
curl http://127.0.0.1:9005/api/v1/brainstem/3C43352C/system/0/save
import requests
import json
response = requests.get('http://127.0.0.1:9005/api/v1/brainstem/3C43352C/system/0/save')
json_data = response.json()
print(json.dumps(json_data, indent=4))
The output will be similar to the following:
1{
2 "timestamp": "2023-09-20T17:57:05.245Z",
3 "request": {
4 "endpointName": "/api/v1/brainstem/3C43352C/system/0/save",
5 "parameters": {}
6 },
7 "response": {}
8}
JSON Schema for GET Response Object¶
The following table lists a JSON Schema for the response object.
Download the raw JSON Schema file for this response: get_brainstem_response.json
Object Fields of Get Brainstem Response¶
Name |
Type |
Mandatory |
Description |
---|---|---|---|
|
Yes |
||
|
string or number |
No |
If appropriate, a user-friendly formatted value. |
|
No |
v1-aErr¶
Name |
Value |
---|---|
Type |
string |
description |
Enumeration of all possible error results |
Enumerations |
|
v1-units¶
Name |
Value |
---|---|
Type |
string |
description |
Allowed and recognized units for a value. |
Enumerations |
|
v1-uint32¶
Name |
Value |
---|---|
Type |
integer |
description |
Unsigned 32-bit integer |
minimum |
0 |
maximum |
4294967295 |
v1-rawValue¶
Name |
Value |
---|---|
Type |
|
description |
Unformatted return value from the device. |
v1-error¶
Name |
Value |
---|---|
Type |
|
description |
Error containing an acroname error |
Name |
Type |
Mandatory |
Description |
---|---|---|---|
|
Yes |
Acroname error code |
|
|
string |
No |
A human-readable message to describe the context of the error. |
JSON Schema for PUT Request Object¶
The following table lists a JSON Schema for the response object.
Download the raw JSON Schema file for this response: put_brainstem_payload_v1.json
Object Fields of Put Brainstem Payload (v1)¶
Name |
Type |
Mandatory |
Description |
---|---|---|---|
|
integer or string or boolean or Array<integer or string> |
Yes |
Value to set on the Device. |
JSON Schema for PUT Response Object¶
The following table lists a JSON Schema for the response object.
Download the raw JSON Schema file for this response: put_brainstem_response.json
Object Fields of Put Brainstem Response¶
Name |
Type |
Mandatory |
Description |
---|---|---|---|
|
Yes |
Acroname error code |
|
|
string |
No |
A human-readable message to describe the context of the error. |
- or - |
|||
|
null |
No |
v1-aErr¶
Name |
Value |
---|---|
Type |
string |
description |
Enumeration of all possible error results |
Enumerations |
|
v1-error¶
Name |
Value |
---|---|
Type |
|
description |
Error containing an acroname error |
Name |
Type |
Mandatory |
Description |
---|---|---|---|
|
Yes |
Acroname error code |
|
|
string |
No |
A human-readable message to describe the context of the error. |