Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/eansearch/go-ean-search
A Go module for EAN, GTIN and ISBN name lookup and validation using the API on https://www.ean-search.org
https://github.com/eansearch/go-ean-search
barcode ean ean13 gtin gtin-codes isbn isbn-13 upc
Last synced: 1 day ago
JSON representation
A Go module for EAN, GTIN and ISBN name lookup and validation using the API on https://www.ean-search.org
- Host: GitHub
- URL: https://github.com/eansearch/go-ean-search
- Owner: eansearch
- License: mit
- Created: 2021-03-01T15:15:38.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-04-18T20:00:37.000Z (7 months ago)
- Last Synced: 2024-08-16T09:44:05.708Z (3 months ago)
- Topics: barcode, ean, ean13, gtin, gtin-codes, isbn, isbn-13, upc
- Language: Go
- Homepage: https://www.ean-search.org/ean-database-api.html
- Size: 26.4 KB
- Stars: 3
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# go-ean-search
A Go module for EAN, GTIN and ISBN name lookup and validation using the API on https://www.ean-search.org
```go
package mainimport (
eansearch "github.com/eansearch/go-ean-search"
"fmt"
)func printProduct(p eansearch.Product) {
fmt.Println("EAN:\t", p.Ean)
fmt.Println("\t Name:", p.Name)
fmt.Println("\t CategoryID:", p.CategoryID)
fmt.Println("\t CategoryName:", p.CategoryName)
fmt.Println("\t IssuingCountry:", p.IssuingCountry)
}func main() {
var products []eansearch.Product
var more bool
var err error
var country string// get an API token at https://www.ean-search.org/ean-database-api.html
token := "abcdefg"
eansearch.SetToken(token)products, err = eansearch.BarcodeLookup("5099750442227", eansearch.English)
if err != nil {
fmt.Println(err)
} else if len(products) == 0 {
fmt.Println("No results found")
} else {
printProduct(products[0])
}products, err = eansearch.ISBNLookup("1119578884")
if err != nil {
fmt.Println(err)
} else if len(products) == 0 {
fmt.Println("No results found")
} else {
printProduct(products[0])
}products, more, err = eansearch.ProductSearch("esprit pullover", 0, eansearch.English)
if err != nil {
fmt.Println(err)
} else if len(products) == 0 {
fmt.Println("No results found")
} else {
for _, p := range products {
printProduct(p)
}
if more {
fmt.Println("More results available")
}
}products, more, err = eansearch.BarcodePrefixSearch("40620999", 0, eansearch.AnyLanguage)
if err != nil {
fmt.Println(err)
} else if len(products) == 0 {
fmt.Println("No results found")
} else {
for _, p := range products {
printProduct(p)
}
if more {
fmt.Println("More results available")
}
}ean := "5099750442227"
country, err = eansearch.IssuingCountryLookup(ean)if err != nil {
fmt.Println(err)
} else {
fmt.Printf("EAN %s was issued in %s\n", ean, country)
}ean = "5099750442228"
valid, err = eansearch.VerifyChecksum(ean)if err != nil {
fmt.Println(err)
} else {
if (valid) {
fmt.Printf("EAN %s is VALID\n", ean)
} else {
fmt.Printf("EAN %s is INVALID\n", ean)
}
}ean = "5099750442227"
image, err = eansearch.BarcodeImage(ean)if err != nil {
fmt.Println(err)
} else {
//fmt.Print("Content-Type: image/png\n\n")
//fmt.Printf("%s", image)
_ = image
fmt.Println("Barcode image received")
}}