Skip to main content

media Query

Description​

Retrieves a paginated list of media items with optional filtering by reference ID, numeric ID, file extensions, or multiple IDs. Results are sorted by creation date. You can request a specific page size, and it will be used if it does not exceed the server-enforced maximum. If your requested size exceeds the maximum, the server will enforce the maximum limit.

query media(
$mediaRef: ID
$id: Int
$ids: [Int]
$extensions: [String]
$folder: String
$term: String
$page: Int
$limit: Int
) {
media(
mediaRef: $mediaRef
id: $id
ids: $ids
extensions: $extensions
folder: $folder
term: $term
page: $page
limit: $limit
) {
media {
_id
id
title
alt
caption
ext
mime
size
width
height
url
key
folder
}
pagination {
limit
count
page
pages
hasMore
}
folders
}
}

Variables​

{
"mediaRef": "de0c3b374aea57a7ed1b4a99",
"id": 8354215420549,
"ids": [
42
],
"extensions": [
"extensions"
],
"folder": "folder",
"term": "term",
"page": 1,
"limit": 20
}

Response​

{
"media": {
"media": [
{
"_id": "0838e00d4c8bb26f36566b40",
"id": 2248039840252,
"title": "example",
"alt": "example",
"caption": "example",
"ext": "example",
"mime": "example",
"size": 42,
"width": 42,
"height": 42,
"url": "https://example.com",
"key": "example",
"folder": "example"
}
],
"pagination": {
"limit": 20,
"count": 10,
"page": 1,
"pages": 1,
"hasMore": true
},
"folders": [
"example"
]
}
}

Arguments​

NameTypeDescription
mediaRefIDMedia reference ID (ObjectId) to retrieve a specific media item.
idIntNumeric media ID to retrieve a specific media item.
ids[Int]List of numeric media IDs to retrieve multiple media items.
extensions[String]List of file extensions to filter by (e.g., ["jpg", "png", "pdf"]).
folderStringFolder name to filter by. Pass an empty string to return only media not in any folder.
termStringCase-insensitive search term matched against the media title.
pageIntThe requested page number. Defaults to 1 if not specified.
limitIntNumber of media items per page. You can request a specific page size, and it will be used if it does not exceed the server-enforced maximum. If your requested size exceeds the maximum, the server will enforce the maximum limit.

Returns​

MediaConnection