Skip to main content

Users

Users API gives you access to get basic information about other users present in the institute.

This endpoint protects the privacy of users. It is NOT possible to extra personal details of all the users from this endpoint. An admin however can extract the personal details using the Admin APIs.

Get Current authenticated user

This endpoint retrieves details of the authenticated user.

HTTP Request

GET /api/v2.2/me/

Fields

NameTypeDescription
idintThe user unique ID
batchesarrayList of batches to which this user belongs
urlstringURL to get details of the user
usernamestringUsername of the user
first_namestringFirst name of the user
last_namestringLast name of the user
display_namestringDisplay name of the user (Concatenates first_name & last_name if available. Falls back to username)
emailstringEmail of the user
photostringOriginal photo uploaded by the user
large_imagestringProfile photo transformed to 256x256 px
medium_imagestringProfile photo transformed to 128x128 px
small_imagestringProfile photo transformed to 48x48 px
x_small_imagestringProfile photo transformed to 32x32 px
mini_imagestringProfile photo transformed to 24x24 px
birth_datedatestringBirth date as provided by the user
genderstringGender as provided by the user. Can be "Male", "Female" or "Transgender"
address1stringAddress provided by the user
address2stringAddress provided by the user
citystringCity provided by the user
zipstringPincode provided by the user
statestringState provided by the user
phonestringPhone provided by the user
curl --request GET \
--url http://demo.testpress.in/api/v2.2/me/ \
--header 'authorization: JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRlc3RwcmVzcyIsInVzZXJfaWQiOjE3LCJlbWFpbCI6InRlc3RwcmVzcy5pbkBnbWFpbC5jb20iLCJleHAiOjE0NDc4MzMyMjl9.Ik_yi4lHbNbrRGhqmRpsW82Nls_O9lgXakk_syV-vSw' \
--header 'cache-control: no-cache'

Response

{
"id": 17,
"batches": [
"EEE",
"ECE",
"Unique UPSC Batch",
"POZITIVE ONLINE TEST SERIES",
"OHC 2.23",
"st std A",
"IBPS Morning Batch",
"UPSC Morning Batch",
"NEET Morning Batch",
"IBPS Online Batch",
"UPSC Evening Batch"
],
"url": "http://demo.testpress.in/api/v2.2/users/17/",
"username": "testpress",
"display_name": "Divya",
"first_name": "Divya",
"last_name": "",
"email": "testpress.in@gmail.com",
"photo": "https://s3-ap-southeast-1.amazonaws.com/media.testpress.in/i/9b69ab73fc924813871b2ef1e2ef00fa.jpeg",
"large_image": "https://s3-ap-southeast-1.amazonaws.com/media.testpress.in/i/493054067d1d4173a22d96b824d7f0c6.jpeg",
"medium_image": "https://s3-ap-southeast-1.amazonaws.com/media.testpress.in/i/8d96dab06a82487ab3149b771fe5d479.jpeg",
"small_image": "https://s3-ap-southeast-1.amazonaws.com/media.testpress.in/i/4023a394cd36472fa24db76e493192ce.jpeg",
"x_small_image": "https://s3-ap-southeast-1.amazonaws.com/media.testpress.in/i/796fa9a9727a42e4a7faa015b0388af3.jpeg",
"mini_image": "https://s3-ap-southeast-1.amazonaws.com/media.testpress.in/i/5f9215132af54acc8e72aed968582763.jpeg",
"birth_date": "1994-08-27",
"gender": "Female",
"address1": "Chennai",
"address2": "Chennai",
"city": "Chennai",
"zip": "600069",
"state": "Tamil Nadu",
"phone": "9043570576"
}

Get a single user

This endpoint retrieves publicly available details of a single user.

This endpoint protects the privacy of users. If the requested user is same as authenticated user, then the response will be same as /api/v2.2/me/. Otherwise, personal contact details will not be available.

HTTP Request

GET /api/v2.2/users/{id}

URL Parameters

ParameterDescription
idThe unique id of the user to retrieve

curl --request GET \
--url http://demo.testpress.in/api/v2.2/users/18/ \
--header 'authorization: JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRlc3RwcmVzcyIsInVzZXJfaWQiOjE3LCJlbWFpbCI6InRlc3RwcmVzcy5pbkBnbWFpbC5jb20iLCJleHAiOjE0NDc4MzMyMjl9.Ik_yi4lHbNbrRGhqmRpsW82Nls_O9lgXakk_syV-vSw' \
--header 'cache-control: no-cache'

Response


{
"id": 18,
"url": "http://demo.testpress.in/api/v2.2/users/18/",
"username": "Vinoth",
"display_name": "Vinoth Kumar",
"first_name": "Vinoth",
"last_name": "Kumar",
"photo": "",
"large_image": "",
"medium_image": "",
"small_image": "",
"x_small_image": "",
"mini_image": ""
}

Update current user

This endpoint will update a user profile details. The data to update should be posted in the request body in JSON format.

An authenticated user can update only his profile.

HTTP Request

PUT /api/v2.2/users/{id}

URL Parameters

ParameterDescription
idThe unique id of the user to retrieve
curl --request PUT \
--url http://demo.testpress.in/api/v2.2/users/17/ \
--header 'authorization: JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InRlc3RwcmVzcyIsInVzZXJfaWQiOjE3LCJlbWFpbCI6InRlc3RwcmVzcy5pbkBnbWFpbC5jb20iLCJleHAiOjE0NDc4MzMyMjl9.Ik_yi4lHbNbrRGhqmRpsW82Nls_O9lgXakk_syV-vSw' \
--header 'cache-control: no-cache' \
--header 'content-type: application/json' \
--data '{\n "first_name": "John",\n "last_name": "Appleseed"\n}'

Response

{
"first_name": "John",
"last_name": "Appleseed",
"email": "testpress.in@gmail.com",
"photo": "https://s3-ap-southeast-1.amazonaws.com/media.testpress.in/i/9b69ab73fc924813871b2ef1e2ef00fa.jpeg",
"large_image": "https://s3-ap-southeast-1.amazonaws.com/media.testpress.in/i/493054067d1d4173a22d96b824d7f0c6.jpeg",
"medium_image": "https://s3-ap-southeast-1.amazonaws.com/media.testpress.in/i/8d96dab06a82487ab3149b771fe5d479.jpeg",
"small_image": "https://s3-ap-southeast-1.amazonaws.com/media.testpress.in/i/4023a394cd36472fa24db76e493192ce.jpeg",
"x_small_image": "https://s3-ap-southeast-1.amazonaws.com/media.testpress.in/i/796fa9a9727a42e4a7faa015b0388af3.jpeg",
"mini_image": "https://s3-ap-southeast-1.amazonaws.com/media.testpress.in/i/5f9215132af54acc8e72aed968582763.jpeg",
"x_offset": 37,
"y_offset": 0,
"crop_height": 540,
"crop_width": 539,
"birth_date": "1994-08-27",
"gender": 2,
"address1": "Chennai",
"address2": "Chennai",
"city": "Chennai",
"zip": "600069",
"state_choices": 31,
"phone": "9043570576"
}