Skip to main content

Get All Users

Retrieve a list of users with optional filtering, searching, and pagination.

HTTP Request

GET/api/users

Authorization

Authorization

  • Required: Yes
  • Permission: Staff or Admin
  • Authentication: Token-based (Authorization: Token <your_api_key>)

Query Parameters

ParameterTypeDefaultDescription
limitinteger10Number of results per page
offsetinteger0Number of results to skip
searchstringSearch term for `username`, `email`, `first_name`, `last_name`
orderingstringField to order by (`id`, `username`, `email`, `created_at`, `updated_at`)
is_adminbooleanFilter by admin status
is_staffbooleanFilter by staff status
is_customerbooleanFilter by customer status
has_emailbooleanFilter users who have an email address
has_avatarbooleanFilter users who have an avatar image
has_phonebooleanFilter users who have a mobile number
has_tokenbooleanFilter users who have an authentication token
has_first_namebooleanFilter users who have a first name
has_last_namebooleanFilter users who have a last name
is_activebooleanFilter by active status
is_onlinebooleanFilter by online status
has_groupsbooleanFilter users who belong to any group
group_idintegerFilter users who belong to a specific group ID
groups_ininteger listFilter users in any of the specified group IDs (comma-separated)
last_login_datestringExact last login date (YYYY-MM-DD)
last_login_fromstringStart date for users who logged in after this date (YYYY-MM-DD)
last_login_tostringEnd date for users who logged in before this date (YYYY-MM-DD)
id_minintegerMinimum user ID to filter results
id_maxintegerMaximum user ID to filter results
created_datestringExact creation date (YYYY-MM-DD)
updated_datestringExact last update date (YYYY-MM-DD)
created_fromstringStart date for users created after this date (YYYY-MM-DD)
updated_fromstringStart date for users updated after this date (YYYY-MM-DD)
created_tostringEnd date for users created before this date (YYYY-MM-DD)
updated_tostringEnd date for users updated before this date (YYYY-MM-DD)

Example Requests

1import requests
2
3api = requests.Session()
4api.headers.update({'Authorization': 'Token f4e75eab6e0f663a972d145478d6fc4b81762070'})
5response = api.get('http://www.example.com/api/users/', params={
6  'limit': 5,
7  'is_active': True,
8  'ordering': 'username'
9})
10print(response.json())

Status Codes

CodeDescription
200Users retrieved successfully
400Bad request — invalid parameters
401Unauthorized — authentication required
403Forbidden — insufficient permissions
500Internal server error

Response Fields

FieldTypeDescription
idIntegerUnique ID of the user.
usernameStringUsername of the user.
mobile_numberStringMobile phone number of the user.
emailStringEmail address of the user.
avatarStringURL to the user's avatar image (null if none).
first_nameStringFirst name of the user.
last_nameStringLast name of the user.
full_nameStringFull name (first + last name).
genderStringGender of the user.(male/female)
is_staffBooleanWhether user has staff privileges.
is_adminBooleanWhether user has admin privileges.
is_activeBooleanWhether user account is active.
last_loginString (ISO 8601)Timestamp of last login (null for new users).
created_atString (ISO 8601)Timestamp when user was created.
updated_atString (ISO 8601)Timestamp when user was last updated.
is_onlineBooleanWhether user is currently online.
groups_dataArray[Object]Array of group objects with detailed info.

Group Data Structure

FieldTypeDescription
idIntegerUnique ID of the group
nameStringName of the group

Example Response

[
{
"id": 78,
"username": "michael_chen",
"mobile_number": "+1-555-0156",
"email": "michael.chen@techcorp.com",
"avatar": "http://www.example.com/media/avatars/michael_avatar.jpg",
"first_name": "Michael",
"last_name": "Chen",
"full_name": "Michael Chen",
"gender": "male",
"avatar": "http://www.example.com/media/avatars/michael.jpg",
"full_name": "Michael Chen",
"is_staff": true,
"is_admin": false,
"is_active": true,
"last_login": "2025-08-06T16:45:20.123456Z",
"created_at": "2025-08-06T17:30:45.789012Z",
"updated_at": "2025-08-06T17:35:12.456789Z",
"is_online": true,
"groups_data": [
{
"id": 1,
"name": "Engineering Team"
},
{
"id": 3,
"name": "Product Management"
}
]
},
{
"id": 92,
"username": "sarah_williams",
"mobile_number": "+1-555-0189",
"email": "sarah.williams@techcorp.com",
"avatar": null,
"first_name": "Sarah",
"last_name": "Williams",
"full_name": "Sarah Williams",
"gender": "female",
"avatar": null,
"full_name": "Sarah Williams",
"is_staff": false,
"is_admin": false,
"is_active": true,
"last_login": "2025-08-06T14:22:15.987654Z",
"created_at": "2025-08-06T10:15:30.123456Z",
"updated_at": "2025-08-06T14:22:15.987654Z",
"is_online": false,
"groups_data": [
{
"id": 2,
"name": "Marketing Team"
},
{
"id": 4,
"name": "Customer Success"
}
]
}
]