NFT API Quickstart
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:
1. Choose a package manager
For this guide, we will be using npm
or yarn
as our package manager if you choose to use 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) Fetch
You can easily interact with Alchemy’s NFT API using simple fetch requests. No additional dependencies required with Node.js 18+.
Demo Script
View the demo script on GitHub
In your alchemy-nft-api
directory, you can create a new file called nft-api-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:
b) 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: