Pinata Docs
Search…
Pin JSON
/pinning/pinJSONToIPFS
This endpoint allows the sender to add and pin any JSON object they wish to Pinata's IPFS nodes. This endpoint is specifically optimized to only handle JSON content. Once the server receives the JSON, it is converted into a JSON file and pinned to our IPFS storage nodes.

Uploading and Pinning JSON

Each upload can optionally include additional information beyond just the file. Both pinataOptions and pinataMetadata can be included in the request. Their formats are documented here.
post
https://api.pinata.cloud
/pinning/pinJSONToIPFS
cURL
Node.js
Python
Go
curl --location --request POST 'https://api.pinata.cloud/pinning/pinJSONToIPFS' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer PINATA JWT' \
--data-raw '{
"pinataOptions": {
"cidVersion": 1
},
"pinataMetadata": {
"name": "testing",
"keyvalues": {
"customKey": "customValue",
"customKey2": "customValue2"
}
},
"pinataContent": {
"somekey":"somevalue"
}
}'
var axios = require('axios');
var data = JSON.stringify({
"pinataOptions": {
"cidVersion": 1
},
"pinataMetadata": {
"name": "testing",
"keyvalues": {
"customKey": "customValue",
"customKey2": "customValue2"
}
},
"pinataContent": {
"somekey": "somevalue"
}
});
​
var config = {
method: 'post',
url: 'https://api.pinata.cloud/pinning/pinJSONToIPFS',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer PINATA JWT'
},
data : data
};
​
const res = await axios(config);
​
console.log(res.data);
import requests
import json
​
url = "https://api.pinata.cloud/pinning/pinJSONToIPFS"
​
payload = json.dumps({
"pinataOptions": {
"cidVersion": 1
},
"pinataMetadata": {
"name": "testing",
"keyvalues": {
"customKey": "customValue",
"customKey2": "customValue2"
}
},
"pinataContent": {
"somekey": "somevalue"
}
})
headers = {pyth
'Content-Type': 'application/json',
'Authorization': 'Bearer PINATA JWT'
}
​
response = requests.request("POST", url, headers=headers, data=payload)
​
print(response.text)
​
package main
​
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
​
func main() {
​
url := "https://api.pinata.cloud/pinning/pinJSONToIPFS"
method := "POST"
​
payload := strings.NewReader(`{
"pinataOptions": {
"cidVersion": 1
},
"pinataMetadata": {
"name": "testing",
"keyvalues": {
"customKey": "customValue",
"customKey2": "customValue2"
}
},
"pinataContent": {
"somekey":"somevalue"
}
}`)
​
client := &http.Client {
}
req, err := http.NewRequest(method, url, payload)
​
if err != nil {
fmt.Println(err)
return
}
req.Header.Add("Content-Type", "application/json")
req.Header.Add("Authorization", "Bearer PINATA JWT")
​
res, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer res.Body.Close()
​
body, err := ioutil.ReadAll(res.Body)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(body))
}