How to mint NFTs with a REST API in 10 minutes

How to mint NFTs with a REST API in 10 minutes

VP of Product & Co-founder at NFTPort

Become an NFT Jedi: full tutorial for deploying NFT contracts, minting and building NFT products on Ethereum and Polygon

Wish to deploy your own NFT contract, mint NFTs or build an NFT-based product without having to learn complex Web3 stack? Then you’ve come to the right place as by the end of this blog post you’ll learn how to do exactly that with a simple-to-use REST API in just under 10 minutes, zero need to learn Solidity, IPFS, node infrastructure, etc. Just master a few API calls and become an NFT Jedi 🥷🏻

Building everything from scratch? We’ve done it so you don’t have to

So you’ve decided to build with NFTs as perhaps you want to release your own NFT collection, or mint NFTs as part of the product you’re building. In order to develop it, you’ve done some research into Web3 stack and realised the complexity of it, aka that you’d need to learn:

  • how to write Solidity and develop the contract
  • how to deploy a contract that is secure and accepted by users i.e. follows best practises
  • how to customize contracts for your product needs, e.g. how to set and handle royalties, update NFTs, etc.
  • how to integrate the contract with your application
  • how to handle gas fees and minting costs, need to deal with crypto, find funds to test stuff out
  • how to mint NFTs reliably and at scale if you need to mint a lot of NFTs dynamically from your application i.e. welcome to nonce hell
  • figure out what are the best and accepted practices for NFT storage i.e. IPFS, Filecoin, Arweave, etc.
  • start the loop again if you go another chain such as Solana, Polkadot, Flow, etc.

Yup, we’ve been part of the same journey and, truth be told, most of the times it ain’t fun. Usually the end result is spending months trying to figure out all of it and spending a lot of money meanwhile taking the focus off from the product itself.

That’s exactly why we built developer-first minting REST API - to abstract away the blockchain complexity so any Web2 or Web3 dev can focus on building what really matters - a product their users love and ship it in days, instead of months.

Jedi tricks - a single API call is all you need

Going from 450+ lines Solidity in ERC721 to a single REST API call to deploy your own NFT contract is just the start. Besides that, out of the box you’ll have:

  • NFT contracts that follow the best practises such as OpenZeppelin ERC721 and are open-source
  • You can customize the contracts by setting the wished royalty percentage, update metadata, update permissions, etc ✅
  • You don’t need to worry about fluctuating gas fees as you can pay a fixed fee in USD with Stripe ✅
  • You can mint NFTs at scale on Polygon as we’ve made it highly scalable (a separate blog post on that in the future) ✅
  • Out of the box NFT assets storage with Filecoin which ensures files are backed up for good in IPFS ✅
  • Fully owned by you, so you always have the ability to exit the API (we are devs ourselves and hate lock-ins) ✅
  • much more!

So, are you ready to start building your NFT product? ⚡

Getting started with NFTPort

First, get a free NFTPort API key. To do so, sign up for NFTPort and copy your API key from the "API key" section.

Getting started with NFTPort is free. Use your API key to mint NFTs, deploy contracts and build NFT products

Choosing a chain to mint NFTs: Ethereum vs Polygon vs Solana

Before you can start minting NFTs, you need to choose a blockchain for it. NFTPort supports Polygon, Solana, and Ethereum (mainnet) and Goerli (testnet). How do you decide which one is right for you?

  • Ethereum has been the default for a long time. Users perceive it to be high-status and secure; almost every wallet and NFT app supports it. However, it is also expensive -- it can go above $10 just to mint a single NFT -- and transactions can take minutes to be finalized.

  • Polygon is a layer-2 chain that brings costs down to a few cents per minted NFT and transactions are faster. It is directly compatible with Ethereum, so it is easy for apps to integrate this, and in fact many have. The largest marketplaces like OpenSea support Polygon.

  • Solana is not compatible with Ethereum but has its own benefits: transactions are very fast (sub-second) and almost too cheap to meter. It's not universally supported like Ethereum, but it's seeing rapid adoption now, and Solana recently exceeded Ethereum in NFT activity.

In a nutshell, if you are launching a PFP collection and want it be of high quality, we recommend Polygon. If you are building an NFT based product where you need to mint a lot of NFTs based on users activity in your application, then we recommend Polygon or Solana. 

Should you wish to change to another chain later on, you can easily do that as there are no lock-ins. Any API calls you make with NFTPort on one chain are very easy to modify to mint your NFTs onto another chain.

Mint an NFT on Polygon with REST API (using Easy Minting)

We'll start with the simplest possible use case: minting a single NFT. We will mint an ERC-721 token from an image. This is the simplest and most common type of NFT right now, and is supported by popular marketplaces like OpenSea and Rarible. In this example we don't need to write any contract code at all -- we'll get to that later.

The following API call mints one NFT. It's shown as a curl command, but in the full API documentation for easy minting an NFT in a single API call you can get code examples in Javascript, Python, Ruby, PHP, and many other languages.

curl --request POST \\
--url https://api.nftport.xyz/v0/mints/easy/urls \\
--header 'Authorization: YOUR-API-KEY-HERE' \\
--data '{
	"chain": "polygon",
	"name": "My first NFT",
	"description": "So this is what it is like to be on-chain?",
	"file_url": "",
	"mint_to_address": "0x5FDd0881Ef284D6fBB2Ed97b01cb13d707f91e42"

If you replace the API key in the example, you can run it on the command line to mint your first NFT. To become the owner of the minted NFT, you also need to set the mint_to_address to your own address, and I'm sure you also would like to customize the image, name and description to your liking. The response will look something like this:

	"response": "OK",
	"chain": "polygon",
	"contract_address": "0x1a61dd84d67228b04cf28542c9f492a07cc1a38a",
	"transaction_hash": "0x61af6e...",
	"transaction_external_url": "https://polygonscan.com/tx/0x61af6e...",
	"mint_to_address": "0x5FDd0881Ef284D6fBB2Ed97b01cb13d707f91e42",
	"name": "My first NFT",
	"description": "So this is what it is like to be on-chain?"

When you made the API call, this is what the NFTPort API took care of in the background:

  1. Downloaded the file you specified in file_url
  2. Uploaded this file to IPFS decentralized storage
  3. Using the name, description and the IPFS link to the file you specified, assembled an NFT metadata JSON and uploaded your NFT metadata to IPFS
  4. Finally, minted an NFT by submitting a transaction onto the Polygon chain. You can look at this transaction yourself by visiting the link in transaction_external_url from the API response

And just like that, you have created your first NFT from an image 🎉

Next, you might be wondering: how could we mint an NFT without deploying a contract first? Can't I deploy my own contract with NFTPort?

Of course you can. To keep easy minting easy, that NFT was minted into a contract that is shared across all NFTPort users. But most of the time you will want to have a dedicated contract just for your application, so this is what we'll be doing next.

Choose the right kind of NFT contract: Collection Contracts vs Product Contracts 

Before you deploy your own contract, you need to think through the end user flow you want to build. When an NFT is minted, do you just want to drop the NFT into the user's wallet automagically, or do you want the user to sign a transaction to mint the NFT themselves?

There are two main kinds of contracts you can deploy with NFTPort: collection contracts and product contracts.

  1. Collection contracts
    These are typically used to launch NFT collections -- think Bored Apes Yacht Club or Doodles. The maximum supply of tokens is fixed at contract deployment time, e.g. to 10,000 NFTs, and users mint the NFTs on a minting website (dApp) that the developer -- you! -- have set up. That means the user needs to be advanced enough to sign a transaction with their wallet.

  2. Product contracts
    These are more flexible. You can mint on-demand using our REST APIs, and the total number of NFTs in the collection is not limited: you can mint more whenever you like. To send an NFT to a wallet, you don't need to ask the user to sign the transaction, which makes for a simpler user experience.

If you know you want to launch a profile picture or art collection with a minting website, then you should use an NFT collection contract. But if you want to integrate NFTs into your product and give them some utility in your app, go for an NFT product contract

Both types of contracts let you mint standard ERC721 NFTs, support earning royalties, and show up on marketplaces. For details, see the full comparison of NFT contracts.

Deploy an NFT collection on Ethereum with REST API (using Collection Contract)

Let's now go through the steps needed to deploy an NFT collection contract on Ethereum (hint: there aren't many 👀).

First off, deploying to Ethereum with NFTPort is a paid feature on the Growth plan and costs $199 per contract to cover the gas fees (see NFTPort pricing for details). However, you can do a dry run of everything below for free by changing the chain parameter from ethereum to Goerli -- Goerli is a test network for the Ethereum mainnet.

The steps below are a summary of the full tutorial for launching an NFT collection on Ethereum. Refer to that page if you want to go deeper with anything shown here.

Before you go further you need to decide the maximum number of NFTs in your collection. You need to fix that upfront; people often choose 3,333 or 5,000 or 10,000 or another memorable number.

The basic steps for minting NFTs on Ethereum using collection contracts are:

  1. Upload the asset of each NFT to IPFS
    This is optional, but people typically attach an image, video, audio clip, or 3D model to the NFT.

  2. Upload a directory of metadata files to IPFS
    This is super easily done with our “Upload metadata directory to IPFS API” API endpoint. If you are new to NFT metadata, read NFT metadata basics first.

  3. Deploy the collection contract on Ethereum
    set the base_uri to the directory of metadata JSON files you just uploaded to IPFS.

  4. Your  collection contract is now live!
    Finally, you can set up a minting website. Alternatively, Etherscan acts as a sort of poor man's minting website: you can mint by going to the contract's Etherscan page, to "Contract" > "Write Contract", connecting your wallet, and signing the transaction.

And just like that, you’ve created and deployed an NFT collection on Ethereum with just a few simple API calls 🎉 

Mint NFTs on-demand on Polygon with REST API (using Product Contract)

As mentioned above, if you want to integrate NFTs into your product and give them some utility in your app, you’re better off with using NFT Product Contract as it is more flexible. For example, with Product Contract, you could:

  • Mint NFTs on-demand: e.g. imagine you’ve built a ticketing app. Every time when a user buys a ticket to an event, you can mint the ticket NFT on-demand. Or you can use NFTs for pre-orders: when a user places a pre-order, you can drop an NFT into their wallet as proof of their order, and their position in the waiting list.

  • You can also pre-mint a bunch of tokens and allow your user to drop them into another wallet at the push of a button.

  • For users without wallets, you could mint the NFT to them but hold custody of it, and transfer the token to the user's wallet only once they have set up their own wallet and requested to retrieve the token into their own custody.

To mint customisable NFTs on Polygon, you need to start by deploying a contract. As always, this only required a single API call with NFTPort. If you want to make dynamic NFTs, i.e. change the NFT after it has been minted, make sure you set metadata_updatable=true

Once you’ve deployed a contract, minting a customisable NFT takes three steps:

  1. Upload the asset of the NFT to IPFS
    As before, this could be an image, video, audio clip, 3D model, or any other file you will attach to the NFT.
  2. Upload the metadata file to IPFS
    You can customize the name, description, token ID, and many other things by specifying the relevant field in the metadata.
  3. Mint the NFT on Polygon
    With this API call, the transaction representing the NFT will go on-chain, and the NFT will show up in the user's wallet.

After you’ve minted your customisable NFT, you can update the NFT, burn the NFT, or transfer it

Next steps: Build your NFT application

You now know how to mint NFTs from an image with Easy Minting and mint on-demand with Customizable Minting, as well as how to deploy NFT contracts on Polygon and Ethereum -- all via REST API calls. 

But there are a lot more possibilities, like upgrading these NFTs, upgrading contracts, burning NFTs, or locking NFTs so they cannot be upgraded or deleted, and more. You can combine these building blocks in various ways to build your own NFT application – more on how to do that in the next guides.

Until then, get your free NFTPort API key to mint NFTs at scale and build anything from collections to large-scale NFT products.


The Stripe for NFTs — One-Stop, Simple and Developer-First NFT Infrastructure & APIs which Help Developers bring their NFT application to market in hours instead of months. We take care of the NFT infrastructure so you can focus on your application. By devs, for devs.

Website | Blog | Discord Community | Twitter | Docs | Contact Us

Similar Posts

Relevant Posts

Bring Your NFT Project to Life

Get Free API Key