A C++ class for EAN, GTIN, UPC and ISBN lookup and validation using the API at ean-search.org.
Core implementation:
- Interface: eansearch.hpp — class and data structures
- Implementation: eansearch.cpp
- Example usage: see example.cpp
- Build on Linux: Makefile
- License: MIT
Primary classes and types
EANSearch— main API classProduct— basic product infoProductFull— product with added Google product category (inheritsProduct)ProductList— typedef for product lists
Main public methods on EANSearch
EANSearch::BarcodeLookup
search by a single EAN, GTIN, UPC or ISBN-13 codeEANSearch::IsbnLookup
search by ISBN code (ISBN-10)EANSearch::VerifyChecksum
verify whether the checksum on any EAN, GTIN, UPC or ISBN-13 code is validEANSearch::ProductSearch
search the product database by product name (exact search)EANSearch::SimilarProductSearch
search the product database for similar product namesEANSearch::CategorySearch
search the product database by product name, restricted by product categoryEANSearch::BarcodePrefixSearch
search by the first digits of a barcode (prefix)EANSearch::IssuingCountryLookup
check the issuing country of any EAN, GTIN, UPC or ISBN-13 codeEANSearch::BarcodeImage
generate a PNG image of the barcode (base64 encoded)
...
auto * eansearch = new EANSearch(token);
ProductFull * p = eansearch->BarcodeLookup("5099750442227");
if (p) {
cout << ean << " is " << p->name << endl;
}
...
ProductList * pl = eansearch->ProductSearch("Bananaboat");
...See example.cpp for more details on all API functions.
To compile, you need Boost and OpenSSL installed.
On Debian and Ubuntu:
sudo apt install libssl-dev boost-devOn Windows with vcpgk
vcpkg install openssl boost --triplet x32-windowsBuild and run the example (Linux):
c++ example.o -o example -lssl -lcrypto
./examplePlease note that the library is "header-only", so all code is included in the one heade file, but you will have to link with OpenSSL (for the https support).
Export your API token as an environment variable:
export EAN_SEARCH_API_TOKEN=your_token_here