The prerequisite of the API includes acquiring the Capture Token following the instructions and registration of the asset following the initial asset registration instructions.
API Endpoint: https://api.numbersprotocol.io/api/v3/assets/NID/c2pa/Cost:0NUM (free to use)Method:POSTAuthentication:This API requires a valid token for Authorization.The token should be passed in the headers of the request usingthe following format:"Authorization: token YOUR_CAPTURE_TOKEN"Pathparameter (required):nid (string):NidoftheassettodownloadExamples:curl -XPOSThttps://api.numbersprotocol.io/api/v3/assets/NID/c2pa/ \ -H"Content-Type: application/json" \ -H"Authorization: token YOUR_CAPTURE_TOKEN"Response:{"url":string,// URL for downloading the C2PA asset. "cid": string // cid of the C2PA asset. Note that because of the nature of C2PA injection, the cid will not be the same as the asset nid.
}
import requestsimport json# Define the API endpointurl ="https://api.numbersprotocol.io/api/v3/assets/{nid}/c2pa/"# Define the headers for the requestheaders ={"Content-Type":"application/json","Authorization":"token YOUR_CAPTURE_TOKEN"# Replace YOUR_CAPTURE_TOKEN with your own}# Define the path parameters for the requesturl = url.format(nid=NID)# Replace NID with the Nid of the asset you want to create and download C2PA file# Send the POST request to the API endpointresponse = requests.post(url, headers=headers)# Check the response status codeif response.status_code !=200:print(f"Error: {response.status_code} - {response.text}")else:# Parse the JSON response json_data = response.json() download_url = json_data["url"]print(download_url)
constrequest=require("request");consturl="https://api.numbersprotocol.io/api/v3/assets/{nid}/c2pa/"; // Replace the {nid} with the actual nidconstheaders= {"Content-Type":"application/json","Authorization":"token YOUR_CAPTURE_TOKEN"};request.post( { url, headers },function(error, response, body) {console.log(body); });