Links

Get Assets by Group

Get a list of assets by a group key and value.

Overview

This will return the asset information for a specific group provided (i.e Collection). This can return compressed or standard NFTs.
The page parameter in the request starts at 1 .
post
https://rpc.helius.xyz
/?api-key=<api_key>
getAssetsByGroup

Suggested Use Cases

  • NFT Collection Page
  • NFT Mintlist
  • Token Gated dApps

Example

Mad Lads Mint List

const url = "https://rpc.helius.xyz/?api-key=<api-key>"
const getAssetsByGroup = async () => {
const response = await fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
jsonrpc: '2.0',
id: 'my-id',
method: 'getAssetsByGroup',
params: {
groupKey: 'collection',
groupValue: 'J1S9H3QjnRtBbbuD4HjPV6RpRhwuk4zKbxsnCHuTgh9w',
page: 1, // Starts at 1
limit: 1000,
},
}),
});
const { result } = await response.json();
console.log("Assets by Group: ", result.items);
};
getAssetsByGroup();

Pagination with Mad Lads

const url = "https://rpc.helius.xyz/?api-key=<api-key>"
const getAssetsByGroup = async () => {
console.time("getAssetsByGroup"); // Start the timer
let page = 1;
let assetList = [];
while (page) {
const response = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
jsonrpc: "2.0",
id: "my-id",
method: "getAssetsByGroup",
params: {
groupKey: "collection",
groupValue: "J1S9H3QjnRtBbbuD4HjPV6RpRhwuk4zKbxsnCHuTgh9w",
page: page,
limit: 1000,
},
}),
});
const { result } = await response.json();
assetList.push(...result.items);
if (result.total !== 1000) {
page = false;
} else {
page++;
}
}
const resultData = {
totalResults: assetList.length,
results: assetList,
};
console.log("Mad Lads Assets: ", resultData);
};
getAssetsByGroup();