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
| Parameter | Type | Default | Description |
|---|---|---|---|
| limit | integer | 10 | Number of results per page |
| offset | integer | 0 | Number of results to skip |
| search | string | — | Search term for `username`, `email`, `first_name`, `last_name` |
| ordering | string | — | Field to order by (`id`, `username`, `email`, `created_at`, `updated_at`) |
| is_admin | boolean | — | Filter by admin status |
| is_staff | boolean | — | Filter by staff status |
| is_customer | boolean | — | Filter by customer status |
| has_email | boolean | — | Filter users who have an email address |
| has_avatar | boolean | — | Filter users who have an avatar image |
| has_phone | boolean | — | Filter users who have a mobile number |
| has_token | boolean | — | Filter users who have an authentication token |
| has_first_name | boolean | — | Filter users who have a first name |
| has_last_name | boolean | — | Filter users who have a last name |
| is_active | boolean | — | Filter by active status |
| is_online | boolean | — | Filter by online status |
| has_groups | boolean | — | Filter users who belong to any group |
| group_id | integer | — | Filter users who belong to a specific group ID |
| groups_in | integer list | — | Filter users in any of the specified group IDs (comma-separated) |
| last_login_date | string | — | Exact last login date (YYYY-MM-DD) |
| last_login_from | string | — | Start date for users who logged in after this date (YYYY-MM-DD) |
| last_login_to | string | — | End date for users who logged in before this date (YYYY-MM-DD) |
| id_min | integer | — | Minimum user ID to filter results |
| id_max | integer | — | Maximum user ID to filter results |
| created_date | string | — | Exact creation date (YYYY-MM-DD) |
| updated_date | string | — | Exact last update date (YYYY-MM-DD) |
| created_from | string | — | Start date for users created after this date (YYYY-MM-DD) |
| updated_from | string | — | Start date for users updated after this date (YYYY-MM-DD) |
| created_to | string | — | End date for users created before this date (YYYY-MM-DD) |
| updated_to | string | — | End date for users updated before this date (YYYY-MM-DD) |
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/', params={
6 'limit': 5,
7 'is_active': True,
8 'ordering': 'username'
9})
10print(response.json())1curl "http://www.example.com/api/users/?limit=5&is_active=true&ordering=username" -H "Authorization: Token XXXXXXXXXXXXXXXXXXXXXX"Status Codes
| Code | Description |
|---|---|
| 200 | Users retrieved successfully |
| 400 | Bad request — invalid parameters |
| 401 | Unauthorized — authentication required |
| 403 | Forbidden — insufficient permissions |
| 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": 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"
}
]
}
]