Example GTIN with valid check-digit: 00666522900091
You sent us an image without/0 as check-digit, simply request your image as: https://han.brickinc.net/gtin/00666522900090.jpg
Since it's a national product, pass in a valid check-digit to get Brick's image: https://han.brickinc.net/gtin/00666522900091.jpg
NOTE The free API will watermark your image and has a limit of 10 requests per minute, with a burst of 5 requests.
To use your paid API, no limit or watermark. Simply md5
sign the GTIN with expires time, and provide in the query string similar to our php example below:
/**
* @param $baseUrl - non protected part of the URL including hostname, e.g. https://han.brickinc.net/gtin/
* @param $gtin - the gtin
* @param $secret - the shared secret
* @param $ttl - the number of seconds until this link expires
* @return string
*/
function buildSecureLink($baseUrl, $gtin, $secret, $ttl)
{
$expires = time() + $ttl;
$md5 = md5("$expires$gtin $secret", true);
$md5 = base64_encode($md5);
$md5 = strtr($md5, '+/', '-_');
$md5 = str_replace('=', '', $md5);
return $baseUrl . $gtin . '?md5=' . $md5 . '&expires=' . $expires;
}
$baseUrl = 'https://han.brickinc.net/gtin/';
echo buildSecureLink($baseUrl, $gtin, $secret, $ttl);
Example output: https://han.brickinc.net/gtin/00666522900090.jpg?md5=9qlN2DscJIME4d8U4zAG5w&expires=1589494411
Please contact us to get your API secret
for generating the md5
signature/query string.
Additionally, you can provide the width as w
and height as h
in the query string. Example: https://han.brickinc.net/gtin/00666522900090.jpg?md5=9qlN2DscJIME4d8U4zAG5w&expires=1589494411&w=300
When only width
is provided, the image will resize
to specified width
, while height
is resized proportionally. The system will perform a crop
operation when both width
and height
are provided.
Check-digit is required. You can pass in 0/anything if you do not know the check-digit. For national product, we will automatically calculate the check digit for you.
The API will also work for EAN-13 or EAN-12 as it will auto-append 0 to make a GTIN-14 lookup. Example: https://han.brickinc.net/gtin/666522900090.jpg