Skip to main content

mediaList

The mediaList query retrieves a paginated list of NFT media assets and associated data with comprehensive filtering, sorting, and pagination capabilities.

It returns a MediaList object containing an array of Media objects containing an NFT's media assets and associated data.

Schema Definition

mediaList(
first: Int = 10
skip: Int = 0
where: MediaFilter
orderBy: MediaOrderBy = CREATED_AT
orderDirection: Ordering = DESC
): MediaList!

Arguments

ArgumentTypeDescription
firstInt = 10 scalarMaximum number of media items to retrieve per page. Maximum value is 100.
skipInt = 0 scalarNumber of media items to bypass before assembling the page. Set to the first value from the previous page for offset pagination.
whereMediaFilter inputSpecifies subsets of media data to be retrieved.
orderByMediaOrderBy enumSets how the list of media items is ordered.
orderDirectionOrdering enumSets the direction in which the list of media items is ordered.

Return Type

MediaList object

Common Use Cases

  • Display media galleries for NFT collections by filtering on contract address or token IDs.
  • Generate optimized image displays using available thumbnail presets for faster page loads.
  • Track recently added or updated media using createdAtGte/createdAtLte and updatedAtGte/updatedAtLte filters.
  • Filter by media and file type using the mediaType and fileType parameters for type-specific galleries.

Example

Query

query CollectionGallery($first: Int!, $skip: Int!, $mediaType: MediaType) {
mediaList(
first: $first
skip: $skip
where: { mediaType: $mediaType }
orderBy: CREATED_AT
orderDirection: DESC
) {
numEntries
cursor
entries {
url
mediaType
fileType
thumbnails(preset: MEDIUM) {
url
width
height
}
createdAt
updatedAt
}
}
}

Variables

{
"first": 10,
"skip": 0,
"mediaType": "IMAGE"
}

Response

{
"data": {
"mediaList": {
"numEntries": 10,
"cursor": "10",
"entries": [
{
"url": "https://example.com/nft-media/1.png",
"mediaType": "IMAGE",
"fileType": "image/png",
"thumbnails": [
{
"url": "https://example.com/nft-media/thumbnails/1_medium.png",
"width": 300,
"height": 300
}
],
"createdAt": "2024-01-15T12:34:56Z",
"updatedAt": "2024-02-20T08:22:10Z"
}
// More media entries...
]
}
}
}

Implementation Notes

note
  • The default first value is 10 transactions. OneSource enforces a maximum first value of 100. Adjust based on your UI needs.
  • Use skip for offset-based pagination. To get the next page, use a skip value equal to the previous first value.
  • All range filters use Gte (greater than or equal to) and Lte (less than or equal to) suffixes for inclusive ranges.
  • Use orderBy and orderDirection to ensure consistent ordering when paginating through large result sets.
  • Use thumbnail presets (SMALL, MEDIUM, LARGE) for optimized image loading rather than full-size assets.
  • The fileType field contains the MIME type (e.g., image/png, video/mp4) for proper rendering.
  • Media URLs may point to IPFS, Arweave, or centralized storage. Implement fallback handling for reliability.