Link Search Menu Expand Document

User 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
emailstring [must be unique]
first_namestring
last_namestring
groups_own_jsonlist of dictionaries with each group owned by the user. See structure below
websitestring [max length: 200]
google_scholarstring [max length: 200]
orcid_idstring [max length: 100]
atlas_preferencestring [max length: 7]

The following fields are only accessible for administrators:

FieldDescription
is_superuserboolean
is_project_adminboolean
is_group_adminboolean
is_taxonomies_adminboolean
is_resources_adminboolean
is_attributes_adminboolean
is_contact_form_email_receiverboolean

Each dictionary in the groups_own_json list contains the group’s id and name:

{'id': 8, 'name': 'test_group'}

List view

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

Use example (using Python API)

resp = client.load_model('user')

Response example

{'users': [
    {
        'id': 1,
        'email': 'petersen.peter@gmail.com',
        'first_name': 'Peter',
        'last_name': 'Petersen',
        'groups_own_json': [
            {'id': 9, 'name': 'my group1'},
            {'id': 13, 'name': 'Peters group'}
        ],
        'website': 'https://petersenlab.org/',
        'google_scholar': 'https://scholar.google.dk/citations?user=RywQhd8AAAAJ&hl',
        'orcid_id': 'https://orcid.org/0000-0002-2092-4791',
        'atlas_preference': 'AIA'
    },
    {
        'id': 16,
        'email': 'my@email.com',
        'first_name': 'New',
        'last_name': 'User',
        'groups_own_json': [],
        'website': '',
        'google_scholar': '',
        'orcid_id': '',
        'atlas_preference': 'AIA'
    }
]}

Add

Users can only be added through the website Register form.

Detail

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

Use example (using Python API)

resp = client.load_model('user', id='16')

Response example

{'user': {
    'id': 16,
    'email': 'my@email.com',
    'first_name': 'New',
    'last_name': 'User',
    'groups_own_json': [],
    'website': '',
    'google_scholar': '',
    'orcid_id': '',
    'atlas_preference': 'AIA'}
}

Change

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

Note: Users can only change their own profiles, unless they are administrators.

Use example (using Python API)

resp = client.save_model("user", id="16", data={"website": "www.someweb.com"})

Response example

{'user': {
    'id': 16,
    'email': 'my@email.com',
    'first_name': 'New',
    'last_name': 'User',
    'groups_own_json': [],
    'website': 'http://www.someweb.com',
    'google_scholar': '',
    'orcid_id': '',
    'atlas_preference': 'AIA'}
}

Delete

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

Note: only administrators can remove Users.

Use example (using Python API)

resp = client.delete_model("user", id="16")