DEV Community

Cover image for Create a NFT collection using Python
Sem Moolenschot
Sem Moolenschot

Posted on

Create a NFT collection using Python


In this tutorial I will show you guys how to create your very own NFT collection in Python.


  1. Download Python.
  2. Open any IDE like VS Code, and then open ur terminal. Once you have your terminal opened you can clone the repository by typing git clone
  3. Now you have the repository cloned, you will need to install the requirements by typing the following in your terminal:


pip3 install -r requirements.txt
Enter fullscreen mode Exit fullscreen mode


pip install -r requirements.txt
Enter fullscreen mode Exit fullscreen mode

What is Pinata?

Pinata cloud is a pinning service that allows users to host files on the IPFS network. We will have to use this so that we can have a path to our images to put it in the corresponding metadata.

What is metadata?

NFT metadata is the core of an NFT. It is a JSON document that often contains a path to the image along with a description and the name of the NFT etc.

Get an API key from Pinata

  1. Go to and make an account.
  2. Click on your icon in the top right corner and navigate to API Keys.
  3. Click on the 'New Key' button, enable 'Admin' and give the key a name.
  4. Once you've made the key, copy the JWT (Secret access token).

Set up the config

Now comes the most important part, setting up the config. It will make sure that the images can be uploaded to the right Pinata account and that all names and descriptions will be set correctly for each individual NFT in your collection.

    // Name of your collection
    "project_name": "name of your project",

    // Amount of images you want to create
    "amount": 50,

    // Description of the collection
    "description": "description of your collection",

    // JWT (Secret access token) from Pinata that you had copied
    // earlier.
    "api_key": "your secret access token",

    // All folders containing seperate layers that will be used
    // to make your final images. You can add as many folders as
    // you want as long as they start with a sequential number
    // that represents the order of the layers. 
    "folders": [
        "1 background",
        "2 body",
        "3 eyes"

    // Files to be ignored in the corresponding folders while
    // making the NFT images.
    "ignore": [
Enter fullscreen mode Exit fullscreen mode

You should have a file structure that looks something like the following:

├─ config.json
├─ requirements.txt
├─ 1 background/
│  ├─ red.png
│  ├─ green.png
│  ├─ blue.png
├─ 2 body/
│  ├─ female.png
│  ├─ male.png
│  ├─ zombie.png
├─ 3 eyes/
│  ├─ sun_glasses.png
│  ├─ normal_eyes.png
│  ├─ vr_glasses.png
Enter fullscreen mode Exit fullscreen mode

Make sure each folder contains at least one image.

Creating the images

Now the config and folders are set up, we're finally able to create the images. Good job 👏. All you have to do now is open up your terminal and run the Python file.


Enter fullscreen mode Exit fullscreen mode


Enter fullscreen mode Exit fullscreen mode

If you have followed along step by step, then your images and the metadata should appear in a folder called 'output'. You can also log in to Pinata and your output should be right there at the files tab.


We have now created our own collection of unique images along with the metadata that's needed to deploy them as NFT's!

If you’ve reached this far, congratulations! There will be another tutorial soon to actually deploy your images and start earning money.

Final code repository

Top comments (0)