-
-
Notifications
You must be signed in to change notification settings - Fork 3
API Reference
EverShelf exposes a single PHP endpoint: api/index.php. All actions are selected via the action query parameter.
Full OpenAPI 3.1 spec:
docs/openapi.yaml
https://your-server/api/index.php?action=ACTION_NAME
GET requests pass parameters as query params; POST requests send JSON in the body.
| Tier | Limit | Applies to |
|---|---|---|
| Standard | 120 req/min | All general endpoints |
| AI | 15 req/min |
gemini_*, generate_recipe*
|
| Strict | 5 req/min | report_error |
Exceeded limits return HTTP 429 with {"error": "rate_limit_exceeded"}.
Search for a product in the local database by barcode.
| Param | Type | Description |
|---|---|---|
barcode |
string | EAN/UPC barcode |
Look up a barcode on Open Food Facts (external call).
| Param | Type | Description |
|---|---|---|
barcode |
string | EAN/UPC barcode |
Create or update a product. Pass id to update.
{
"id": 42,
"name": "Pasta Barilla",
"brand": "Barilla",
"category": "pasta",
"unit": "g",
"default_quantity": 500,
"barcode": "8076800105988"
}Get product details by id.
Delete a product by id.
List all products.
Search products by name (?q=pasta).
List all inventory items with product details, grouped.
Response:
{
"inventory": [
{
"id": 1,
"product_id": 42,
"name": "Pasta Barilla",
"quantity": 2,
"unit": "pz",
"location": "dispensa",
"expiry_date": "2027-03-01",
"opened_at": null,
"vacuum_sealed": 0
}
]
}Add a product to inventory.
{
"product_id": 42,
"quantity": 3,
"location": "dispensa",
"expiry_date": "2027-03-01",
"vacuum_sealed": false
}Locations: dispensa, frigo, freezer, altro
Consume inventory. Set use_all: true to consume all stock at a location.
{
"product_id": 42,
"quantity": 1,
"location": "dispensa"
}{
"product_id": 42,
"use_all": true,
"location": "__all__",
"notes": "Buttato"
}Update an inventory entry by id.
Remove an inventory entry by id.
Returns item counts per location.
{
"dispensa": 12,
"frigo": 5,
"freezer": 8
}Returns the operation log.
| Param | Type | Default | Description |
|---|---|---|---|
limit |
int | 50 | Results per page |
offset |
int | 0 | Pagination offset |
Undo a transaction within 24 hours.
{ "id": 873 }Response on success:
{ "success": true, "name": "Tonno all'olio d'oliva" }Error cases:
{ "error": "...", "already_undone": true }
{ "error": "...", "too_old": true }Returns waste and consumption statistics for the last 30 days.
All AI endpoints require GEMINI_API_KEY to be configured. Rate limit: 15 req/min.
Read an expiry date from a product photo.
{ "image": "data:image/jpeg;base64,..." }Identify a product from a photo.
{ "image": "data:image/jpeg;base64,..." }Chat with the AI kitchen assistant.
{ "message": "Cosa posso fare con la pasta?", "history": [] }Generate a recipe based on current inventory.
{ "persons": 2, "meal": "dinner", "preferences": {} }Same as generate_recipe but streams output via Server-Sent Events.
Get AI storage location + shelf-life hint for a new product.
Enrich shopping suggestions with practical tips.
Get a plain-language explanation for a specific inventory anomaly.
Requires BRING_EMAIL and BRING_PASSWORD in .env.
Get the current Bring! shopping list.
Add items to the Bring! list.
{ "items": ["Latte", "Pane"] }Remove an item from the Bring! list.
{ "name": "Latte" }Get smart shopping predictions based on consumption history.
Returns current settings as boolean flags only (no raw key values):
{
"gemini_key_set": true,
"bring_configured": false,
"tts_enabled": false,
"scale_enabled": true,
"demo_mode": false,
"settings_token_set": true
}Update server configuration. If SETTINGS_TOKEN is set, requires header:
X-Settings-Token: your_token
{
"gemini_api_key": "...",
"bring_email": "...",
"scale_enabled": true,
"scale_gateway_url": "ws://127.0.0.1:8765"
}Submit an automatic error report (creates a GitHub Issue).
{
"type": "uncaught-error",
"message": "...",
"stack": "...",
"context": {}
}Only creates an issue if:
- The client is running the latest released version
- The fingerprint hasn't been seen in the last 24 hours
Returns inventory rows where stored quantity significantly differs from transaction history.
Dismiss an anomaly banner without changing inventory.
Relays BLE scale readings from the gateway to the browser via Server-Sent Events (avoids HTTPS→WS mixed-content issues).
Check if the Scale Gateway is reachable.
Scan the local LAN for a running Scale Gateway instance.