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
$itemRef: ID
$page: Int
$limit: Int
) {
media(
mediaRef: $mediaRef
id: $id
ids: $ids
extensions: $extensions
folder: $folder
term: $term
itemRef: $itemRef
page: $page
limit: $limit
) {
media {
_id
id
title
alt
caption
ext
mime
size
width
height
url
key
folder
itemRef
}
pagination {
limit
count
page
pages
hasMore
capped
}
folders
extensions
}
}

Variables​

{
"mediaRef": "48236deec69399d43ea8343f",
"id": 2664015870641,
"ids": [
42
],
"extensions": [
"extensions"
],
"folder": "folder",
"term": "term",
"itemRef": "6abd91881ea83176b9774add",
"page": 1,
"limit": 20
}

Response​

{
"media": {
"media": [
{
"_id": "f60ebbdd18f58d7220a3e783",
"id": 7616154002982,
"title": "example",
"alt": "example",
"caption": "example",
"ext": "example",
"mime": "example",
"size": 42,
"width": 42,
"height": 42,
"url": "https://example.com",
"key": "example",
"folder": "example",
"itemRef": "95c25acb4138fc1248168f9f"
}
],
"pagination": {
"limit": 20,
"count": 10,
"page": 1,
"pages": 1,
"hasMore": true,
"capped": true
},
"folders": [
"example"
],
"extensions": [
"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.
itemRefIDReference ID of an item: returns that item's downloadable files instead of the media library, which never lists them.
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