How to get NFT collections by creator
Prerequisitesβ
Before getting started, make sure you have the following ready:
- Node v.14+ or Python
- NPM/Yarn or Pip
Step 1: Setup Moralisβ
First register your Moralis account and get your Moralis API Key.
Once you have your Moralis API Key, install the Moralis SDK in your project.
- npm
- yarn
- pnpm
- pip
npm install moralis
yarn add moralis
pnpm add moralis
pip install moralis
Step 2: Get NFT Collections By Creatorβ
In order to get NFT collections by creator, Moralis provides you a getNFTCollectionsByCreator endpoint to do so.
Here you'll need two parameters: limit
and creatorAddress
.
Once you have obtained both the limit
and creatorAddress
, you can copy the following code:
- index.js (JavaScript)
- index.ts (TypeScript)
- index.py (Python)
const Moralis = require("moralis").default;
const runApp = async () => {
await Moralis.start({
apiKey: "YOUR_API_KEY",
// ...and any other configuration
});
const limit = 10;
const creatorAddresses =
"0x57410cf1141dd18aef4acf956d3c35a9634111642c5ed0ab0d017d634869959b";
const response =
await Moralis.AptosApi.collections.getNFTCollectionsByCreator({
limit,
creatorAddresses,
});
console.log(response.result);
};
runApp();
import Moralis from "moralis";
const runApp = async () => {
await Moralis.start({
apiKey: "YOUR_API_KEY",
// ...and any other configuration
});
const limit = 10;
const creatorAddresses =
"0x57410cf1141dd18aef4acf956d3c35a9634111642c5ed0ab0d017d634869959b";
const response =
await Moralis.AptosApi.collections.getNFTCollectionsByCreator({
limit,
creatorAddresses,
});
console.log(response.result);
};
runApp();
from moralis import aptos_api
api_key = "YOUR_API_KEY"
params = {
"network": "mainnet",
"limit": 10,
"creator_address": "0x57410cf1141dd18aef4acf956d3c35a9634111642c5ed0ab0d017d634869959b"
}
result = aptos_api.collections.get_nft_collections_by_creator(
api_key=api_key,
params=params,
)
print(result)
Step 3: Run the scriptβ
To run the script, enter the following command:
- Shell (JavaScript)
- Shell (TypeScript)
- Shell (Python)
node index.js
ts-node index.ts
python index.py
In your terminal, you should see the following JSON response:
[
{
"collection_data_id_hash": "43c343a58c54f0ce20ad9329d799b7e4e3f8dfb2ba76e4fae7a472f1bcf611ec",
"collection_name": "[REDACTED] Keys",
"creator_address": "0x57410cf1141dd18aef4acf956d3c35a9634111642c5ed0ab0d017d634869959b",
"description": "A set of mysterious keys. Is that a flamingo?",
"description_mutable": true,
"last_transaction_timestamp": "2022-12-23T08:25:31.000Z",
"last_transaction_version": "55833002",
"maximum": "7878",
"maximum_mutable": true,
"metadata_uri": "https://nftstorage.link/ipfs/bafybeichamqw2clzmpmfzm4v3dywdiitpl3pvd5wzaoxy6khizmtir3nwy/0.gif",
"supply": "1400",
"table_handle": "0x4190bb038ddb7d014118c6d45e3ac2db9166a1d0b43312750dc78e21139bca24",
"uri_mutable": true
}
]
Congratulations π₯³ You just got NFT collections by creator with just a few lines of code using the Moralis NFT API!
Youtube Videoβ
API Referenceβ
If you want to know more details on the endpoint and optional parameters, check out:
Supportβ
If you face any trouble following the tutorial, feel free to reach out to our community engineers in our Discord or Forum to get 24/7 developer support.