Retrieve an asset from the blockchain.

Use this endpoint to receive an asset from the blockchain related to your blockchain address.

Endpoint

https://tracapi.com/api.v2/get

Fields/Parameters

Fields/Parameter Value
api_key Your api key "blockchain address:secret key" assigned for the location where the asset is located. Required
gtin The global trade identification number of the asset. Required
lot The lot number of the asset. If left blank the asset class is returned. Optional
batch (0 or 1). If 0 returns the asset class or asset batch. If 1, returns the asset batch at the current location. Default 1

Test it

Sample Code - PHP/Curl

<?php

$auth_key=$_POST['auth_key'];
$gtin=$_POST['gtin'];
$lot=$_POST['lot'];
$batch=$_POST['batch'];

//URL of the endpoint.
$url = 'https://tracapi.com/api.v2/get/';

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

//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);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);

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

//echo the result
echo $result;

//close connection
curl_close($ch);
?>