NFT Collections
Ternoa indexer is a record of the Ternoa Chain data. You can query data for some specific entities (NFT, Collection, Marketplace(...)) using GraphQL. In this example, we use the graphql-request library.
Step 1: CollectionEntity query preparation
You first need to prepare a stringified query to get Collection data from a specific collection id. Here are detailed the parameters available for the CollectionEntity
:
For example, if we want to get the Collection: owner / id; we have to prepare the following query by replacing COLLECTION_ID with the collection id you want to get the information from (e.g. the collection id from the Collection minted previously in "How to mint a Collection on-chain"):
Step 2: Sending the request to the Indexer
Once the query is ready, you can request our Indexer instances by providing both the indexer endpoint and the query.
Replace COLLECTION_ID in the following code snippet with the collection ID previously generated in "How to mint a Collection on-chain"):
The getCollectionData
function is an asynchronous function that sends a GraphQL request using the request
function from the "graphql-request" library. Here we are using the Ternoa Alphanet instance at "https://indexer-alphanet.ternoa.dev" with the Collection ID 0 as the query parameter (you can try with your id). The response from the server is an object with a property collectionEntity that has the data of the requested Collection entity.
The response for the collection id 0 the Alphanet Network is:
How to retrieve the last Collection minted using Ternoa Indexer
Ternoa Indexer comes with filtering and ordering options. Instead of requesting a single CollectionEntity
with a specific collection ID, you can filter all CollectionEnties
:
The NFT in the response will be ordered by creation timestamp descendent with orderBy: [TIMESTAMP_CREATE_DESC]
.
The response on the Alphanet Network when this document is written is:
The last Collection minted on the Ternoa chain is collection 585.
How to retrieve a limited collection using the Ternoa Indexer
Ternoa indexer is a record of the Ternoa Chain data. You can query data for some specific entities (NFT, Collection, Marketplace(...)) using graphql. In this example, we use the graphql-request library.
You first need to prepare a stringified query to get collection data from a specific collection id, as we did in the query(id) function. Do not hesitate to adapt the information you require in your query. When the query is ready, you can request our indexer by providing both the indexer endpoint and the query. To check if the collection is limited, the limit
should be set and the timestampLimit
must be filled.
How to retrieve a closed collection using Ternoa Indexer
Ternoa indexer is a record of the Ternoa Chain data. You can query data for some specific entities (NFT, Collection, Marketplace(...)) using graphql. In this example, we use the graphql-request library.
You first need to prepare a stringified query to get collection data from a specific collection id, as we did in the query(id) function. Do not hesitate to adapt the information you require in your query. When the query is ready, you can request our indexer by providing both the indexer endpoint and the query. To check if the collection is closed, just add the isClosed
andtimestampClose
fields in the list.
How to retrieve a burned collection using Ternoa Indexer
Ternoa indexer is a record of the Ternoa Chain data. You can query data for some specific entities (NFT, Collection, Marketplace(...)) using graphql. In this example, we use the graphql-request library.
You first need to prepare a stringified query to get collection data from a specific collection id, as we did in the query(id) function. Do not hesitate to adapt the information you require in your query. When the query is ready, you can request our indexer by providing both the indexer endpoint and the query. To check if the collection is burned, the owner
should be set to null, and the timestampBurn
must be filled.
Support
If you face any trouble, feel free to reach out to our community engineers in our Discord.
Last updated