Skip to main content

List media files

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

HTTP Request

GET/api/media/files

Authorization

Authorization

  • Required: Yes
  • Permission: Staff with FilePermission or Admin
  • Permission Code: 3802
  • 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 lookup results by id, name
orderingstring-created_atOrder results by (id, type, name, size, width, height, mode, created_at, updated_at, user__id, user__username, user__first_name, user__last_name, user__last_login)
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
typestringFilter by file type (pdf, text, image, document, compressed, spreadsheet, presentation, video, audio)
user_idintegerFilter by specific user ID who uploaded the file
size_minintegerMinimum file size in bytes
size_maxintegerMaximum file size in bytes
width_minintegerMinimum image width in pixels (applies to images only)
width_maxintegerMaximum image width in pixels (applies to images only)
height_minintegerMinimum image height in pixels (applies to images only)
height_maxintegerMaximum image height in pixels (applies to images only)

Example Requests

1import requests
2
3# List all files
4response = requests.get('http://www.example.com/api/media/files', 
5  headers={'Authorization': 'Token <your_api_key>'}
6)
7print(response.json())
8
9# Search for files with filters
10response = requests.get('http://www.example.com/api/media/files', params={
11  'search': 'profile',
12  'type': 'image',
13  'size_min': 1024,
14  'ordering': '-created_at',
15  'limit': 20
16}, headers={'Authorization': 'Token <your_api_key>'})
17print(response.json())
18
19# Filter by user and image dimensions
20response = requests.get('http://www.example.com/api/media/files', params={
21  'user_id': 123,
22  'width_min': 800,
23  'height_min': 600,
24  'created_from': '2023-01-01'
25}, headers={'Authorization': 'Token <your_api_key>'})
26print(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 MediaFile objects

MediaFile Object Structure

FieldTypeDescription
idIntegerUnique ID of the file
typeStringFile type(Choices)
userObjectUser who uploaded the file with id, username, full_name (nullable)
fStringFile URL/path
nameStringOriginal filename (nullable)
descriptionStringFile description (nullable)
sizeIntegerFile size in bytes (nullable)
human_readable_sizeStringHuman-readable file size (e.g., "2.5 MB", nullable)
widthIntegerImage width in pixels (images only, nullable)
heightIntegerImage height in pixels (images only, nullable)
modeStringImage color mode (images only, nullable)
created_atString (ISO 8601)Timestamp when file was uploaded
updated_atString (ISO 8601)Timestamp when file was last updated
thumbnailsList of thumbnail objectsthumbnails of the image files

Thumbnail Data Structure

FieldTypeDescription
idIntegerUnique ID of the thumbnail (unique)
fStringURL to access the thumbnail file
sizeIntegerFile size in bytes (nullable)

*** User Object Structure

FieldTypeDescription
idIntegerUnique id of the uploader user
usernameStringUsername of the user
full_nameStringFull name of the user (computed value from first and last name)

Example Response

{
"count": 9,
"next": "http://127.0.0.1:8000/api/media/files?limit=3&offset=3",
"previous": null,
"results": [
{
"id": 9,
"type": "text",
"user": {
"id": 14,
"username": "Shakira_Anderson47",
"full_name": "بهرام نوروزی"
},
"f": "http://127.0.0.1:8000/media/core_media/2025/12/22/askari.txt",
"name": "textfile",
"description": "",
"size": 1408,
"human_readable_size": "1.38 KB",
"created_at": "2025-12-22T17:29:34.807896Z",
"updated_at": "2025-12-22T17:29:34.807905Z"
},
{
"id": 8,
"type": "image",
"user": {
"id": 1,
"username": "BehroozGhorbani",
"full_name": "بهروز قربانی"
},
"f": "http://127.0.0.1:8000/media/core_media/2025/12/20/Fantasticheskie_kartinki_dlja_monitora_68_63.jpg",
"name": "پیک موتوری",
"description": "",
"size": 808754,
"human_readable_size": "789.80 KB",
"width": 1920,
"height": 1080,
"mode": "RGB",
"created_at": "2025-12-20T16:27:27.975156Z",
"updated_at": "2025-12-20T16:27:27.975163Z",
"thumbnails": [
{
"id": 313,
"f": "http://127.0.0.1:8000/media/core_media/2026/02/02/thumbnails/test2_ecH0zVV_thumbnail_64x64.jpg",
"size": 64
},
{
"id": 314,
"f": "http://127.0.0.1:8000/media/core_media/2026/02/02/thumbnails/test2_ecH0zVV_thumbnail_128x128.jpg",
"size": 128
},
{
"id": 315,
"f": "http://127.0.0.1:8000/media/core_media/2026/02/02/thumbnails/test2_ecH0zVV_thumbnail_512x512.jpg",
"size": 512
},
{
"id": 316,
"f": "http://127.0.0.1:8000/media/core_media/2026/02/02/thumbnails/test2_ecH0zVV_thumbnail_1080x1080.jpg",
"size": 1080
}
]
},
{
"id": 7,
"type": "image",
"user": {
"id": 1,
"username": "BehroozGhorbani",
"full_name": "بهروز قربانی"
},
"f": "http://127.0.0.1:8000/media/core_media/2025/12/02/computer.png",
"name": "computers",
"description": "the computers and all",
"size": 3284,
"human_readable_size": "3.21 KB",
"width": 235,
"height": 215,
"mode": "P",
"created_at": "2025-12-02T14:31:15.787793Z",
"updated_at": "2025-12-02T14:31:15.787799Z",
"thumbnails": [
{
"id": 213,
"f": "http://127.0.0.1:8000/media/core_media/2026/02/02/thumbnails/test2_ecH0zVV_thumbnail_64x64.jpg",
"size": 64
},
{
"id": 214,
"f": "http://127.0.0.1:8000/media/core_media/2026/02/02/thumbnails/test2_ecH0zVV_thumbnail_128x128.jpg",
"size": 128
},
{
"id": 215,
"f": "http://127.0.0.1:8000/media/core_media/2026/02/02/thumbnails/test2_ecH0zVV_thumbnail_512x512.jpg",
"size": 512
},
{
"id": 216,
"f": "http://127.0.0.1:8000/media/core_media/2026/02/02/thumbnails/test2_ecH0zVV_thumbnail_1080x1080.jpg",
"size": 1080
}
]
}
]
}

Notes

    • width, height, and mode fields are only included in the response for image files
    • File type is automatically detected and set upon upload based on content and MIME type
    • Search works on file ID and name fields
    • Size filters work in bytes - use appropriate values for filtering by file size
    • Image dimension filters (width_min, width_max, height_min, height_max) only apply to image files
    • User object includes basic information about who uploaded the file
    • Thubnails are only generated for image-type files