Best Practices & Toubleshooting
Do's and Don'ts
This guide provides best practices for integrating the LogMeal API.
Follow these recommendations to ensure your applications are stable, reliable, and efficient.
✅ Do's
-
Use the correct user token
Endpoints require specific user types:- ⚫ APICompany → company-level management
- 🔴 APIUser → individual food recognition and logging
- 🔵 APIUserManager → clinicians or managers supervising multiple users
See Users Types & Access Tokens for details.
-
Preprocess images
Clean, cropped, and well-lit images improve recognition accuracy.
→ See Image Preprocessing. -
Monitor quotas programmatically
Use GET /v2/info/limitations to check:- © Monthly credits
- (D) Daily request limits
- (S) Per‑second request limits
-
Handle rate limits gracefully
If you hit 429 Too Many Requests, implement exponential backoff and respect anyRetry-After
headers.
❌ Don'ts
-
Don’t share 🔴 APIUser tokens
Each end user must have their own token for correct intake history and nutrition tracking. -
Don’t ignore request limits
Persistent 429 errors without backoff can temporarily block your app. -
Don’t hardcode nutritional data
Models and databases evolve. Always fetch fresh data from the API. -
Don’t upload oversized images
Large files waste bandwidth and credits. Use recommended dimensions. -
Don’t use deprecated endpoints
Check the API Documentation to stay up-to-date with supported endpoints.
Reliability Best Practices
Design your integration with fault tolerance in mind:
-
Retry transient failures
Implement retries with exponential backoff for 429 (rate limit) and 5xx (server errors). -
Optimize image payloads
Compress and resize images before sending. -
Validate inputs
Check image format, size, and parameters before making requests to avoid unnecessary failures.
Common Error Scenarios
Error | Cause | Resolution |
---|---|---|
429 Too Many Requests | Rate limit exceeded | Backoff + retry later |
400 Bad Request | Invalid payload | Validate image, parameters, and fields |
401 Unauthorized | Invalid/expired token | Make sure you are using the appropriate user token type |
500 Internal Server Error | Temporary backend issue | Retry with exponential backoff |
🔧 Troubleshooting
This guide provides solutions to common issues when using the LogMeal API and answers frequently asked questions.
1. I get HTTP 401 Unauthorized
- Cause: Invalid, expired, or missing token.
- Fix: Ensure you are using the correct token type (⚫, 🔴, 🔵) and that it has not expired.
- Solution: Make sure you are using the appropriate token and generate the adequate token if necessary.
2. I get HTTP 429 Too Many Requests
- Cause: Exceeded daily (D) or per-second (S) request limits. Or exceeded monthly credits usage if using the 🆓 Free trial plan.
- Fix: Implement exponential backoff retries.
- Solution: Check your quotas with GET /v2/info/limitations.
3. I get HTTP 400 Bad Request
- Cause: Invalid request payload (e.g., wrong parameters, unsupported image format, missing fields).
- Fix: Validate inputs before calling the API.
- Tip: Use JPEG images within recommended size limits. See Image Pre-processing.
4. I get HTTP 500 Internal Server Error
- Cause: Temporary server-side issue.
- Fix: Retry with exponential backoff. If persistent, contact support.
5. I uploaded an image but no dishes were recognized
- Possible reasons:
- Poor image quality (blurry, low light).
- Dish / food item not yet supported in the recognition model.
- Fix: Improve image preprocessing or check if dish is in the supported list.
❓ FAQs
Q: Can I test all features without a paid plan?
Yes. The Free (Trial) tier provides 30 days of unlimited access to all endpoints.
After that, you’ll need to subscribe to Analyse, Monitor, Recommend, or Custom. See Plans & Limits.
Q: Do I need a new 🔴 APIUser token for each end user?
Yes. Each final user must have their own 🔴 APIUser token to ensure personalized nutrition tracking and intake history.
Q: Can managers or clinicians see multiple users’ data?
Yes. Use 🔵 APIUserManager tokens. They allow authorized professionals to view and manage multiple users’ intake history.
Q: How do I know which plan I need?
Check the Plans & Limits guide.
- Analyse → basic food recognition and nutrition.
- Monitor → history, goals, and company tools.
- Recommend → advanced AI scoring and recommendations.
- Custom → enterprise features (e.g., Kiosk).
Q: How often are recognition models updated?
Regularly. Updates include new dishes, improved accuracy, and nutritional refinements.
Q: What image formats are supported?
Only JPEG is supported. Use clear, well-lit photos for best results.
Versioning & Deprecations
The LogMeal API evolves constantly. New food recognition models are released, endpoints may be improved, and older ones may eventually be deprecated.
This page explains how to manage model versions and what to expect when something is marked as deprecated.
Model Versioning
Most recognition endpoints include an optional parameter: model_version
.
-
By default → If you do not specify
model_version
, your requests will automatically use the latest available model.
→ This is the recommended approach to always benefit from the most up-to-date recognition improvements. -
When to specify
model_version
→ You may choose to lock to a specific model version if:- You need full reproducibility of results in a research setting.
- You are conducting long-term studies where results must remain consistent.
- You are validating against a fixed dataset and want to avoid mid-study model updates.
Note: Sticking to a fixedmodel_version
means you will not get improvements (accuracy, new dishes, updated nutrition data) until you explicitly upgrade.
For more details on recognition capabilities, see Food Recognition Capabilities.
Deprecations
Over time, older endpoints or parameters may be deprecated.
This means they are still available for now, but will eventually be removed.
When an endpoint or parameter is deprecated:
- It will be clearly marked in the API Documentation.
- A transition period will be provided before removal.
Migration Tips
- Always prefer the latest endpoints listed in the docs.
- Update your integrations promptly when a deprecation notice is published.
Best Practices
- Default to latest models → Don’t set
model_version
unless reproducibility is critical. - Test regularly with fresh data when new models are released.
- Design for flexibility so you can update
model_version
or endpoint paths with minimal code changes.
Related Resources
- Plans & Limits → Learn how quotas and credits work
- User Types & Access Tokens → Learn about LogMeal API user types and how their access tokens control endpoint permissions.
Updated about 10 hours ago