Collection API endpoint

Table of contents

  1. Fields
  2. List view
  3. Add
  4. Detail
  5. Change
  6. Delete

Fields

FieldDescription
idUUID identificator formatted as a string
namestring [required] [max length: 100]
descriptionstring
projectrelated project ID formatted as a string [required]
sessionslist of related sessions IDs formatted as strings
tagslist of strings

List view

  • Allowed portals: public, private
  • Request method: GET
  • URL: https://www.brainstem.org/api/private/stem/collection
  • Data: None
  • Responses: 200 OK; 403 Not allowed; 404 Not found

Use example (using Python API)

resp = client.load_model('collection')

Response example

{'collections': [
        {
            'id': '00000000-0000-0000-0000-000000000000',
            'name': 'newcollection1',
            'project': '00000000-0000-0000-0000-000000000000',
            'sessions': [
                            '00000000-0000-0000-0000-000000000000',
                            '00000000-0000-0000-0000-000000000000'
                        ]
        },
        {
            'id': '00000000-0000-0000-0000-000000000000',
            'name': 'collection2',
            'project': '00000000-0000-0000-0000-000000000000',
            'sessions': [
                            '00000000-0000-0000-0000-000000000000',
                            '00000000-0000-0000-0000-000000000000'
                        ]
        }
    ]
}

Public list responses also include a meta object (pagination/filter metadata).

Add

  • Allowed portals: private
  • Request method: POST
  • URL: https://www.brainstem.org/api/private/stem/collection
  • Data: JSON dictionary containing at least the required fields.
  • Responses: 201 OK; 400 Bad request; 403 Not allowed; 404 Not found

Use example (using Python API)

resp = client.save_model("collection", data={"name": "NewRestCollection", "project": "00000000-0000-0000-0000-000000000000", "sessions": ["00000000-0000-0000-0000-000000000000"]})

Response example

{'collection': {
    'id': '00000000-0000-0000-0000-000000000000',
    'name': 'NewRestCollection',
    'project': '00000000-0000-0000-0000-000000000000',
    'sessions': ['00000000-0000-0000-0000-000000000000']
    }
}

Detail

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

Use example (using Python API)

resp = client.load_model('collection', id='00000000-0000-0000-0000-000000000000')

Response example

{'collection': {
    'id': '00000000-0000-0000-0000-000000000000',
    'name': 'NewRestCollection',
    'project': '00000000-0000-0000-0000-000000000000',
    'sessions': ['00000000-0000-0000-0000-000000000000']
    }
}

Change

  • Allowed portals: private
  • Request method: PATCH
  • URL: https://www.brainstem.org/api/private/stem/collection/<id>/
  • Data: dictionary containing the fields to be updated
  • Responses: 200 OK; 400 Bad request; 403 Not allowed; 404 Not found

Use example (using Python API)

resp = client.save_model("collection", id="00000000-0000-0000-0000-000000000000", data={"name": "new name"})

Response example

{'collection': {
    'id': '00000000-0000-0000-0000-000000000000',
    'name': 'new name',
    'project': '00000000-0000-0000-0000-000000000000',
    'sessions': ['00000000-0000-0000-0000-000000000000']
    }
}

Delete

  • Allowed portals: private
  • Request method: DELETE
  • URL: https://www.brainstem.org/api/private/stem/collection/<id>/
  • Data: None
  • Responses: 204 OK; 403 Not allowed; 404 Not found

Use example (using Python API)

resp = client.delete_model("collection", id="00000000-0000-0000-0000-000000000000")