Getting started using our our barcode lookup API

Our barcode lookup API allows you to easily look up EAN, GTIN or UPC barcodes in our database or to search by keyword or product name to find products and the corresponding EANs.

It can be used in almost any programming or scripting language. Below you will find some examples in different languages. Just pick the tab with the language you prefer for an example. We also provide libraries for many programming languages. Our API manual includes many more examples.

Simply replace the access token "abcdef" in all examples with your own token after opening an account.

Lookup an EAN barcode

Use the barcode lookup API function and pass your 13-digit EAN / GTIN in the ean parameter. If you want to search for a 12-digit UPC, pass it in the upc parameter. 10-digit ISBN go into the isbn parameter.


$ curl "https://api.ean-search.org/api?token=abcdef&op=barcode-lookup&format=json&ean=5099750442227"


import java.io.*;
import java.net.*;
import java.util.regex.*;

class EAN_API_Demo {

	public static void main (String args[]) {
		String apiToken = "abcdef"; // your private API access token
		String ean = "5099750442227"; // search for this EAN code
		String productName = "unknown";
		try {
			URL url= new URL("https://api.ean-search.org/api?token="
				+ apiToken + "&op=barcode-lookup&ean=" + ean);
			InputStream is = url.openStream();
			int ptr = 0;
			StringBuffer apiResult = new StringBuffer();
			while ((ptr = is.read()) != -1) {
    				apiResult.append((char)ptr);
			}
			// you can use a real XML parser,
			// but a regular expression is much faster
			Pattern p = Pattern.compile("(.*)");
    			Matcher m = p.matcher(apiResult);
    			if (m.find()) {
      			productName = m.group(1);
			}
		} catch ( Exception ex ) {
    			ex.printStackTrace();
		}
		System.out.println("EAN " + ean + " => " + productName);
	}
}


<?php
$ean = '5099750442227';
$token = 'abcdef';
$xml = file_get_contents("https://api.ean-search.org/api?"
	. "op=barcode-lookup&token=$token&ean=$ean");
$response = new SimpleXMLElement($xml);
$productName = $response->product->name;
if ($response == "Barcode not found") {
	echo ("EAN $ean no product found\n");
} else {
	$productName = $response->product->name;
	echo ("EAN $ean => $productName\n");
}


$ pip3 install eansearch # Python 3


from eansearch import EANSearch

ean = "5099750442227"
apiToken = "abcdef"

lookup = EANSearch(apiToken)

name = lookup.barcodeLookup(ean)
print(ean, " is ", name)


$ cargo add eansearch


let eansearch = EANSearch::new("abcdef");
let product = eansearch.barcode_lookup(5099750442227, Some(1));
let product = product.unwrap(); // unwrap result
let product = product.unwrap();
println!("EAN {} is {}", product.ean, product.name);


package main

import (
    eansearch "github.com/eansearch/go-ean-search"
    "fmt"
)

func main() {
    eansearch.SetToken("abcdef")
    ean := "5099750442227"
    products, err := eansearch.BarcodeLookup(ean, eansearch.English)
    fmt.Println("EAN:", products[0].EAN)
    fmt.Println("Name:", products[0].Name)
}


Please copy the macro from the API manual (chapter 3) in your account.

 Result

[
  {
    "ean":"5099750442227",
    "name":"Michael Jackson, Thriller",
    "categoryId":"15",
    "categoryName":"Music",
    "googleCategoryId":"855",
    "issuingCountry":"UK"
  }
]

Search by product name

To search for a product name or keyword, use the product search API function and pass the search terms in the name parameter. Make sure to url encode your search terms, eg. replace spaces with a '+' character so they are passed safely to our API.

This fulltext search will find all matching products and the associated barcode. Unlike the free website, it is not limited to 50 results. Use the page parameter to page through large result sets.

 Result

{
  "page":0,
  "moreproducts":false,
  "totalproducts":2,
  "productlist": [
    {
      "ean":"0042286275123",
      "name":"Stephan Remmler, Bananaboat",
      "categoryId":"15",
      "categoryName":"Music",
      "issuingCountry":"US"
    },
    {
      "ean":"4011222328366",
      "name":"Harry Belafonte: Bananaboat",
      "categoryId":"15",
      "categoryName":"Music",
      "issuingCountry":"DE"
    }
  ]
}

Search by EAN prefix


$ curl "https://api.ean-search.org/api?token=abcdef&op=barcode-prefix-search&format=json&prefix=0885909"


<?php
$prefix = '0885909';
$token = 'abcdef';
$language = 99; // any language

$page = 0;
do {
    $xml = file_get_contents("https://api.ean-search.org/api?
        . op=barcode-prefix-search&token=$token&prefix=$prefix&
        . page=$page&language=$language");
    $response = new SimpleXMLElement($xml);
    foreach ($response->xpath('//product') as $product) {
        echo "$product->ean,\"$product->name\"\n";
    }
    $page++;
} while ($response->xpath('/BarcodePrefixResponse')[0]['moreproducts'] > 0);


$ pip3 install eansearch # Python 3


from eansearch import EANSearch

apiToken = "abcdef"

eansearch = EANSearch(apiToken)
eanList = eansearch.barcodePrefixSearch('0885909');
for product in eanList:
	print(product["ean"], " is ", product["name"].encode("utf-8"))


package main

import (
    eansearch "github.com/eansearch/go-ean-search"
    "fmt"
)

func main() {
    eansearch.SetToken("abcdef")
    ean := "5099750442227"
    products, more, err := eansearch.BarcodePrefixSearch("40620999", 0, eansearch.AnyLanguage)
    for _, p := range products {
        fmt.Println("EAN:", p.EAN)
        fmt.Println("Name:", p.Name)
    }
}


$ cargo add eansearch


let eansearch = EANSearch::new("abcdef");
let product_list = eansearch.barcode_prefix_search(509975044, Some(1), None);
for p in &product_list.unwrap() {
	println!("EAN {:0>13} is {} ({})", p.ean, p.name, p.category_name);
}

 Result

{
  "page":0,
  "moreproducts":true,
  "productlist": [
    {
      "ean":"0885909000173",
      "name":"Apple iPhone 4 8GB Svart Telenor",
      "categoryId":"25",
      "categoryName":"Electronics",
      "issuingCountry":"US"
    },
    {
      "ean":"0885909000180",
      "name":"Apple iPhone 4 8GB Vit Telenor",
      "categoryId":"25",
      "categoryName":"Electronics",
      "issuingCountry":"US"
    },
...
}

Wait there is more...

With our API you can also

All these API operations are described in more detail in the API manual and we provide examples in many programming or scripting languages.

To use any of these examples, you have to create an account.

/ / / / / / /
   Login / Register
Try it now!