Trace a Product

Use this endpoint to perform a trace on a product. The starting point in the trace must be an asset owned by the blockchain address linked to the API key.



Fields/Parameter Value
api_key Your food ledger api key "blockchain address:secret key" assigned for the location receiving the product Required
gtin The globally unique item number of the product. Usually GTIN or UPC code. If tracing a shipment use "SHIPMENT". Required
lot The lot number of the asset being traced. Required
direction Direction of the trace. Values, "forward", "backward", and "both" are valid. Defaults to both. Optional
levels The maximum number of levels the trace will be performed. Default 5 Optional

Test it

Sample Code - PHP/Curl



//URL of the endpoint.
$url = '';

//Create an array of POST data to be sent to the endpoint.
$fields = array(
'auth_key' => $auth_key,
'gtin' => $gtin,
'lot' => $lot,
'direction' => $direction,
'levels' => $levels);

//url-ify the data for the POST
foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
rtrim($fields_string, '&');

//open connection
$ch = curl_init();

//set the url, number of POST vars, POST data
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_POST, count($fields));
curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);

//execute post
$result = curl_exec($ch);

//echo the result
echo $result;

//close connection