### Get All Products Request Example (Bash) Source: https://eulabel.eu/docs/llms-full.txt Example of a cURL request to retrieve a list of all products. Includes pagination parameters 'limit' and 'offset'. Authentication is handled via the 'Authorization' header. ```bash curl -X GET "https://api.eulabel.eu/v1/products" \ -H "Authorization: Bearer sk_live_..." ``` -------------------------------- ### Install EUlabel SDK Source: https://eulabel.eu/docs/llms-full.txt Install the official EUlabel SDK package using Yarn. ```bash yarn add @eulabel/sdk ``` -------------------------------- ### Install EUlabel SDK Source: https://eulabel.eu/docs/documentation/sdks/python Installs the required Python package via pip. ```bash pip install eulabel ``` -------------------------------- ### API Base URL and Authentication Example Source: https://eulabel.eu/docs/llms-full.txt Demonstrates how to construct a request to the EUlabel API, including the base URL and the required 'Authorization' header for authentication. This example uses `curl` to fetch product data. ```bash curl https://api.eulabel.eu/v1/products \ -H "Authorization: Bearer sk_test_..." ``` -------------------------------- ### Product Resolution Examples Source: https://eulabel.eu/docs/llms-full.txt Examples of how to test the EUlabel resolver using curl, demonstrating default redirects, linkset discovery, specific link type requests, and Accept header negotiation. ```APIDOC ## Testing the EUlabel Resolver with curl ### Description These examples demonstrate various ways to interact with the EUlabel resolver using the `curl` command-line tool. ### Method GET ### Endpoint `https://eulabel.eu/01/{gtin}` (and variations with query parameters) ### Parameters #### Path Parameters - **gtin** (string) - The Global Trade Item Number of the product. #### Query Parameters - **linkType** (string) - Specifies the desired type of link to resolve (e.g., `linkset`, `gs1:pip`). ### Request Examples 1. **Default redirect (consumer view):** ```bash curl -I "https://eulabel.eu/01/05601234567890" ``` 2. **Linkset discovery:** ```bash curl "https://eulabel.eu/01/05601234567890?linkType=linkset" ``` 3. **Specific link type (e.g., gs1:pip):** ```bash curl -I "https://eulabel.eu/01/05601234567890?linkType=gs1:pip" ``` 4. **Accept header negotiation (requesting linkset+json):** ```bash curl -I "https://eulabel.eu/01/05601234567890" \ -H "Accept: application/linkset+json" ``` ### Response #### Success Response (307 Temporary Redirect) - The resolver typically returns an `HTTP 307 Temporary Redirect` status code on successful resolution, directing the client to the actual resource. - The `Location` header in the response contains the resolved URL. #### Error Response (e.g., 404 Not Found) - If the GTIN is not found or an error occurs, an appropriate HTTP error code will be returned. #### Note on Response Codes - A `200 OK` response from the resolver itself usually indicates an error or a specific response like a linkset, not a standard product resolution. - Ensure your HTTP client correctly handles `307 Temporary Redirect` and does not cache it permanently. ``` -------------------------------- ### Get Product by ID Request Example (Bash) Source: https://eulabel.eu/docs/llms-full.txt Example of a cURL request to retrieve a single product using its unique identifier. The productId is included in the URL path. ```bash curl -X GET "https://api.eulabel.eu/v1/products/{productId}" \ -H "Authorization: Bearer sk_live_..." ``` -------------------------------- ### GET /v1/analytics/product/{id} Source: https://eulabel.eu/docs/knowledge-base/examples/wine-label-end-to-end Retrieves scan analytics for a specific product to monitor consumer engagement. ```APIDOC ## GET /v1/analytics/product/{id} ### Description Fetches scan data for a product starting from a specified date. ### Method GET ### Endpoint https://api.eulabel.eu/v1/analytics/product/{productId} ### Parameters #### Path Parameters - **productId** (string) - Required - The unique identifier of the product. #### Query Parameters - **start** (string) - Required - The start date for the analytics report (YYYY-MM-DD). ### Response #### Success Response (200) - **analyticsData** (object) - Scan statistics for the requested period. ``` -------------------------------- ### Install EUlabel SDK Source: https://eulabel.eu/docs/documentation/sdks/typescript Commands to install the @eulabel/sdk package using common Node.js package managers. ```npm npm install @eulabel/sdk ``` ```pnpm pnpm add @eulabel/sdk ``` ```yarn yarn add @eulabel/sdk ``` -------------------------------- ### Curl Example for Machine-Readable Linkset Source: https://eulabel.eu/docs/knowledge-base/best-practices/multi-audience-design This command-line example uses `curl` to fetch the HTTP headers for a machine-readable linkset from the EU Label resolver. It specifically requests the linkset containing all available links for a given product identified by its GTIN. This is useful for discovering all possible views or data endpoints for a product. ```bash curl -I "https://eulabel.eu/01/05601234567890?linkType=gs1:sustainabilityInfo" # Machine-readable linkset (all available links) ``` -------------------------------- ### POST /v1/products Source: https://eulabel.eu/docs/knowledge-base/examples/wine-label-end-to-end Creates a new product entry in the EULabel system to initiate the passport creation process. ```APIDOC ## POST /v1/products ### Description Creates a new product record. This is the first step in the wine labeling workflow. ### Method POST ### Endpoint https://api.eulabel.eu/v1/products ### Request Body - **name** (string) - Required - The name of the wine product. - **category** (string) - Required - The product category (e.g., "wine"). - **brand** (string) - Required - The brand name. - **gtin** (string) - Required - The Global Trade Item Number. ### Request Example { "name": "Quinta do Crasto Douro Red 2021", "category": "wine", "brand": "Quinta do Crasto", "gtin": "5601234567890" } ### Response #### Success Response (200) - **productId** (string) - Unique identifier for the product. - **qrCodeUrl** (string) - The URL for the generated QR code. - **createdAt** (string) - Timestamp of creation. #### Response Example { "productId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890", "qrCodeUrl": "https://eulabel.eu/01/05601234567890", "createdAt": "2026-03-20T12:44:02.408Z" } ``` -------------------------------- ### Example Wine Passport in JSON-LD Source: https://eulabel.eu/docs/llms-full.txt This JSON-LD example demonstrates the structure of a wine product passport, including general product information, ingredients, allergens, and nutrition. It uses schema.org and GS1 Web Vocabulary for semantic richness, making it machine-readable and interoperable. ```json { "@context": ["https://schema.org", "https://www.gs1.org/voc/"], "@type": "Product", "name": "Quinta dos Carvalhais Alfrocheiro 2019", "gtin": "05601012012200", "brand": { "@type": "Brand", "name": "Quinta dos Carvalhais" }, "countryOfOrigin": { "@type": "Country", "name": "Portugal" }, "hasIngredientList": [ { "@type": "gs1:FoodBeverageTobaccoIngredientDetails", "ingredientName": "Grapes (Alfrocheiro)", "ingredientContentPercentage": 99.986 }, { "@type": "gs1:FoodBeverageTobaccoIngredientDetails", "ingredientName": "Sulphites", "ingredientContentPercentage": 0.014 } ], "hasAllergen": [ { "@type": "gs1:AllergenDetails", "allergenType": "https://gs1.org/voc/AllergenTypeCode-AS", "allergenLevelOfContainment": "CONTAINS" } ], "nutritionInformation": { "@type": "NutritionInformation", "servingSize": "100 mL", "calories": "84 kcal", "fatContent": "0 g", "carbohydrateContent": "1 g", "sugarContent": "0.1 g", "proteinContent": "0 g", "sodiumContent": "0 g" } } ``` -------------------------------- ### GET /products Source: https://eulabel.eu/docs/api-reference Retrieve a paginated list of products associated with the authenticated account. ```APIDOC ## GET /products ### Description Returns a list of products. Supports pagination using limit and offset parameters. ### Method GET ### Endpoint https://api.eulabel.eu/v1/products ### Parameters #### Query Parameters - **limit** (integer) - Optional - Maximum items to return (default: 20, max: 100) - **offset** (integer) - Optional - Number of items to skip (default: 0) ### Request Example GET /v1/products?limit=20&offset=0 ### Response #### Success Response (200) - **data** (array) - List of product objects - **pagination** (object) - Metadata containing total, limit, and offset #### Response Example { "data": [], "pagination": { "total": 142, "limit": 20, "offset": 0 } } ``` -------------------------------- ### GET /v1/products Source: https://eulabel.eu/docs/llms-full.txt Retrieves a list of products. Authentication is required. ```APIDOC ## GET /v1/products ### Description Retrieves a list of products. Authentication is required. ### Method GET ### Endpoint https://api.eulabel.eu/v1/products ### Parameters #### Query Parameters (No specific query parameters are detailed in the provided text, but typically used for filtering, pagination, etc.) #### Request Body None ### Response #### Success Response (200) - **products** (array) - A list of product objects. - Each product object may contain fields like `productId`, `name`, `category`, `brand`, `gtin`. #### Response Example ```json { "products": [ { "productId": "prod_12345abcde", "name": "Quinta do Crasto Douro Red 2021", "category": "wine", "brand": "Quinta do Crasto", "gtin": "5601234567890" } ] } ``` ``` -------------------------------- ### POST /v1/products Source: https://eulabel.eu/docs/documentation/get-started/quickstart Creates a new product entry in the EUlabel system. Requires basic product information including name, category, brand, and GTIN. ```APIDOC ## POST /v1/products ### Description Creates a new product record. Every product requires a name, category, brand, and a valid GTIN. ### Method POST ### Endpoint https://api.eulabel.eu/v1/products ### Request Body - **name** (string) - Required - The name of the product - **category** (string) - Required - The product category (e.g., "wine") - **brand** (string) - Required - The brand name - **gtin** (string) - Required - Global Trade Item Number ### Request Example { "name": "Quinta do Crasto Douro Red 2021", "category": "wine", "brand": "Quinta do Crasto", "gtin": "5601234567890" } ### Response #### Success Response (201/200) - **productId** (string) - Unique identifier for the product - **qrCodeUrl** (string) - URL for the product's QR code - **createdAt** (string) - ISO timestamp of creation #### Response Example { "productId": "a1b2c3d4-...", "qrCodeUrl": "https://eulabel.eu/01/05601234567890", "createdAt": "2026-03-20T17:44:04.491Z" } ``` -------------------------------- ### Get Product Passport Data - API Request Example Source: https://eulabel.eu/docs/api-reference/endpoints/passports Example of how to make a GET request to retrieve the full structured passport data for a product. Requires a valid API key for authorization and specifies the product ID in the URL path. The 'Accept' header can be used to request JSON-LD format. ```bash curl -X GET "https://api.eulabel.eu/v1/products/{productId}/passport" \ -H "Authorization: Bearer sk_live_..." ``` -------------------------------- ### Create Product using API (cURL, JavaScript, Python) Source: https://eulabel.eu/docs/documentation/get-started/quickstart This snippet demonstrates how to create a new product using the EU Label API. It requires product details such as name, category, brand, and GTIN. The API key is used for authentication. The response includes a unique productId. ```bash export EULABEL_API_KEY="sk_test_..." curl -X POST https://api.eulabel.eu/v1/products \ -H "Authorization: Bearer $EULABEL_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "name": "Quinta do Crasto Douro Red 2021", "category": "wine", "brand": "Quinta do Crasto", "gtin": "5601234567890" }' ``` ```javascript const EULABEL_API_KEY = process.env.EULABEL_API_KEY; const response = await fetch('https://api.eulabel.eu/v1/products', { method: 'POST', headers: { 'Authorization': `Bearer ${EULABEL_API_KEY}`, 'Content-Type': 'application/json', }, body: JSON.stringify({ name: 'Quinta do Crasto Douro Red 2021', category: 'wine', brand: 'Quinta do Crasto', gtin: '5601234567890', }), }); if (!response.ok) { const error = await response.json(); throw new Error(`${error.error.code}: ${error.error.message}`); } const product = await response.json(); console.log(product.productId); ``` ```python import requests EULABEL_API_KEY = "sk_test_..." response = requests.post( "https://api.eulabel.eu/v1/products", headers={"Authorization": f"Bearer {EULABEL_API_KEY}"}, json={ "name": "Quinta do Crasto Douro Red 2021", "category": "wine", "brand": "Quinta do Crasto", "gtin": "5601234567890", }, ) response.raise_for_status() product = response.json() print(product["productId"]) ``` -------------------------------- ### Pagination Parameters Example (cURL) Source: https://eulabel.eu/docs/api-reference Shows how to use query parameters 'limit' and 'offset' to control pagination when fetching resources. Adjust values as needed. ```bash curl "https://api.eulabel.eu/v1/products?limit=50&offset=50" \ -H "Authorization: Bearer sk_test_..." ``` -------------------------------- ### Bash: Fetch All Suppliers Source: https://eulabel.eu/docs/api-reference/endpoints/suppliers Example cURL command to retrieve a list of all suppliers associated with the organization. It sends a GET request to the /suppliers endpoint with the necessary authorization header. ```bash curl -X GET "https://api.eulabel.eu/v1/suppliers" \ -H "Authorization: Bearer sk_live_..." ``` -------------------------------- ### Create Product using cURL Source: https://eulabel.eu/docs/knowledge-base/examples/wine-label-end-to-end This snippet shows how to create a new product entry using a cURL command. It requires an authorization token and sends product details in JSON format. The response includes a unique productId and a QR code URL. ```bash curl -X POST https://api.eulabel.eu/v1/products \ -H "Authorization: Bearer sk_test_..." \ -H "Content-Type: application/json" \ -d '{ "name": "Quinta do Crasto Douro Red 2021", "category": "wine", "brand": "Quinta do Crasto", "gtin": "5601234567890" }' ``` -------------------------------- ### Check Scan Analytics using cURL Source: https://eulabel.eu/docs/knowledge-base/examples/wine-label-end-to-end This cURL command retrieves scan analytics data for a specific product. It requires the productId and an optional start date to filter the results. This helps in understanding consumer engagement with the product's QR code. ```bash curl "https://api.eulabel.eu/v1/analytics/product/a1b2c3d4-e5f6-7890-abcd-ef1234567890?start=2026-02-18" \ -H "Authorization: Bearer sk_test_..." ``` -------------------------------- ### API Authentication Example (cURL) Source: https://eulabel.eu/docs/api-reference Demonstrates how to authenticate API requests using an API key in the Authorization header. Replace 'sk_test_...' with your actual API key. ```bash curl https://api.eulabel.eu/v1/products \ -H "Authorization: Bearer sk_test_..." ``` -------------------------------- ### Install @eulabel/sdk using Pnpm Source: https://eulabel.eu/docs/llms-full.txt Installs the EUlabel TypeScript SDK using the pnpm package manager. This is an alternative to npm for installing the SDK. ```bash pnpm add @eulabel/sdk ``` -------------------------------- ### Download Product QR Code Source: https://eulabel.eu/docs/documentation/get-started/quickstart Downloads the product's QR code in SVG format. The QR code encodes a GS1 Digital Link URI for consumer and regulatory access. ```bash curl https://api.eulabel.eu/v1/products/a1b2c3d4-.../qr \ -H "Authorization: Bearer $EULABEL_API_KEY" \ -o label-qr.svg ``` ```javascript const qrResponse = await fetch( 'https://api.eulabel.eu/v1/products/a1b2c3d4-.../qr', { headers: { 'Authorization': `Bearer ${EULABEL_API_KEY}` } } ); if (!qrResponse.ok) { throw new Error(`QR code download failed: ${qrResponse.status}`); } const svg = await qrResponse.text(); ``` ```python qr = requests.get( "https://api.eulabel.eu/v1/products/a1b2c3d4-.../qr", headers={"Authorization": f"Bearer {EULABEL_API_KEY}"}, ) qr.raise_for_status() with open("label-qr.svg", "wb") as f: f.write(qr.content) ``` -------------------------------- ### Create a Product using TypeScript SDK Source: https://eulabel.eu/docs/llms-full.txt Shows how to create a new product using the `client.products.create` method. This method requires product data as input. ```typescript async function createProduct() { const productData = { // ... product data properties }; try { const createdProduct = await client.products.create(productData); console.log("Product created:", createdProduct); } catch (error) { console.error("Error creating product:", error); } } ``` -------------------------------- ### Initialize Client and Create Product Passport in TypeScript Source: https://eulabel.eu/docs/documentation/sdks Demonstrates how to initialize the EUlabel client using an API key and perform a sequence of creating a product followed by its associated digital passport. This example highlights the typed interface for product and passport data structures. ```typescript import { EUlabel } from '@eulabel/sdk'; const client = new EUlabel({ apiKey: 'sk_test_...' }); 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' }], }, }); ``` -------------------------------- ### Manage Products Source: https://eulabel.eu/docs/documentation/sdks/python Demonstrates how to create a new product and list existing products using the client's product interface. ```python 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) result = client.products.list() for product in result.products: print(product.name, product.gtin) ``` -------------------------------- ### Home Page cURL Example Update Source: https://eulabel.eu/docs/documentation/changelog Corrects the cURL example for the home page to include the mandatory `category` and `brand` fields. This ensures users can successfully interact with the API. ```bash curl -X POST https://api.eulabel.eu/v1/products \ -H "Content-Type: application/json" \ -d '{ "name": "Example Product", "category": "wine", "brand": "ExampleBrand" }' ``` -------------------------------- ### JSON: Example List of Suppliers Response Source: https://eulabel.eu/docs/api-reference/endpoints/suppliers Example JSON response when fetching a list of suppliers. It contains a 'suppliers' array, where each element represents a supplier object. ```json { "suppliers": [ // Array of supplier objects ] } ``` -------------------------------- ### Pagination Parameters Example Source: https://eulabel.eu/docs/llms-full.txt Shows how to use query parameters `limit` and `offset` to control pagination when requesting a list of products from the EUlabel API. This `curl` command fetches 50 products, skipping the first 50. ```bash curl "https://api.eulabel.eu/v1/products?limit=50&offset=50" \ -H "Authorization: Bearer sk_test_..." ``` -------------------------------- ### Example JSON Payload from DatoCMS Source: https://eulabel.eu/docs/llms-full.txt This is an example JSON payload that might be received from DatoCMS when a product record is updated. It includes event details, entity type, and the updated attributes of the product. ```json { "event_type": "item.update", "entity_type": "item", "entity": { "id": "Kq7rxxPPS32ErMA8nxxMTA", "type": "product", "attributes": { "product_name": "Quinta dos Carvalhais Alfrocheiro 2019", "barcode": [ { "barcode_number": "5601012012200", "capacity_value": "750 mL", "vintage_year": 2019 } ], "list_of_ingredient": [ { "ingredient_name": "Grapes", "quantity": "99.986%" }, { "ingredient_name": "Sulphites", "quantity": "0.014%" } ], "contains_sulfites": true, "energy_value_kj": "351 kJ/100mL", "alcohol_content_by_volume": "13.5%vol.", "product_country": "PT", "product_region": "Dao" } } } ``` -------------------------------- ### JSON: Example Supplier Creation Response Source: https://eulabel.eu/docs/api-reference/endpoints/suppliers Example JSON response received after successfully creating a supplier. It includes the unique supplier ID, name, and creation timestamp. ```json { "supplierId": "sup_sogrape001", "name": "Quinta do Crasto, S.A.", "createdAt": "2026-03-14T20:00:00.000Z" } ``` -------------------------------- ### Initialize EUlabel SDK Client Source: https://eulabel.eu/docs/llms-full.txt Demonstrates how to initialize the EUlabel SDK client with an API key. It's recommended to initialize the SDK on the server-side. ```typescript import EUlabel from "@eulabel/sdk"; const apiKey = "YOUR_API_KEY"; // Replace with your actual API key const client = new EUlabel(apiKey); ``` -------------------------------- ### Textile Certifications JSON Example Source: https://eulabel.eu/docs/knowledge-base/guides/textile-passport Lists the certifications a textile product holds, which are crucial for demonstrating compliance with environmental and sustainability standards. Examples include OEKO-TEX, GOTS, and GRS. ```json { "hasCertification": [ { "@type": "Certification", "name": "OEKO-TEX Standard 100" }, { "@type": "Certification", "name": "Global Organic Textile Standard (GOTS)" }, { "@type": "Certification", "name": "Global Recycled Standard (GRS)" } ] } ``` -------------------------------- ### Retrieve Product Passport Source: https://eulabel.eu/docs/documentation/get-started/quickstart Fetches the full structured digital product passport for a specific product ID. Requires a valid API key in the Authorization header. ```bash curl https://api.eulabel.eu/v1/products/a1b2c3d4-.../passport \ -H "Authorization: Bearer $EULABEL_API_KEY" ``` ```javascript const passportGet = await fetch( 'https://api.eulabel.eu/v1/products/a1b2c3d4-.../passport', { headers: { 'Authorization': `Bearer ${EULABEL_API_KEY}` } } ); if (!passportGet.ok) { const error = await passportGet.json(); throw new Error(`${error.error.code}: ${error.error.message}`); } const passportData = await passportGet.json(); ``` ```python passport_resp = requests.get( "https://api.eulabel.eu/v1/products/a1b2c3d4-.../passport", headers={"Authorization": f"Bearer {EULABEL_API_KEY}"}, ) passport_resp.raise_for_status() passport_data = passport_resp.json() ``` -------------------------------- ### JSON: Example Supplier Creation Request Body Source: https://eulabel.eu/docs/api-reference/endpoints/suppliers An example JSON object representing the request body for creating a supplier. It demonstrates the structure and values for name, country, role, and VAT number. ```json { "name": "Quinta do Crasto, S.A.", "country": "PT", "role": "producer", "vatNumber": "PT500123456" } ``` -------------------------------- ### JSON: Example Link Product Supplier Request Body Source: https://eulabel.eu/docs/api-reference/endpoints/suppliers An example JSON object representing the request body for associating a supplier with a product. It specifies the supplier's ID and the role in the supply chain. ```json { "supplierId": "sup_sogrape001", "role": "producer" } ``` -------------------------------- ### Download QR Code Source: https://eulabel.eu/docs/documentation/get-started/quickstart Generates an SVG QR code that encodes a GS1 Digital Link URI for a product. Scanning this QR code directs users to the product's passport information. ```APIDOC ## GET /v1/products/{productId}/qr ### Description Generates an SVG QR code for a product, encoding a GS1 Digital Link URI. ### Method GET ### Endpoint /v1/products/{productId}/qr ### Parameters #### Path Parameters - **productId** (string) - Required - The unique identifier of the product. ### Request Example ```bash curl https://api.eulabel.eu/v1/products/a1b2c3d4-.../qr \ -H "Authorization: Bearer $EULABEL_API_KEY" \ -o label-qr.svg ``` ### Response #### Success Response (200) - **Content-Type**: `image/svg+xml` - **Body**: SVG content of the QR code. #### Response Example ```xml ... ``` ``` -------------------------------- ### Interactive API Playground Examples (JavaScript, Python, cURL, Go) Source: https://eulabel.eu/docs/documentation/changelog Provides interactive API playground examples in multiple languages, including JavaScript, Python, cURL, and Go. This allows developers to easily test and integrate with the EUlabel API. ```javascript async function getProducts(orgSlug, projectSlug) { const response = await fetch(`https://api.eulabel.eu/v1/${orgSlug}/${projectSlug}/products`); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } const data = await response.json(); console.log(data); } getProducts('my-org', 'my-project'); ``` ```python import requests def get_products(org_slug, project_slug): url = f"https://api.eulabel.eu/v1/{org_slug}/{project_slug}/products" response = requests.get(url) if response.status_code == 200: print(response.json()) else: print(f"Error: {response.status_code}") get_products('my-org', 'my-project') ``` ```bash curl -X GET https://api.eulabel.eu/v1/my-org/my-project/products ``` ```go package main import ( "fmt" "io/ioutil" "net/http" ) func main() { resp, err := http.Get("https://api.eulabel.eu/v1/my-org/my-project/products") if err != nil { fmt.Println("Error making request:", err) return } defer resp.Body.Close() body, err := ioutil.ReadAll(resp.Body) if err != nil { fmt.Println("Error reading response body:", err) return } fmt.Println(string(body)) } ``` -------------------------------- ### Interact with EUlabel Sandbox Environment (cURL) Source: https://eulabel.eu/docs/llms-full.txt Demonstrates how to interact with the EUlabel sandbox environment using cURL. Includes examples for listing products and creating a test product. Requires a sandbox API key. ```bash export EULABEL_API_KEY="sk_test_..." # List pre-populated products curl https://sandbox.api.eulabel.eu/v1/products \ -H "Authorization: Bearer $EULABEL_API_KEY" # Create a test product curl -X POST https://sandbox.api.eulabel.eu/v1/products \ -H "Authorization: Bearer $EULABEL_API_KEY" \ -H "Content-Type: application/json" \ -d '{"name":"Test Wine","category":"wine","brand":"TestBrand","gtin":"4006381333931"}' ``` -------------------------------- ### Example Analytics API Response (JSON) Source: https://eulabel.eu/docs/knowledge-base/concepts/scan-analytics This JSON object shows an example response from the EUlabel Analytics API. It includes aggregated data such as total scans, unique countries, location breakdowns, device types, top referrers, and scans over time. ```json { "productId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890", "period": { "start": "2025-12-20T18:44:05Z", "end": "2026-03-20T18:44:05Z" }, "totalScans": 1842, "uniqueCountries": 14, "locations": { "PT": 823, "ES": 312, "DE": 198, "FR": 145, "IT": 89, "GB": 72 }, "devices": { "mobile": 1534, "desktop": 210, "tablet": 98 }, "topReferrers": [ { "domain": "winebar.pt", "scans": 241 }, { "domain": "google.com", "scans": 189 } ], "scansByDay": [ { "date": "2026-03-18", "scans": 42 }, { "date": "2026-03-19", "scans": 38 } ] } ``` -------------------------------- ### API Error Response - Not Found Error Example Source: https://eulabel.eu/docs/api-reference/endpoints/passports Example of a JSON response when a requested resource is not found. This typically happens if the 'productId' does not exist or the endpoint is incorrect. The response includes the error type and a message indicating that the resource could not be located. ```json { "error": { "type": "not_found", "message": "Resource not found", "code": "not_found" } } ``` -------------------------------- ### Create Product via API (cURL, JavaScript, Python) Source: https://eulabel.eu/docs/llms-full.txt Demonstrates how to create a new product in the EUlabel system using API POST requests. It requires an API key for authentication and sends product details in JSON format. The examples cover cURL, JavaScript (using fetch), and Python (using requests). ```bash export EULABEL_API_KEY="sk_test_..." curl -X POST https://api.eulabel.eu/v1/products \ -H "Authorization: Bearer $EULABEL_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "name": "Quinta do Crasto Douro Red 2021", "category": "wine", "brand": "Quinta do Crasto", "gtin": "5601234567890" }' ``` ```javascript const EULABEL_API_KEY = process.env.EULABEL_API_KEY; const response = await fetch('https://api.eulabel.eu/v1/products', { method: 'POST', headers: { 'Authorization': `Bearer ${EULABEL_API_KEY}`, 'Content-Type': 'application/json', }, body: JSON.stringify({ name: 'Quinta do Crasto Douro Red 2021', category: 'wine', brand: 'Quinta do Crasto', gtin: '5601234567890', }), }); if (!response.ok) { const error = await response.json(); throw new Error(`${error.error.code}: ${error.error.message}`); } const product = await response.json(); console.log(product.productId); ``` ```python import requests EULABEL_API_KEY = "sk_test_..." product = requests.post( "https://api.eulabel.eu/v1/products", headers={"Authorization": f"Bearer {EULABEL_API_KEY}"}, json={ "name": "Quinta do Crasto Douro Red 2021", "category": "wine", "brand": "Quinta do Crasto", "gtin": "5601234567890", }, ).json() ``` -------------------------------- ### API Error Response - Authentication Error Example Source: https://eulabel.eu/docs/api-reference/endpoints/passports Example of a JSON response for an authentication error. This error is returned when the provided API key is missing, invalid, or expired. The response details the error type and a message indicating the authentication issue. ```json { "error": { "type": "authentication_error", "message": "Invalid API key", "code": "authentication_error" } } ``` -------------------------------- ### Requesting a Linkset via HTTP Source: https://eulabel.eu/docs/knowledge-base/concepts/linkset Demonstrates how to fetch a linkset for a specific product using either a query parameter or an Accept header. These methods trigger the resolver to return a structured JSON response containing all available product links. ```bash curl "https://eulabel.eu/01/05601234567890?linkType=linkset" ``` ```bash curl "https://eulabel.eu/01/05601234567890" -H "Accept: application/linkset+json" ```