This Node.js quickstart should get you up and running with your standard backend javascript setup, and by using the API will give you flexibility when it comes to uploading files.Documentation Index
Fetch the complete documentation index at: https://docs.pinata.cloud/llms.txt
Use this file to discover all available pages before exploring further.
Generate your API Keys
To create an API key, visit the Keys Page and click the “New Key” button in the top right. Once you do that you can select if you want your key to be admin or if you want to scope the privileges of the keys to certain endpoints or limit the number of uses. Make those selections, then give the key a name at the bottom, and click create key.If you are just getting started, we recommend using Admin privileges, then
move to scope keys as you better understand your needs
The API keys are only shown once, be sure to copy them somewhere safe!
Setup a Node.js Project
To start you can go to your terminal and put in the following codedotenv
.env file where we’re pull the following variables.
JWT from the API key creation in the previous step as well as the Gateway Domain. The format of the Gateway domain should be mydomain.mypinata.cloud.
Now we’ll make two files, index.js and hello-world.txt.
hello-world.txt you can put whatever you’d like such as Hello World!.
Upload a File to Pinata
Once we have our initial project setup we can put the following code into ourindex.js file.
node index.js in the terminal. After uploading a file you should get a response that looks like this
Fetch the File through a Gateway
With thecid you can view the file or fetch the data using your Gateway. Lets make a new file called fetch.js and put in the following code.
fetch.js