POST
/
pinning
/
pinByHash
curl --request POST \
  --url https://api.pinata.cloud/pinning/pinByHash \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "hashToPin": "CID",
  "pinataOptions": "<string>",
  "pinataMetadata": "<string>"
}'
{
  "id": "<string>",
  "ipfsHash": "<string>",
  "status": "<string>",
  "name": "<string>"
}

This endpoint allows for an additional property in the pinataOptions object to help our IPFS nodes find the content you would like pinned.

hostNodes - multiaddresses of nodes your content is already stored on.

You can pass in the “multiaddresses” up to five host nodes that your content already resides on.

To find the multiaddresses of your own nodes, simply run the following on your node’s command line:

ipfs id

In the response, you’ll want to focus on the “Addresses” array that’s returned. Here you’ll find the multiaddresses of your node. These multiaddresses are what other IPFS nodes use to connect to your node.

In the “Addresses” array, take note of the multiaddress that contains your external IP address. Not the local ipv4 “127.0.0.1” address or the local ipv6 “::1” address.

Here’s an example of a full external ipv4 multiaddress (your IP address and node ID will differ):

/ip4/123.456.78.90/tcp/4001/ipfs/QmAbCdEfGhIjKlMnOpQrStUvWxYzAbCdEfGhIjKlMnOpQr

Once you’ve grabbed the full multiaddress for every node that already has your content pinned, simply add the “host_nodes” property to your pinataOptions object like so:

{
    hashToPin: (ExampleHash),
    pinataOptions: {
        hostNodes: [
            /ip4/hostNode1ExternalIP/tcp/4001/ipfs/hostNode1PeerId,
            /ip4/hostNode2ExternalIP/tcp/4001/ipfs/hostNode2PeerId
            .
            .
            .
        ]
    }
}

Authorizations

Authorization
string
headerrequired

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

Body

application/json
hashToPin
string
required

The CID of the file you want to pin to Pinata

pinataOptions
string

Optional Pinata Options object

pinataMetadata
string

Optiona Pinata Metadata object

Response

200 - application/json
id
string
ipfsHash
string
status
string
name
string