Generation Waste

API Dokumentation

URL: https://api.generationwaste.se

Use our API to both retrieve and submit waste data. This enables seamless integration with your existing business intelligence systems, allowing you to enrich your analysis beyond the insights available in the Generation Waste Portal. The API also supports automated data input, such as transferring guest counts directly from your POS system.

Contact us and we will provide you with a username and password, free of charge.


1. Authentication Endpoint

POST /auth

Authenticates a user and returns access-token (bearer) and refresh-token.

Request Parameters (JSON)

{
    "username": "string",
    "password": "string"
}

Response Example (Success)

{
    "access_token": "your_access_token",
    "access_expires": 1743069032,
    "refresh_token": "your_refresh_token",
    "refresh_expires": 1743587432
}

Example Request

curl -X POST https://api.generationwaste.se/auth \
    -H "Content-Type: application/json" \
    -d '{"username":"user","password":"pass"}'

2. Refresh Token Endpoint

POST /refresh

Generates a new access and refresh token

Response Example (Success)

{
    "access_token": "new_access_token",
    "access_expires": 1743069032,
    "refresh_token": "new_refresh_token",
    "refresh_expires": 1743587432
}

Example Request

curl -X POST https://api.generationwaste.se/refresh \
    -H "Authorization: Bearer your_refresh_token" \
    -H "Content-Type: application/json"

3. Foodwaste Data Endpoint

POST /foodwaste

Retrieves food waste data for a given organization within a date range.

Headers

Authorization: Bearer your_jwt_token

Request Parameters (JSON)

{
    "fromDate": "YYYY-MM-DD",
    "toDate": "YYYY-MM-DD",
    "fractions": ["string"], (platewaste, kitchenwaste, servingwaste, guests)
    "servings": ["string"], (Breakfast, Lunch, Dinner)
    "groupBy": "string" (day, week, month, year)
}

Response Example (Success)

Day

[{
    "organization": "01J4KP9YY4EYZ6WA1NRRZWE379",
    "name": "Restaurant X",
    "date": "2024-11-04",
    "serving": "Breakfast",
    "fraction": "platewaste",
    "registrations": 1,
    "value": 2
}]

Week

[{
    "organization": "01J4KP9YY4EYZ6WA1NRRZWE379",
    "name": "Restaurant X",
    "week": "2024-45",
    "serving": "Breakfast",
    "fraction": "platewaste",
    "registrations": 9,
    "value": 21.5
}]

Month

[{
    "organization": "01J4KP9YY4EYZ6WA1NRRZWE379",
    "name": "Restaurant X",
    "month": "2024-11",
    "serving": "Breakfast",
    "fraction": "platewaste",
    "registrations": 42,
    "value": 104.8
}]

Year

[{
    "organization": "01J4KP9YY4EYZ6WA1NRRZWE379",
    "name": "Restaurant X",
    "year": 2024,
    "serving": "Breakfast",
    "fraction": "platewaste",
    "registrations": 809,
    "value": 1348.46
}]

4. Register Data Endpoint

POST /register

Register food waste data or number of guests for a given organization on a date.

Headers

Authorization: Bearer your_jwt_token

Request Parameters (JSON)

{
    "organization": "01J4KP9YY4EYZ6WA1NRRZWE379",
    "date": "YYYY-MM-DD",
    "fraction": "string", (platewaste, kitchenwaste, servingwaste, guests)
    "serving": "string", (Breakfast, Lunch, Dinner)
    "value": number (ie 1.24 or 125)
}

Response Example (Success)

{
    "organization": "01J4KP9YY4EYZ6WA1NRRZWE379",
    "name": "Restaurant X",
    "date": "2024-11-04",
    "serving": "Breakfast",
    "fraction": "guests",
    "registrations": 1,
    "value": 125
}