User API endpoint

A person with a BrainSTEM account, who receives roles directly or through groups.

Table of contents

  1. Endpoints
  2. Fields
  3. List
  4. Detail
  5. Change

Endpoints

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.

FieldDescription
idnumber [read-only]
emailstring [read-only]
first_namestring; max 150 characters
last_namestring; max 150 characters
groups_own_jsonstring [read-only]
profilestring [read-only]

List

  • Allowed portals: private, public
  • Request method: GET
  • URL: https://www.brainstem.org/api/private/users/user/
  • Responses: 200 OK; 401 Not authenticated; 403 Not allowed

Use example (Python API tool)

resp = client.load('user', load_all=True)
records = resp['users']

Use example (MATLAB API tool)

resp = client.load('user', 'load_all', true);
records = resp.users;

Response example

{
    "users": [
        {
            "id": 1,
            "email": "",
            "first_name": "",
            "last_name": "",
            "groups_own_json": "",
            "profile": ""
        }
    ],
    "meta": {
        "page": 1,
        "per_page": 100,
        "total_results": 1,
        "total_pages": 1
    }
}

Detail

  • Allowed portals: private, public
  • Request method: GET
  • URL: https://www.brainstem.org/api/private/users/user/<id>/
  • Responses: 200 OK; 403 Not allowed; 404 Not found

Use example (Python API tool)

resp = client.load('user', id='<id>')
record = resp.json()['user']

Use example (MATLAB API tool)

out = client.load('user', 'id', '<id>');
record = out.user;

Response example

{
    "user": {
        "id": 1,
        "email": "",
        "first_name": "",
        "last_name": "",
        "groups_own_json": "",
        "profile": ""
    }
}

Change

  • Allowed portals: private
  • Request method: PATCH
  • URL: https://www.brainstem.org/api/private/users/user/<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: 200 OK; 400 Bad request; 403 Not allowed; 404 Not found

Use example (Python API tool)

resp = client.save('user', id='<id>', data={"first_name": "new value"})

Use example (MATLAB API tool)

client.save(struct('id', '<id>', 'first_name', 'new value'), 'user', 'method', 'patch');