Recent blog posts

Google category IDs now in API results

Introducing Our MCP Server for AI Integration

DeepSeek AI text generation with product data

New API Call: Similar-Product-Search

Doing GTIN Lookup in JavaScript

Using the EAN-Search API with ChatGPT

Why are some EAN numbers "invalid"?

Python, PHP and Go libraries updated

How do GTIN, EAN & UPC codes relate?

Using VBA to look up EAN barcodes

Product names in different languages

How to search for product categories

Introducing the GraphQL API (Beta)

EAN Prefix Search

EAN prefix 2 and 8-digit EANs

Using the EAN-Search API with ChatGPT

3 Jan 2024

AI and ChatGPT are currently the most talked about technologies. But combining AI with your own, factual data is what will make the difference in the future.

An easy way to integrate our product database with ChatGPT is to query the EAN-Search API, build ChatGPT prompts with the data, and then run those prompts with the ChatGPT API.

So, let's assume you are scanning barcodes and you want to generate short articles about the products, using the template "Please write a 4 sentence description pointing out the flaws of the product 'XYZ'" (or point out the good aspects, depending on your use case).

Here is an example of how to do this in Python. I assume that you have installed both the EAN-Search API and OpenAI libraries, using "pip install eansearch openai" and put the API keys into environment variables.

import os
from eansearch import EANSearch
from openai import OpenAI

# quickly set up both APIs
eansearch = EANSearch(os.environ.get("EAN_SEARCH_API_KEY"))
chatgpt = OpenAI(api_key = os.environ.get("OPENAI_API_KEY"))

ean = "0194253382829" # this is the EAN barcode number that you scan
                      # an Apple iPhone 14 Pro Max in this example

# let's get the product data from ean-search.org
product = eansearch.barcodeSearch(ean, 1)

# now send the prompt to ChatGPT
response = chatgpt.chat.completions.create(
    model = "gpt-3.5-turbo",
    messages = [
        {
            "role": "user",
            "content": "Please write a 4 sentence description "
				+ "pointing out the flaws of the product '"
                + product["name"] + "' from the product category '"
                + product["categoryName"] + "'"
        } 
    ]
)

# now print out all your product data with the generated description
print ("Products > " + product["categoryName"])
print ("<h1>" + product["name"] + " (EAN " + ean + ")</h1>")
print (response.choices[0].message.content)

This example is aimed at keeping things simple. A more advanced way of integrating the two systems would be to build a CustomGPT and include the EAN-Search API as a data source.

Please keep in mind that ChatGPT is good, but may also generate nonsense sometimes. So you better check what it generates for you and fine-tune your prompts accordingly.

You could also let ChatGPT generate an article combining and comparing the data of multiple products, contrasting them, making lists...

The possibilities seem endless! If you come up with other great ideas on how to use our data with AI tools, please let us know!


You might also be interested in this:

UPC barcode lookup manually


Why are some EAN numbers "invalid"? >


/ / / / / / /
   Login / Register