Numbers Protocol
Search
⌃K

[IPFS] Cat metadata from Nid/Cid

The following API helps you cat metadata with IPFS Nid from Numbers IPFS gateway. Capture Token and the Nid of the asset are required. If you do not already have a Capture Token yet, please follow the instruction provided to create one.
API Endpoint: https://eoilb27dj3s5ncc.m.pipedream.net
​
Cost: 0 NUM (free to use)
​
Method: GET
Endpoint: /?nid=NID_TO_FETCH
​
Description:
This API endpoint allows developers to retrieve metadata on IPFS via the Numbers Gateway (https://ipfs-pin.numbersprotocol.io/ipfs/) using a Nid. The returned data is a string containing the metadata associated with the provided Nid.
​
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"
​
Headers:
- Content-Type: application/json
- Authorization: token YOUR_CAPTURE_TOKEN
​
Examples:
curl -X GET -H "Content-Type: application/json" \
-H "Authorization: token YOUR_CAPTURE_TOKEN" \
https://eoilb27dj3s5ncc.m.pipedream.net?nid=NID_TO_FETCH
​
Response:
A string containing the metadata associated with the provided Nid.
​
A detailed explanation of the Nid can be found on the Numbers ID (Nid) page. In this example, you would replace YOUR_CAPTURE_TOKEN with your actual Capture token and NID_TO_FETCH with the Nid of the metadata you want to cat. More examples can be found below:
Python
Javascript
import requests
import json
​
# Define the API endpoint
url = "https://eoilb27dj3s5ncc.m.pipedream.net"
​
# Define the headers for the request
headers = {
"Content-Type": "application/json",
"Authorization": "token YOUR_CAPTURE_TOKEN" # Replace YOUR_CAPTURE_TOKEN with your own
}
​
# Define the parameters for the request
params = {"nid": NID_TO_FETCH} # Replace NID_TO_FETCH with the Nid of the metadata you want to retrieve
​
# Send the GET request to the API endpoint
response = requests.get(url, headers=headers, params=params)
​
# Check the response status code
if response.status_code != 200:
print(f"Error: {response.status_code} - {response.text}")
else:
# Parse the JSON response
json_data = response.json()
ipfs_data = json.loads(json_data["data"])
order_id = json.loads(json_data["order_id"])
print(ipfs_data.keys())
const axios = require('axios');
​
const url = 'https://eoilb27dj3s5ncc.m.pipedream.net';
const headers = {
'Content-Type': 'application/json',
Authorization: 'token YOUR_CAPTURE_TOKEN',
};
const params = { nid: 'NID_TO_FETCH' };
​
axios.get(url, { headers, params })
.then(response => {
const jsonData = response.data;
const ipfsData = JSON.parse(jsonData.data);
const orderID = JSON.parse(jsonData).order_id;
console.log(Object.keys(ipfsData));
})
.catch(error => {
console.log(`Error: ${error.response.status} - ${error.response.data}`);
});
​