getNFTs
/**
* Get NFTs by an account address
* @param {string} address Account address
* @param {string} [includeMetadata=false] flag to include the metadata object in the results
* @returns {Promise<object>} List of NFTs with metadata if 'includeMetadata' flag is true
*/
async getNFTs({ publicAddress, includeMetadata = false }) {
if (!publicAddress || !utils.isAddress(publicAddress)) {
throw new Error(
errorLogger({
location: ERROR_LOG.location.SDK_getNFTs,
message: ERROR_LOG.message.invalid_account_address,
}),
);
}
const apiUrl = `${this.#apiPath}/accounts/${publicAddress}/assets/nfts`;
const { data } = await this.#httpClient.get(apiUrl);
if (!includeMetadata) {
return {
...data,
assets: data.assets.map(asset => {
const { metadata, ...rest } = asset;
return rest;
}),
};
}
return data;
}
Method currently returns maximum 100 items.
Copy link