This repo provides examples for uploading files to Pinata, a leading IPFS pinning service. It includes basic API calls to help you get started with uploading and managing files on IPFS through Pinata's platform.
Tip
If you plan to use Pinata in a Typescript/Javascript enviornment, check out SDK!
First follow these steps to create a free Pinata account and get your API key and Gateway URL.
By default this repo uses Bun.sh, so install this first unless you plan to run the files with another program.
Clone the repo to your machine and install the dependencies
git clone https://github.com/PinataCloud/files-api-starter
cd files-api-starter
bun install
Create a .env
file in the root directory and add your Pinata JWT API key and Gateway URL:
PINATA_JWT=your_pinata_jwt_here
GATEWAY_URL=your_gateway_url_here
Upload files to Pinata using the following commands:
Upload JSON files to Pinata:
npm run upload
Upload image files to Pinata:
npm run upload-image <path-to-image>
For example:
npm run upload-image logo.png
npm run upload-image /path/to/your/image.png
Using Bun directly:
bun upload-file.ts
Additional Pinata operations:
Explore the other files in this repo for additional Pinata functionality:
list-files.ts
- List files from your Pinata accountcreate-group.ts
- Create file groups in Pinataadd-to-group.ts
- Add files to existing groupscreate-ipfs-url.ts
- Generate IPFS URLs for your files