SDKs
Python SDK
Install and use the eulabel Python package.
At a glance
- Install
eulabeland initialize a client with an API key. - Use typed methods for products, passports, analytics.
- Catch
EUlabelErrorfor consistent error handling.
Keep API keys on the server. Do not embed production keys in client-side apps.
Installation
pip install eulabelInitialization
from eulabel import EUlabel
client = EUlabel(api_key="sk_live_...")
<Callout type="info">
Prefer environment variables in production. For example: `EULABEL_API_KEY=sk_live_...`
</Callout>Use sk_test_... in the sandbox and sk_live_... in production. Prefer environment variables and a secrets manager.
Products
Create a product
product = client.products.create(
name="Quinta do Crasto Douro Red 2021",
category="wine",
brand="Quinta do Crasto",
gtin="5601234567890",
)
print(product.product_id)
print(product.qr_code_url)List products
result = client.products.list()
for product in result.products:
print(product.name, product.gtin)Passports
Create a passport
passport = client.passports.create(
product_id="a1b2c3d4-...",
data={
"product_type": "wine",
"colour": "red",
"vintage": 2021,
"ingredients": ["Grapes (Touriga Nacional)", "Sulphur Dioxide"],
"nutrition": {
"energy_kj": 351,
"energy_kcal": 84,
"fat_g": 0,
"saturated_fat_g": 0,
"carbohydrates_g": 0.6,
"sugars_g": 0.3,
"protein_g": 0.1,
"salt_g": 0,
"alcohol_g": 13.5,
},
"allergens": {
"contains_sulphites": True,
"contains_egg": False,
"contains_fish": False,
"contains_milk": False,
},
"origin": {"country": "PT", "region": "Douro", "designation": "Douro DOC"},
"producers": [{"name": "Quinta do Crasto", "role": "producer", "country": "PT"}],
},
)Retrieve a passport
passport = client.products.get_passport("a1b2c3d4-...")Analytics
analytics = client.analytics.get_product(
"a1b2c3d4-...",
start="2026-01-01",
end="2026-03-14",
)
print(f"Total scans: {analytics.total_scans}")
print(f"Countries: {analytics.unique_countries}")Error handling
from eulabel import EUlabel, EUlabelError
try:
client.products.create(name="Test", category="wine", brand="Test", gtin="invalid")
except EUlabelError as e:
print(e.type) # "validation_error"
print(e.message) # "Invalid GTIN check digit"
print(e.param) # "gtin"