Skip to content

eansearch/csharp-barcode-lookup

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BarcodeLookup - A C# Library for GTIN, UPC, EAN and ISBN Lookup and Validation

BarcodeLookup is a C# library for performing EAN and ISBN barcode lookups using the EAN-Search.org API. This library allows developers to seamlessly integrate product and book barcode lookups, checksum verification, and related operations into their applications.

Features

  • EAN barcode lookup: Retrieve product names or detailed product information using EAN barcodes.
  • ISBN lookup: Fetch book titles using ISBN-10 or ISBN-13 barcodes.
  • Checksum verification: Validate the checksum of EAN barcodes.
  • Product search: Search for products by name or find similar product names.
  • Category search: Look up products within specific categories.
  • Barcode prefix search: Search for products based on barcode prefixes.
  • Issuing country lookup: Identify the issuing country of an EAN barcode.
  • Barcode image retrieval: Get a barcode image for a given EAN.

Getting Started

Prerequisites

Installation

The library is available as a NuGet package. Install it using the .NET CLI:

dotnet add package BarcodeLookup

Usage

Initialization

To use the library, create an instance of the BarcodeLookup class and provide your API token.

using EANSearch;

string token = Environment.GetEnvironmentVariable("EAN_SEARCH_API_TOKEN") ?? "";
BarcodeLookup lookup = new BarcodeLookup(token);

GTIN / EAN Lookup

Retrieve the product name for a given EAN barcode:

string? productName = lookup.GTINName("5099750442227");
Console.WriteLine(productName ?? "Product not found");

Retrieve full product information:

Dictionary<string, object>? product = lookup.GTIN("5099750442227");

if (product != null) {
    Console.WriteLine(product["name"] + " category " + product["categoryName"]);
} else {
    Console.WriteLine("Product not found");
}

ISBN Lookup

Fetch the book title for an ISBN:

string? bookTitle = lookup.ISBNName("1989726038");
Console.WriteLine(bookTitle ?? "Book not found");

Verify Checksum

Check if an EAN barcode is valid:

bool? isValid = lookup.VerifyChecksum("5099750442227");
Console.WriteLine("5099750442227 is " + (isValid.HasValue && isValid.Value ? "valid" : "invalid"));

Product Search

Search for products by name:

List<Dictionary<string, object>>? products = lookup.ProductSearch("Bananaboat", 0, 99);

foreach (var p in products ?? []){
    Console.WriteLine(p["ean"] + ": " + p["name"]);
}

Barcode Image Creation

Get the image of a barcode:

string? barcodeImage = lookup.BarcodeImage("5099750442227");
Console.WriteLine(barcodeImage ?? "Image not available");

Contributions are welcome! Feel free to submit a pull request or open an issue on our GitHub repository. License

This library is licensed under the MIT License. See the LICENSE file for details. Acknowledgments

This library uses the EAN-Search.org API. Please visit EAN-Search.org for more information.

About

A C# class for GTIN, UPC, EAN and ISBN name lookup and validation

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •  

Languages