I want to use Center to render images
Use the Render NFT endpoint to render the media directly, specifying the following parameters:
network
: Network ID where the NFT is presentaddress
: Contract address for NFTtokenId
: Token ID for NFTfilename
: How you would like the NFT to be rendered (See below)
Note: You can omit the mediaPath
query parameter. We will select the media file (if there are multiple) that we think is most likely to be the default media for the NFT. We will not select a video or audio file.
What is the filename
?
The filename tells us how you would like the NFT to be rendered. It should be provided in the following format: size.format
.
- size: This is required. It can either be a preset (
small
,medium
ororiginal
) or a specific file dimension (400x400
,750x750
). Thesmall
preset is 200x200 and themedium
preset is 1000x1000.original
will render the media in its original size and format.- Note: Media will be rendered in its original aspect ratio within the bounds of the size that is specified.
- format: This is optional. It is used to transform media into a desired format. This format can be
png
,jpg
orgif
.
Example acceptable filename
parameters are: medium
,250x250.jpg
,small.png
,original
,650x650
.
I want to use Center to render more complex media (audio, video, HTML media)
Most NFTs with audio, video or HTML media have several media files associated with them. In order to specify the precise media file you would like to render, you will need to follow a few steps:
- Determine the
key
of the media file you would like to render. Common keys includeimage
andanimation_url
.- In order to determine the
key
, you can either:- Query the List NFT Media endpoint to retrieve a list of all media files available for a particular NFT.
- Query the Show NFT Metadata endpoint (or the batched version). An
allMediaPaths
array is returned which provides the list of all available media files.
- Center categorizes the available media into four categories:
image
,audio
,video
andother
. We also provide the mime type for each, so that you can decide what you want to render.
- In order to determine the
- If rendering
image
,audio
orvideo
use the Center Render NFT endpoint with the following:- Specify
original
for thefilename
parameter. - Provide the
key
in themediaPath
parameter. This is oftenanimation_url
for audio and video NFTs.
- Specify
- If rendering
other
(e.g., HTML files):- You should not use the Center Render NFT endpoint. Due to issues like relative paths and CORS, it is often not possible for us to render these directly.
- You should take the source URL from the media array and render it directly in your application using an iFrame or similar.
I want to predict the size and file type of media before I render it
We provide the mime type of each media file associated with an NFT in our media array (available both in the List Media response and the NFT Metadata response).
To determine the file size, you can:
- Make a header request to the Render NFT endpoint. This will provide the
content-length
andcontent-type
for the media. - Query the Show NFT Metadata endpoint. A
media
array will be returned, which provides information about thesmall
andmedium
presets. If this media has already been rendered by Center, we will provide the file size.