Gateways are Pinata’s tool to deliver your content with speed and security. They’re similar to CDNs but with way more features. When you create a Pinata account, you’ll automatically have a Gateway created for you! To see it, simply visit the Gateways Page.

The gateway domains are randomly generated and might look something like this:

aquamarine-casual-tarantula-177.mypinata.cloud

Retrieving Files Through Your Gateway

All content uploaded to Pinata is by default private, and there are a few ways you can view it. One of the simplest ways to fetch content is through the get method in the SDK. All content is referenced by the cid, a special identifier given to each file based on the cotnent of that file.

import { PinataSDK } from "pinata";

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

const file = await pinata.gateways.get("bafkreib4pqtikzdjlj4zigobmd63lig7u6oxlug24snlr6atjlmlza45dq")

You can also create a signed URL that can be used to access the content for a limited amount of time.

import { PinataSDK } from "pinata";

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

const url = await pinata.gateways.createSignedURL({
	cid: "bafkreib4pqtikzdjlj4zigobmd63lig7u6oxlug24snlr6atjlmlza45dq",
	expires: 30, // Number of seconds link is valid for
});

Adding a Custom Domain

Pinata also allows you to create a custom domain for your Dedicated Gateway. Simply visit the Gateways Page, click the menu button on the right side of your gateway, then click Add Custom Domain. You’ll need to own the domain you want to use. When you enter your domain, you will be prompted to enter DNS information through your registrar.