NFT API Quickstart
Go from zero to hero with the Alchemy NFT API. Learn how to query NFT data, then dive into some fun tutorials!
Don't have an API key?
Start using the NFT API in your app today. Get started for free
Getting Started Instructions
Follow along with the steps below to get started with the NFT API:
-
- Alchemy SDK (recommended)
- Node-Fetch
- Axios
1. Choose a package manager
For this guide, we will be using npm
or yarn
as our package manager to install either alchemy-sdk
, fetch
, or axios
.
npm
To get started with npm
, follow the documentation to install Node.js and npm
for your operating system: https://docs.npmjs.com/downloading-and-installing-node-js-and-npm
yarn
To get started with yarn
, follow these steps: https://classic.yarnpkg.com/lang/en/docs/install
2. Set up your repo
npm
Open up a terminal, and from the command line, create a new repository to hold your quickstart scripts. We’ll also initialize the repo as an npm project.
yarn
Since we’ll be using import syntax to load ES6 modules, add 'type': 'module'
to your package.json
file:
See this discussion for more context.
3. Choose a Library
a) Alchemy SDK (Recommended)
You can install the alchemy-sdk-js
module to easily interact with Alchemy APIs. We highly recommend using the Alchemy SDK because you also get WebSocket support, retries, and other benefits without the complexity!
For full documentation on alchemy-sdk-js
, check the GitHub repo:
View the Alchemy SDK on GitHub
Installation
Run the following command to install alchemy-web3
with npm
and yarn
Demo Script
View the demo script on GitHub
The demo script for the Alchemy SDK
In your alchemy-nft-api
directory, you can create a new file called alchemy-sdk-script.js
using your favorite file browser, code editor, or just directly in the terminal using the touch
command like this:
and then paste the following code snippet into the file:
From your command line, you can execute the script with:
You should see output like this:
For full documentation on the available endpoints for alchemy-sdk
, check the github repo:
View the Alchemy SDK on GitHub
b) Node-Fetch
node-fetch
is a lightweight, common module that brings the Fetch API to Node.js and allows us to make our HTTP requests.
See the documentation for more info: https://www.npmjs.com/package/node-fetch
Installation
Run the following command to install node-fetch
with npm
and yarn
Demo Script
View the demo script on GitHub
In your alchemy-nft-api
directory, you can create a new file called fetch-script.js
using your favorite file browser, code editor, or just directly in the terminal using the touch
command like this:
and then paste the following code snippet in to explore the getNFTs or getNFTMetadata methods:
From your command line, you can execute the script with:
Your output should look like the following:
c) Axios
axios
is a promise-based HTTP client for the browser and Node.js, which allows us to make a raw request to the Alchemy API.
See the documentation for more info: https://www.npmjs.com/package/axios
Installation
Run the following command to install axios
with npm
and `yarn
Demo Script
View the demo script on GitHub
In your alchemy-nft-api
directory, you can create a new file called axios-script.js
using your favorite file browser, code editor, or just directly in the terminal using the touch
command.
and then paste the following code snippet in to explore the getNFTs or getNFTMetadata methods:
From your command line, you can execute the script with:
Your output should look like the following:
Available Tutorials
-
How to Create NFT Token-Gated Communities: Learn how to use the Alchemy NFT API to verify ownership of an NFT, or grab a complete ownership snapshot for a collection!
-
How to Filter Out Spam NFTs: Learn how to identify and filter spam NFTs using the Alchemy API.
-
How to Get NFT Owners at a Specific Block Height: Learn how to get snapshot of all the owners of an NFT collection at a particular point in time or block height using the NFT API.
-
How to Check the Owner of an NFT: Learn how to find the owner of an NFT (ERC-721 or ERC-155) on Ethereum and Polygon in one request using the NFT API.
-
How to Get All NFTs in a Collection: Learn how to get all NFTs that belong to a particular collection using the Alchemy NFT API.
-
How to Get All NFTs Owned by an Address: Learn how to get all NFTs (and their metadata) owned by an address using the Alchemy NFT API.
-
How to Get a List of NFT Holders for a Given Collection: Learn how to get a list of all wallets that own a specific NFT collection.
-
How to Resolve ENS Domains Given a Wallet Address: This tutorial uses Alchemy’s NFT API to fetch all ENS Domain Names owned by a user.
Each tutorial includes step-by-step instructions and code examples to help you follow along and build your own app.
Thank you for using the NFT API, and happy coding!