Get Nid from AssetTree¶
This is a free API to help you retrieve the Nid (assetCid)
from AssetTree file. It requires either a fileURL
or input nid
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 instructions provided to create one.
API Endpoint: https://eoulu4xwyfomadg.m.pipedream.net
Cost: 0 NUM (free to use)
Method: POST
Description:
This is a free API to help you retrieve the Nid of any file.
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) // URL of your AssetTree file or
file (object) // uploading AssetTree file directly or
nid (string) // input Nid of your AssetTree file
One of the three above must be provided
Example 1 (direct file upload):
curl -F "file=@/tmp/my_asset_tree.json" \
-H "Authorization: token YOUR_CAPTURE_TOKEN" \
"https://eoulu4xwyfomadg.m.pipedream.net"
Example 2 (upload via URL)
curl -X POST "https://eoulu4xwyfomadg.m.pipedream.net" \
-H "Content-Type: application/json" \
-H "Authorization: token YOUR_CAPTURE_TOKEN" \
-d '{
"fileURL": AssetTree_URL
}'
Response:
{
"nid": string // assetCid found in the AssetTree
}
200: Cid/Nid retrieved 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/my_asset_tree.json
or AssetTree_URL
with the actual file on your filesystem. More examples can be found below:
{% tabs %} {% tab title="Python" %}
import requests
url = "https://eoulu4xwyfomadg.m.pipedream.net"
headers = {
"Content-Type": "application/json",
"Authorization": "token YOUR_CAPTURE_TOKEN"
}
data = {
"nid": "bafkreihzcudbwkb4vlnhsyfr545mrnswvpwojvmrqt4ej56zdnx43s4dym"
}
response = requests.post(url, headers=headers, json=data)
print(response.json())
{% tab title="Javascript" %}
const request = require("request");
const url = "https://eoulu4xwyfomadg.m.pipedream.net";
const headers = {
"Content-Type": "application/json",
"Authorization": "token YOUR_CAPTURE_TOKEN"
};
const data = {
"fileURL": FILE_URL,
"version": 1
};
request.post(
{
url,
headers,
json: data
},
function(error, response, body) {
console.log(body);
}
);