Your requests to the Digit-Eyes API must be signed. The signature
is different for every UPC/EAN request and needs to be recomputed for each UPC/EAN.
This is because the signature is an encrypted version of the UPC or EAN code that is
dependent on a shared secret -- your authorization key (in your case, this is the value "")
The signature is created by combining the authorization key with each UPC in an SHA-1 hash,
converting the signature to base 64 and sending it to the API. The exact process for
creating a signature depends on your programming language,
but here is a general flow:
If your language does not have a native SHA-1 encryption function, instantiate
the SHA-1 utility for your language;
Add the authorization key to the SHA-1 object;
Add the UPC/EAN code to the SHA-1 object;
Obtain the signature (a binary hash of the authorization key + the UPC/EAN code)
from the SHA-1 object. Then, using the binary signature:
Convert the binary signature to base 64;
Pad the signature (now in base 64) to 28 bytes using
the equals sign ("=").
Submit the signed request to the API. Please note that the authorization key is
NOT included in the list -- it is the shared secret and stays secret.
You will be submitting at least the following fields.
Your application key in the format "app_key="
The UPC/EAN code for which you want information in
the format "upcCode=xxxxxxxxxxxxx"where xxxxxxxxxxxxx
is the code for which you want information
The computed signature for the UPC/EAN in the format
"signature=yyyyyyyyyyyyyyyyyyyyyyyyyyy"
The preferred language of retrieval in the format
"language=xx" where "xx" is the two-character ISO language code.
The default language will be "en"
The names of the data fields that you want the API to return
or "all". Note that there are special charges for some
fields like images or structured categories, so do not
request these if you do not need them.
Examples are shown below and you can use the demo at http://digit-eyes.com/gtin/
to validate your signature creation results.
Objective C Example
To create a signature, we provide a category in objective C that
takes a string and a key and returns the encoded value where UPCCode
is the UPC or EAN code and AuthKey is your authorization key:
/// Product code that is to be used in the query is UpcCode
/// Hash that is to be used to create the siguature is AuthKey
private string GetDigitEyesVerificationCode(string UpcCode)
{
var hmac = new HMACSHA1(Encoding.UTF8.GetBytes(AuthKey));
var m = hmac.ComputeHash(Encoding.UTF8.GetBytes(UpcCode));
return Convert.ToBase64String(m);
}
Private Function GetDigitEyesVerificationCode(UpcCode As String)
As String
Dim hmac = New HMACSHA1(Encoding.UTF8.GetBytes(AuthKey))
Dim m = hmac.ComputeHash(Encoding.UTF8.GetBytes(UpcCode))
Return Convert.ToBase64String(m)
End Function