Skip to main content

media

The media query retrieves a specific NFT's media asset and associated data by its contract address and token IDs.

It returns a Media object containing all media metadata, file type information, thumbnails, and associated metadata references.

Schema Definition

media(
contract: String!
tokenId: UInt256!
): Media

Arguments

ArgumentTypeDescription
contractString! non-null scalarThe contract address of the NFT.
tokenIdUInt256! non-null scalarThe token ID of the NFT.

Return Type

Media object

Common Use Cases

  • Display NFT images and media assets in wallets, marketplaces, or galleries.
  • Access optimized thumbnail variants for responsive image loading and performance.
  • Retrieve media file types and MIME information for proper rendering.
  • Build NFT detail pages with complete media asset information.

Example

Query

Retrieve Media Asset for NFT Display

query GetNFTMedia($contract: String!, $tokenId: UInt256!) {
media(contract: $contract, tokenId: $tokenId) {
contract
tokenId
fileType
mediaType
thumbnails {
preset
uri
width
height
}
metadata {
uri
name
image
}
createdAt
updatedAt
}
}

Variables

{
"contract": "0x60e4d786628fea6478f785a6d7e704777c86a7c6",
"tokenId": "12345"
}

Response

{
"data": {
"media": {
"contract": "0x60e4d786628fea6478f785a6d7e704777c86a7c6",
"tokenId": "12345",
"fileType": "image/png",
"mediaType": "IMAGE",
"thumbnails": [
{
"preset": "SMALL",
"uri": "https://cdn.example.com/thumbnails/small/...",
"width": 256,
"height": 256
},
{
"preset": "MEDIUM",
"uri": "https://cdn.example.com/thumbnails/medium/...",
"width": 512,
"height": 512
},
{
"preset": "LARGE",
"uri": "https://cdn.example.com/thumbnails/large/...",
"width": 1024,
"height": 1024
}
],
"metadata": {
"uri": "ipfs://QmXxxx...",
"name": "Cool NFT #12345",
"image": "ipfs://QmYyyy..."
},
"createdAt": 1704067200,
"updatedAt": 1704153600
}
}
}

Implementation Notes

note
  • Use the thumbnails field with appropriate preset values (SMALL, MEDIUM, LARGE) for responsive images and optimized loading.
  • The fileType field contains the MIME type (e.g., image/png, video/mp4, audio/mpeg) for proper content rendering.
  • The mediaType enum categorizes media as IMAGE, VIDEO, AUDIO, ANIMATION, DOCUMENT or UNKNOWN for conditional UI rendering.
  • Values for createdAt and updatedAt are Unix timestamps in seconds. Convert to local time for user-facing applications.
  • The metadata field provides a reference to the associated token metadata, useful for displaying NFT names and descriptions alongside media.