SDK
SDK Overview
Client libraries for TypeScript and Python that simplify EUlabel API integration.
The EUlabel SDK provides typed, ergonomic client libraries that handle authentication, request formatting, retries, and error handling so you interact with a clean interface rather than raw HTTP.
Available SDKs
| Language | Package | Install |
|---|---|---|
| TypeScript / JavaScript | @eulabel/sdk | npm install @eulabel/sdk |
| Python | eulabel | pip install eulabel |
What the SDK handles
| Concern | Without SDK | With SDK |
|---|---|---|
| Authentication | Manual token management, header formatting | Automatic, set once |
| API requests | Raw HTTP calls, URL construction | Typed methods with parameter validation |
| Error handling | Parse error responses, implement retries | Built-in retry with exponential backoff, typed errors |
| Versioning | Track API version changes manually | SDK version pinned to API version |
Quick example (TypeScript)
import { EUlabel } from '@eulabel/sdk';
const client = new EUlabel({ apiKey: 'sk_live_...' });
const product = await client.products.create({
name: 'Quinta da Bacalhoa Reserva 2022',
category: 'wine',
brand: 'Bacalhoa',
gtin: '5601234567890',
});
const passport = await client.passports.create({
productId: product.productId,
data: {
productType: 'wine',
ingredients: ['Grapes', 'Sulphites'],
nutrition: { energyKj: 351, energyKcal: 84, fatG: 0, saturatedFatG: 0, carbohydratesG: 1, sugarsG: 0.1, proteinG: 0, saltG: 0, alcoholG: 11.1 },
allergens: { containsSulphites: true, containsEgg: false, containsFish: false, containsMilk: false },
origin: { country: 'PT', region: 'Setubal' },
producers: [{ name: 'Bacalhoa', role: 'producer', country: 'PT' }],
},
});Helper functions
| Helper | Purpose |
|---|---|
client.products.getPassport(id) | Retrieve a product's passport |
client.analytics.getProduct(id, opts) | Get scan analytics with date filters |
client.webhooks.verify(payload, sig, secret) | Verify an inbound webhook signature |
client.passports.validate(data) | Validate passport data before submission |