Metamask: Pinata pinList API Fetching Unpinned Images and Files
Februari 4, 2025 | by Gusri Efendi

Metamask: Pinata PIN List API fetches unpinned images and files
As a Pinata user, you may be familiar with accessing your Pinata Cloud data via the official APIs. However, I have encountered an issue where, despite my efforts to detach several images and files from my Pinata account, new images and files are still being fetched from the Pinata PIN List API.
Problem
When you pin or unpin content in Pinata, you should usually update the Pin List API to reflect the changes in your data. However, the Pinata API does not seem to take these updates into account. In particular:
- If you unpin multiple items at once, new images and files may be fetched from the Pin List API.
- When you unpin certain pins or content types (e.g. assets), the API may still attempt to fetch the associated items.
Solution
I explored several options to resolve this issue:
- API Key: The Pinata documentation states that setting up a custom API key can help avoid such issues. However, using an API key without proper authentication can lead to unauthorized access and security issues.
- Pinta List Updates: Pinata provides an API to update the pin list itself (e.g. the “pinList” endpoint). While this seems like a possible solution, it requires a more complex implementation and understanding of Pinata’s internal data structures.
Solution: Using Webhooks
After exploring alternative approaches, I found that using webhooks can be an effective way to resolve this issue. Here is the proposed solution:
Step-by-step instructions
- Pinata Webhook Setup: Create a new webhook in your Pinata account by following the instructions in the documentation.
- Configure a webhook to capture unpinned events: Set up a webhook to detect unpinned items and send notifications or updates as needed.
- Use the retrieval API to update pin list data: Once an item is resolved, use the retrieval API to retrieve updated pin list data from the Pinata servers. This should prevent new images and files from being retrieved.
Example code
// Assume you have a webhook endpoint (e.g.
const webhookUrl = "
const apiKey = "YOUR_API_KEY";
fetch(${webhookUrl}?action=update&api_key=${apiKey}
)
.then(response => {
if (!response.ok) {
throw new Error ('API response:', response.status);
}
return response.json();
})
.then(data => {
// Update the pin list data with the retrieved information
const updatedPinList = { ...data.pinList }; // assume 'pinList' is an array of objects
// Update your local database or storage with the new pin list data
})
.catch(error => console.error('Error:', error));
Conclusion
By setting up a webhook to catch board unpin events and using the ‘fetch’ API to update the board list data, you can effectively solve the problem of retrieving unpinned images and files from your Pinata account. While this solution requires some technical knowledge, it should provide reliable and efficient access to your Pinata cloud data.
Note that this is just one possible solution and there may be other approaches or workarounds depending on your specific use case.
RELATED POSTS
View all