Skip to main content

List Request Logs

Retrieves a list of all request logs with filtering, searching, and ordering capabilities. This endpoint provides comprehensive logging information for API requests including user data, device information, response details, and performance metrics.

HTTP Request​

GET/api/metrics/request_logs

Authorization​

Authorization

  • Required: Yes
  • Permission: Staff with RequestLogPermission or Admin
  • Permission Code: 3601
  • Authentication: Token authentication

Query Parameters​

ParameterTypeDefaultDescription
limitinteger10Number of results to return per page
offsetinteger0Number of results to skip before returning results
searchstring—Search in user__id, user__username, user__mobile_number, ip, device, os, browser, endpoint, or exception_type
orderingstring-created_atOrder results by (id, user, ip, device, device_type, os, browser, endpoint, method, status_code, exception_type, duration, created_at)
userinteger—Filter by specific user ID (use 0 for anonymous users)
ipstring—Filter by IP address
devicestring—Filter by device name
device_typestring—Filter by device type (pc, mobile, tablet)
is_botboolean—Filter by bot detection status
osstring—Filter by operating system
browserstring—Filter by browser name
schemestring—Filter by request scheme (http, https)
endpointstring—Filter by API endpoint
methodstring—Filter by HTTP method
status_codeinteger—Filter by HTTP status code
exception_typestring—Filter by exception type
duration_fromnumber—Minimum request duration filter (in seconds)
duration_tonumber—Maximum request duration filter (in seconds)
has_ipboolean—Filter logs with/without IP address
has_deviceboolean—Filter logs with/without device information
has_device_typeboolean—Filter logs with/without device type
has_osboolean—Filter logs with/without OS information
has_browserboolean—Filter logs with/without browser information
has_schemeboolean—Filter logs with/without scheme information
has_endpointboolean—Filter logs with/without endpoint information
has_methodboolean—Filter logs with/without HTTP method
has_query_paramsboolean—Filter logs with/without query parameters
has_bodyboolean—Filter logs with/without request body
has_status_codeboolean—Filter logs with/without status code
has_responseboolean—Filter logs with/without response data
has_request_headersboolean—Filter logs with/without request headers
has_response_headersboolean—Filter logs with/without response headers
has_exception_typeboolean—Filter logs with/without exception type
has_exception_messageboolean—Filter logs with/without exception message
has_exception_tracebackboolean—Filter logs with/without exception traceback
id_mininteger—Minimum ID filter
id_maxinteger—Maximum ID filter
created_datestring—Filter by creation date (e.g., 2023-01-01)
updated_datestring—Filter by last updated date (e.g., 2023-01-01)
created_fromstring—Filter by creation date range start
created_tostring—Filter by creation date range end
updated_fromstring—Filter by last updated date range start
updated_tostring—Filter by last updated date range end

Example Requests​

1import requests
2
3# Basic request logs listing with authentication
4response = requests.get('http://www.example.com/api/metrics/request_logs', 
5  params={
6      'limit': 50,
7      'ordering': '-duration',
8      'search': 'smartphone',
9      'user': 123,
10      'device_type': 'mobile',
11      'status_code': 200,
12      'duration_from': 1.0,
13      'has_exception_type': False
14  },
15  headers={'Authorization': 'Token <your_api_key>'}
16)
17print(response.json())
18
19# Filter for error logs only
20response = requests.get('http://www.example.com/api/metrics/request_logs', 
21  params={
22      'limit': 20,
23      'ordering': '-created_at',
24      'has_exception_type': True,
25      'created_from': '2023-01-01T00:00:00Z'
26  },
27  headers={'Authorization': 'Token <your_api_key>'}
28)
29print(response.json())

Response Fields​

FieldTypeDescription
countIntegerTotal number of categories
nextStringURL for the next page of results
previousStringURL for the previous page of results
resultsArray[Object]Array of RequestLog objects

RequestLog Object Data Structure

FieldTypeDescription
idIntegerUnique ID of the request log
userObjectUser information (id, username, full_name) or null for anonymous
ipStringIP address of the request(nullable)
deviceStringDevice name/model (nullable)
device_typeStringType of device (pc, mobile, tablet) (nullable)
is_botBooleanWhether the request was made by a bot (nullable, default=false)
osStringOperating system information (nullable)
browserStringBrowser information (nullable)
schemeStringRequest scheme (http, https) (nullable)
endpointStringAPI endpoint that was called (nullable)
methodStringHTTP method used (nullable)
status_codeIntegerHTTP response status code (nullable)
exception_typeStringType of exception (if any occurred) (nullable)
started_atString (ISO 8601)Timestamp when request started (nullable)
finished_atString (ISO 8601)Timestamp when request finished (nullable)
durationDecimalRequest duration in seconds (nullable)
created_atString (ISO 8601)Timestamp when log entry was created
updated_atString (ISO 8601)Timestamp when log entry was last updated

Example Response​

{
"count": 2634,
"next": "http://127.0.0.1:8000/api/metrics/request_logs?limit=2&offset=2",
"previous": null,
"results": [
{
"id": 2663,
"user": {
"id": 1,
"username": "BehroozGhorbani",
"full_name": "بهروز قربانی"
},
"ip": "127.0.0.1",
"device": "Other",
"device_type": null,
"is_bot": false,
"os": "Other",
"browser": "PostmanRuntime",
"scheme": "http",
"endpoint": "/api/settings/metrics",
"method": "PATCH",
"status_code": 200,
"exception_type": null,
"started_at": "2025-12-22T16:23:55.998509Z",
"finished_at": "2025-12-22T16:23:56.033603Z",
"duration": 0.035094,
"created_at": "2025-12-22T16:23:56.033771Z",
"updated_at": "2025-12-22T16:23:56.033774Z"
},
{
"id": 2662,
"user": {
"id": 1,
"username": "BehroozGhorbani",
"full_name": "بهروز قربانی"
},
"ip": "127.0.0.1",
"device": "Other",
"device_type": null,
"is_bot": false,
"os": "Other",
"browser": "PostmanRuntime",
"scheme": "http",
"endpoint": "/api/settings/metrics",
"method": "PATCH",
"status_code": 400,
"exception_type": null,
"started_at": "2025-12-22T16:23:46.341031Z",
"finished_at": "2025-12-22T16:23:46.364862Z",
"duration": 0.023831,
"created_at": "2025-12-22T16:23:46.365077Z",
"updated_at": "2025-12-22T16:23:46.365081Z"
}
]
}

Notes​

    • The duration field is automatically calculated from started_at and finished_at timestamps
    • Anonymous requests are stored with user: null and can be filtered using user=0 parameter
    • Use boolean has_* filters to find logs with or without specific data fields
    • Search works across multiple fields including user information, device details, and endpoints
    • Performance monitoring: use duration_from and duration_to to identify slow requests
    • Error tracking: use has_exception_type=true to filter for failed requests
    • Bot detection: use is_bot filter to separate bot traffic from human users