[IPFS] Pin file to IPFS

This API allows you to store a file on the IPFS network through the Numbers Gateway and keep it permanently stored. It requires either a fileURL or a file object along with a valid Capture Token for authorization. If you do not already have a Capture Token yet, please follow the instruction provided to create one.
The Numbers API charges you only for the files you pin, making it a cost-effective solution. Payments are taken every 30 days from your Capture Account's Asset Wallet and must be made in Credits or NUM. To avoid having your files unpinned, it's important to keep your wallet topped up and have sufficient funds. If a payment fails, you will receive an email notification and have 10 days to deposit more funds.
Please note: This API is designed for files up to 25MB. For files larger than 25MB, please use the subscription plan or enterprise API.
Payment for services is processed using NUM; if you want to know how much it costs in USD, you can check CoinGecko or CoinMarketCap.
API Endpoint: https://eoqctv92ahgrcif.m.pipedream.net
Cost: 0.025 NUM + Gas (~0.004 NUM per transaction) per file per month. No Gas is required if paid with Credits.
Method: POST
Description:
This API endpoint allows developers to pin a file to IPFS via the Numbers Gateway (https://ipfs-pin.numbersprotocol.io/ipfs/).
Authentication:
This API requires a valid token for Authorization. The token should be passed in the headers of the request using the following format: "Authorization: token YOUR_CAPTURE_TOKEN"
Header:
Authorization: token $YOUR_CAPTURE_TOKEN (required)
Content-Type: application/json
Request Body (required):
fileURL (string) or file (object): Either the URL of the file to be pinned or the file object itself must be specified. If the fileURL is used, it should be passed as a string. If the file object is used, it should be the direct upload from the system.
Request Body (optional):
pin (boolean): true to pin the file (default: true)
version (integer): CID version (default: 1)
Example 1 (direct file upload):
curl -F "file=@/tmp/MYFILE.png" \
-H "Authorization: token YOUR_CAPTURE_TOKEN" \
"https://eoqctv92ahgrcif.m.pipedream.net"
Example 2 (upload via URL)
curl -X POST "https://eoqctv92ahgrcif.m.pipedream.net" \
-H "Content-Type: application/json" \
-H "Authorization: token YOUR_CAPTURE_TOKEN" \
-d '{
"fileURL": FILE_URL,
"pin": true,
"version": 0
}'
Response:
{
"fileURL": string, // URL of the pinned file
"cid": string, // content identifier of the file
"fileSize": integer, // size of the file
"cid_version": integer // version of the cid
"orderID": string // ID of this order
}
200: File has been pinned successfully
400: Bad request
401: Unauthorized
403: Forbidden
500: Internal Server Error
In this example, you would replace YOUR_CAPTURE_TOKEN with your actual Capture token and /tmp/MYFILE.png with the actual file on your filesystem. More examples can be found below:
Python
Javascript
import requests
url = "https://eoqctv92ahgrcif.m.pipedream.net"
headers = {
"Content-Type": "application/json",
"Authorization": "token YOUR_CAPTURE_TOKEN"
}
data = {
"fileURL": FILE_URL,
"pin": true,
"version": 1
}
response = requests.post(url, headers=headers, json=data)
if response.status_code == 200:
response_json = response.json()
print(response_json)
else:
print("Request failed with status code:", response.status_code)
const request = require("request");
const url = "https://eoqctv92ahgrcif.m.pipedream.net";
const headers = {
"Content-Type": "application/json",
"Authorization": "token YOUR_CAPTURE_TOKEN"
};
const data = {
"fileURL": FILE_URL,
"pin": true,
"version": 1
};
request.post(
{
url,
headers,
json: data
},
function(error, response, body) {
console.log(body);
}
);