Delete File (Unpin)
curl --request DELETE \
--url https://api.pinata.cloud/pinning/unpin/{CID} \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.pinata.cloud/pinning/unpin/{CID}"
headers = {"Authorization": "Bearer <token>"}
response = requests.delete(url, headers=headers)
print(response.text)const options = {method: 'DELETE', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.pinata.cloud/pinning/unpin/{CID}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.pinata.cloud/pinning/unpin/{CID}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "DELETE",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.pinata.cloud/pinning/unpin/{CID}"
req, _ := http.NewRequest("DELETE", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.delete("https://api.pinata.cloud/pinning/unpin/{CID}")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.pinata.cloud/pinning/unpin/{CID}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Delete.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body"OK"Pinning
Delete File (Unpin)
Delete a file by CID
DELETE
/
pinning
/
unpin
/
{CID}
Delete File (Unpin)
curl --request DELETE \
--url https://api.pinata.cloud/pinning/unpin/{CID} \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.pinata.cloud/pinning/unpin/{CID}"
headers = {"Authorization": "Bearer <token>"}
response = requests.delete(url, headers=headers)
print(response.text)const options = {method: 'DELETE', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.pinata.cloud/pinning/unpin/{CID}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.pinata.cloud/pinning/unpin/{CID}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "DELETE",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.pinata.cloud/pinning/unpin/{CID}"
req, _ := http.NewRequest("DELETE", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.delete("https://api.pinata.cloud/pinning/unpin/{CID}")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.pinata.cloud/pinning/unpin/{CID}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Delete.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body"OK"Unpin All Files
Unpin All Files
If you find yourself in a place where you need to unpin a lot of files or perhaps all your files, you can use a script like this to create an array of CIDs and unpin them one by one. The example below uses the
pinList queries to target all pinned files and return 1000 for each request. This could easily be done with a different query to target different files, please check out the listing files doc for more info.Unpin All Files
const PINATA_JWT = "YOUR_JWT_HERE";
const PIN_QUERY = `https://api.pinata.cloud/data/pinList?status=pinned&pageLimit=1000&includeCount=false`;
const fetch = require("node-fetch");
const wait = (milliseconds) => {
return new Promise((resolve) => {
setTimeout(resolve, milliseconds);
});
};
const fetchPins = async () => {
try {
console.log("Fetching pins...");
let pinHashes = [];
let pageOffset = 0;
let hasMore = true;
while (hasMore === true) {
try {
const response = await fetch(`${PIN_QUERY}&pageOffset=${pageOffset}`, {
method: "GET",
headers: {
accept: "application/json",
Authorization: `Bearer ${PINATA_JWT}`,
},
});
const responseData = await response.json();
const rows = responseData.rows;
if (rows.length === 0) {
hasMore = false;
}
const itemsReturned = rows.length;
pinHashes.push(...rows.map((row) => row.ipfs_pin_hash));
pageOffset += itemsReturned;
await wait(300);
} catch (error) {
console.log(error);
break;
}
}
console.log("Total pins fetched: ", pinHashes.length);
return pinHashes;
} catch (error) {
console.log(error);
}
};
const deletePins = async () => {
const pinHashes = await fetchPins();
const totalPins = pinHashes.length;
let deletedPins = 0;
try {
for (const hash of pinHashes) {
try {
const response = await fetch(
`https://api.pinata.cloud/pinning/unpin/${hash}`,
{
method: "DELETE",
headers: {
Authorization: `Bearer ${PINATA_JWT}`,
},
}
);
await wait(300);
deletedPins++;
process.stdout.write(`Deleted ${deletedPins} of ${totalPins} pins\r`);
} catch (error) {
console.log(error);
}
}
console.log("Pins deleted");
} catch (error) {
console.log(error);
}
};
deletePins();
⌘I