Skip to main content
cover Welcome to the Pinata HackUTD cheat sheet! This doc will have everything you need to know about:
  • Getting Started with Pinata
  • Challenge and Prizes
  • Tutorials and Guides

What is Pinata?

Pinata makes file uploads easy for developers who need fast and zero-setup soltuions. We’ve seen the struggles with solutions like S3 for file uploads, and we knew we could make it better Our primary product, the Files API, makes it as simple as one line of code to upload a file:
const upload = await pinata.upload.file(file)
Retreiving files is just as easy!
const signedUrl = await pinata.gateways.createSignedURL({
 	cid: "bafkreib4pqtikzdjlj4zigobmd63lig7u6oxlug24snlr6atjlmlza45dq",
	expires: 30,
})
Built on years of experience with IPFS, Pinata has scaled companies to serve high volumes of requests and bandwidth, as well as developers who are just starting out. Next time you think you need S3, consider spending less time and go with Pinata.

Challenge Statement

Pinata makes file storage and retrieval incredibly simple, freeing you from the complexity of AWS S3 setups and tricky IAM policies. We’re challenging teams to unleash their creativity and build the most unique, game-changing full-stack application using only Pinata—no external databases allowed. Show us how you can push boundaries and create something that truly stands out!

Quickstart

Sign up for a free account
Almost all of our features are on the free account, but if you find yourself limited and need a paid account contact [email protected]

1. Get API key and Gateway URL

Inside the Pinata App select “API Keys” from the sidebar, then click “New Key” in the top right. We would recommend starting with Admin privileges and unlimited uses to start. You will receive a pinata_api_key, pinata_api_secret, and a JWT. The JWT is the most common authentication method and what we’ll be using below.Next you will want to grab your Gateway domain by clicking the Gateways tab in the sidebar. You should see it listed in the format fun-llama-300.mypinata.cloud and you will want to copy it exactly like that.

2. Install and Setup SDK

In the root of your project run the install command with your package manager of choice.
npm i pinata
Import and initialize the SDK in your codebase with the API key and Gateway from the previous step
import { PinataSDK } from "pinata";

const pinata = new PinataSDK({
  pinataJwt: "PINATA_JWT",
  pinataGateway: "example-gateway.mypinata.cloud",
});
The PINATA_JWT is a secret key, be sure to initialize the SDK in a secure environment and practice basic variable security practices. If you need to upload from a client environment, consider using signed JWTs

3. Upload a File

Use the upload method to upload a File object.
import { PinataSDK } from "pinata";

const pinata = new PinataSDK({
  pinataJwt: process.env.PINATA_JWT!,
  pinataGateway: "example-gateway.mypinata.cloud",
});

async function main() {
  try {
    const file = new File(["hello"], "Testing.txt", { type: "text/plain" });
    const upload = await pinata.upload.file(file);
    console.log(upload);
  } catch (error) {
    console.log(error);
  }
}

await main();
You should get a response object like the one below
{
    id: "349f1bb2-5d59-4cab-9966-e94c028a05b7",
    name: "file.txt",
    cid: "bafybeihgxdzljxb26q6nf3r3eifqeedsvt2eubqtskghpme66cgjyw4fra",
    size: 4682779,
    number_of_files: 1,
    mime_type: "text/plain",
    user_id: "7a484d2c-4219-4f80-9d9d-86b42461e71a",
    group_id: null
}
The unique thing about Pinata’s File API is the CID or Content Identifier. Its a unique hash based on the content ofthe file.

4. Retrieve a File through a Gateway

Use the cid of a file to fetch it through a Gateway, or create a signed URL.
import { PinataSDK } from "pinata";

const pinata = new PinataSDK({
  pinataJwt: process.env.PINATA_JWT!,
  pinataGateway: "example-gateway.mypinata.cloud",
});

async function main() {
  try {
    const data = await pinata.gateways.get("bafkreibm6jg3ux5qumhcn2b3flc3tyu6dmlb4xa7u5bf44yegnrjhc4yeq");
    console.log(data)

    const url = await pinata.gateways.createSignedURL({
       	cid: "bafkreib4pqtikzdjlj4zigobmd63lig7u6oxlug24snlr6atjlmlza45dq",
    	expires: 1800,
    })
    console.log(url)
  } catch (error) {
    console.log(error);
  }
}

main();

Prizes

1st Place: AirPods Max

2nd Place: Apple Watch Series 10

3rd Place: Apple HomePod Mini

Example Apps

To get some inspiration, here’s a starter app using the Private Files API. https://github.com/PinataCloud/memorii For more advance usage that takes advantage of key-values and other Pinata features, check out snippets.so

Tutorials

More Tutorials

Need Help?

We got troops on the ground! 🫡 Come find us at our table or shoot us an email!

Steve Simkins

Head of Developer Relations, Resident HillbillyEmail: [email protected]
steve

Lindsey Mazy

Senior Community & Marketing Specialist, Digital CelebrityEmail: [email protected]
lindsey

Kyle Tut

CEO, Vibe DreamerEmail: No email, v exclusive, find the cowboy hat to chat
kyle

Justin Hunter

VP of Product, Build WizardEmail: [email protected]

justin