Retrieve User
Retrieve a specific user by its unique ID.
HTTP Request
GET/api/users/:id
Authorization
Authorization
- Required: Yes
- Permission: Staff or Admin
- Authentication: Token-based (Authorization: Token <your_api_key>)
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| id | Integer | Yes | Unique ID of the user to retrieve |
Example Requests
- 🐍 Python
- 🌐 Curl
1import requests
2
3api = requests.Session()
4api.headers.update({'Authorization': 'Token f4e75eab6e0f663a972d145478d6fc4b81762070'})
5response = api.get('http://www.example.com/api/users/78/')
6print(response.json())1curl "http://www.example.com/api/users/78" -H "Authorization: Token <your_api_key>"Status Codes
| Code | Description |
|---|---|
| 200 | Users retrieved successfully |
| 400 | Bad request — invalid parameters |
| 401 | Unauthorized — authentication required |
| 403 | Forbidden — insufficient permissions |
| 404 | Not found — user does not exist |
| 500 | Internal server error |
Response Fields
| Field | Type | Description |
|---|---|---|
| id | Integer | Unique ID of the user. |
| username | String | Username of the user. |
| mobile_number | String | Mobile phone number of the user. |
| String | Email address of the user. | |
| avatar | String | URL to the user's avatar image (null if none). |
| first_name | String | First name of the user. |
| last_name | String | Last name of the user. |
| full_name | String | Full name (first + last name). |
| gender | String | Gender of the user.(male/female) |
| is_staff | Boolean | Whether user has staff privileges. |
| is_admin | Boolean | Whether user has admin privileges. |
| is_active | Boolean | Whether user account is active. |
| last_login | String (ISO 8601) | Timestamp of last login (null for new users). |
| created_at | String (ISO 8601) | Timestamp when user was created. |
| updated_at | String (ISO 8601) | Timestamp when user was last updated. |
| is_online | Boolean | Whether user is currently online. |
| groups_data | Array[Object] | Array of group objects with detailed info. |
Group Data Structure
| Field | Type | Description |
|---|---|---|
| id | Integer | Unique ID of the group |
| name | String | Name of the group |
Example Response
{
"id": 42,
"username": "michael_chen",
"mobile_number": "+1-555-0156",
"email": "michael.chen@techcorp.com",
"first_name": "Michael",
"last_name": "Chen",
"gender": "male",
"is_staff": true,
"is_admin": false,
"is_active": true,
"last_login": null,
"avatar": "http://www.example.com/media/avatars/michael.jpg",
"full_name": "Michael Chen",
"created_at": "2023-01-01T12:00:00Z",
"updated_at": "2023-01-01T12:00:00Z",
"is_online": false,
"groups_data": [
{
"id": 1,
"name": "Admins"
},
{
"id": 3,
"name": "Editors"
}
]
}