Skip to main content

List Customers

Retrieves a list of all customers with filtering, searching, and ordering capabilities.

HTTP Request

GET/api/customers

Authorization

Authorization

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

Query Parameters

ParameterTypeDefaultDescription
limitinteger10Number of results to return per page
offsetinteger0Number of results to skip before returning results
searchstringSearch term to filter results by id, username, mobile_number, email, first_name, last_name
orderingstringField to order results by (id, username, email, gender, last_login, created_at, updated_at)
has_emailbooleanFilter customers with/without email address
has_avatarbooleanFilter customers with/without avatar
has_phonebooleanFilter customers with/without phone number
has_tokenbooleanFilter customers with/without authentication token
has_first_namebooleanFilter customers with/without first name
has_last_namebooleanFilter customers with/without last name
is_activebooleanFilter by active status
is_profile_completedbooleanFilter by profile completion status
is_onlinebooleanFilter by online status
genderstringFilter by gender (male, female, etc.)
groups_instringFilter by multiple group IDs (comma-separated: 1,2,3)
group_idintegerFilter by specific group ID
last_login_datestringFilter by last login date (e.g., 2023-01-01)
last_login_fromstringFilter by last login date range start
last_login_tostringFilter by last login date range end
id_minintegerMinimum ID filter
id_maxintegerMaximum ID filter
created_datestringFilter by creation date (e.g., 2023-01-01)
updated_datestringFilter by last updated date (e.g., 2023-01-01)
created_fromstringFilter by creation date range start
created_tostringFilter by creation date range end
updated_fromstringFilter by last updated date range start
updated_tostringFilter by last updated date range end

Example Requests

1import requests
2
3# List all customers
4response = requests.get('http://www.example.com/api/customers', 
5  headers={'Authorization': 'Token <your_api_key>'}
6)
7print(response.json())
8
9# Search for customers with filters
10response = requests.get('http://www.example.com/api/customers', params={
11  'search': 'john',
12  'is_active': True,
13  'has_email': True,
14  'ordering': '-created_at',
15  'limit': 20
16}, headers={'Authorization': 'Token <your_api_key>'})
17print(response.json())
18
19# Filter by gender and online status
20response = requests.get('http://www.example.com/api/customers', params={
21  'gender': 'male',
22  'is_online': True,
23  'last_login_from': '2023-01-01'
24}, headers={'Authorization': 'Token <your_api_key>'})
25print(response.json())

Status Codes

CodeDescription
200Customers retrieved successfully
401Unauthorized — authentication required
403Forbidden — insufficient permissions
500Internal server error

Response Fields

FieldTypeDescription
idIntegerUnique ID of the customer
usernameStringCustomer's username
mobile_numberStringCustomer's phone number
emailStringCustomer's email address
avatarStringURL to customer's avatar image
first_nameStringCustomer's first name
last_nameStringCustomer's last name
full_nameStringCustomer's full name (computed field)
genderStringCustomer's gender (male/female)
is_activeBooleanWhether the customer account is active
is_profile_completedBooleanWhether the customer has completed their profile
last_loginString (ISO 8601)Timestamp of customer's last login
created_atString (ISO 8601)Timestamp when customer was created
updated_atString (ISO 8601)Timestamp when customer was last updated
is_onlineBooleanWhether the customer is currently online

Notes

  • Search works across multiple fields: id, username, mobile number, email, first name, and last name
  • Use boolean filters (has_email, has_avatar, etc.) to find customers with or without specific attributes
  • The is_online field indicates current activity status based on authentication token usage
  • Date range filtering supports both specific dates and range queries for creation and login timestamps