Skip to content

eansearch/lua-barcode-lookup

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 

Repository files navigation

BarcodeLookup

A Lua package or EAN, UPC, GTIN and ISBN name lookup and validation

To use the EAN-Search.org API, you need an API access token from https://www.ean-search.org/ean-database-api.html

For the example we store the API token in the environment variable EAN_SEARCH_API_TOKEN.

local barcodeLookup = BarcodeLookup:new(os.getenv("EAN_SEARCH_API_TOKEN"))

local product = barcodeLookup:barcodeLookup("5099750442227")
if (product.error) then
    print(product.error)
else
    print(product.name, product.categoryName)
end
local product = barcodeLookup:barcodeLookup("5099750442228")
if (product.error) then
    print(product.error)
else
    print(product.name, product.categoryName)
end

local productList = barcodeLookup:productSearch("iphone 16")
local i = 1
while productList[i] ~= nil do
    print(productList[i].ean, productList[i].name, productList[i].categoryName)
    i = i + 1
end

print (barcodeLookup:verifyChecksum("5099750442227"))
print (barcodeLookup:verifyChecksum("5099750442228"))

print (barcodeLookup:issuingCountryLookup("5099750442227"))

print ("<img src='data:image/png;base64," .. barcodeLookup:barcodeImage("5099750442227", 300, 200)) .. "' width='300' height='200'>")

About

Lua package to for EAN, UPC and ISBN name lookup and validation

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages