Skip to main content
POST
/
pinning
/
pinJSONToIPFS
Pin JSON
curl --request POST \
  --url https://api.pinata.cloud/pinning/pinJSONToIPFS \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "pinataOptions": {
    "cidVersion": 1
  },
  "pinataMetadata": {
    "name": "pinnie.json"
  },
  "pinataContent": {
    "somekey": "somevalue"
  }
}'
{
  "IpfsHash": "<string>",
  "PinSize": 123,
  "Timestamp": "<string>",
  "isDuplicate": true
}
Pinata makes it easy to upload JSON objects using the pinJSONToIPFS endpoint.
Pin JSON
const JWT = 'YOUR_PINATA_JWT';

async function pinJSONToIPFS() {
  try {
    const data = JSON.stringify({
      pinataContent: {
        name: "Pinnie",
        description: "A really sweet NFT of Pinnie the Pinata",
        image: "ipfs://bafkreih5aznjvttude6c3wbvqeebb6rlx5wkbzyppv7garjiubll2ceym4",
        external_url: "https://pinata.cloud"
      },
      pinataMetadata: {
        name: "metadata.json"
      }
    })
    const res = await fetch("https://api.pinata.cloud/pinning/pinJSONToIPFS", {
      method: "POST",
      headers: {
        'Content-Type': 'application/json',
        Authorization: `Bearer ${JWT}`,
      },
      body: data,
    });
    const resData = await res.json();
    console.log(resData);
  } catch (error) {
    console.log(error);
  }
};

await pinJSONToIPFS()

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json
pinataContent
object
required

The JSON content to pin

pinataOptions
object

Optional Pinata Options Object

pinataMetadata
object

Optional Pinata Metadata object

Response

200 - application/json

{ "IpfsHash": "This is the IPFS multi-hash (CID) provided back for your content," "PinSize": "This is how large (in bytes) the content you just pinned is," "Timestamp": "This is the timestamp for your content pinning (represented in ISO 8601 format)" }

IpfsHash
string
PinSize
integer
Timestamp
string
isDuplicate
boolean
I