weebi_openfoodfacts_service 1.3.2
weebi_openfoodfacts_service: ^1.3.2 copied to clipboard
Advanced OpenFoodFacts integration with multi-language support, image caching, offline capabilities, and Open Prices integration for real-world pricing data.
Weebi OpenFoodFacts Service #
A comprehensive, reusable Flutter package for integrating with OpenFoodFacts API with advanced features like multi-language support, intelligent caching, and Open Prices integration for real-world pricing data.
๐ Features #
Current Capabilities #
- OpenFoodFacts Integration: Full access to 2.9M+ food products - โ Works without credentials!
- ๐ Open Prices Integration: Real-world pricing data from crowdsourced receipts - Requires authentication
- Multi-Language Support: 10+ languages with automatic fallbacks
- Advanced Caching: Product and image caching for offline support
- ๐ Secure Credential Management: Automatic credential loading with .gitignore support
- Framework-Agnostic: Can be used in any Flutter project
- Production Ready: Comprehensive error handling and validation
๐ Quick Start #
import 'package:weebi_openfoodfacts_service/weebi_openfoodfacts_service.dart';
// Initialize without pricing (works immediately)
await WeebiOpenFoodFactsService.initialize(
appName: 'MyApp/1.0',
enablePricing: false, // Disable pricing to work without credentials
enableBeautyProducts: true, // Enable beauty products
);
// Get food product information immediately
final foodProduct = await WeebiOpenFoodFactsService.getProduct('3017620422003');
print('Food Product: ${foodProduct?.name}');
// Get beauty product information
final beautyProduct = await WeebiOpenFoodFactsService.getBeautyProduct('3560070791460');
print('Beauty Product: ${beautyProduct?.name}');
print('Period after opening: ${beautyProduct?.periodAfterOpening}');
๐งพ Open Prices Features (Requires Authentication) #
- Real-time Pricing: Current prices from actual stores
- Price History: Track price changes over time
- Store Locations: Find products at specific stores
- Price Statistics: Average, min/max prices with trends
- Crowdsourced Data: Community-driven price validation
- Receipt Integration: Submit prices from receipts (with auth)
๐ Beauty Products (OpenBeautyFacts) #
The service now supports beauty and cosmetic products from OpenBeautyFacts:
// Get beauty product by barcode
final beautyProduct = await WeebiOpenFoodFactsService.getBeautyProduct('3560070791460');
if (beautyProduct != null) {
print('Name: ${beautyProduct.name}');
print('Brand: ${beautyProduct.brand}');
print('Period after opening: ${beautyProduct.periodAfterOpening}');
print('Cosmetic ingredients: ${beautyProduct.cosmeticIngredients.length} items');
print('Allergens: ${beautyProduct.allergens.join(', ')}');
}
// Search beauty products
final shampooProducts = await WeebiOpenFoodFactsService.searchBeautyProducts(
query: 'shampoo',
limit: 10,
);
// Get beauty categories
final categories = await WeebiOpenFoodFactsService.getBeautyCategories();
print('Available categories: ${categories.join(', ')}');
Beauty Product Features:
- โ Basic Info: Name, brand, barcode
- โ Cosmetic Data: Period after opening, ingredients
- โ Safety: Allergen warnings, ingredient analysis
- โ Images: Product photos, ingredient lists
- โ Multi-language: All data in preferred languages
- ๐ง Pricing: Beauty product pricing (future)
Architecture Foundation for Future Expansion #
- Multi-Database Ready: Built with extensibility for OpenBeautyFacts and OpenProductsFacts
- Product Type System: Supports food, beauty, and general product types
- Flexible Caching: Database-aware caching system
- Scalable Design: Easy to extend for new databases and features
๐ฆ Installation #
Add this to your pubspec.yaml:
weebi_openfoodfacts_service: ^1.3.0
๐ Credential Setup (Optional - Only for Pricing Features) #
Basic product information works without any credentials!
The service works in read-only mode without credentials for OpenFoodFacts API. Credentials are only required for Open Prices API features (pricing data, price submission).
What Works Without Credentials: #
- โ Product information (name, brand, ingredients, etc.)
- โ Product images and nutrition data
- โ Multi-language support
- โ Product caching
- โ All OpenFoodFacts features
What Requires Credentials: #
- โ Pricing data (current prices, price history)
- โ Price statistics and trends
- โ Price submission from receipts
- โ Store-specific pricing
Quick Start Without Credentials: #
await WeebiOpenFoodFactsService.initialize(
appName: 'MyApp/1.0',
enablePricing: false, // Disable pricing to work without credentials
);
// Get product information immediately
final product = await WeebiOpenFoodFactsService.getProduct('3017620422003');
print('Product: ${product?.name}'); // Works without credentials!
Integrations #
OpenFoodFacts + Open Prices #
- โ Multi-language API integration
- โ Advanced caching system
- โ Comprehensive error handling
- โ ๐ Open Prices integration
- โ ๐ Real-time pricing data
- โ ๐ Price history & statistics
- โ ๐ Secure credential management
- โ Production-ready package
OpenBeautyFacts #
- โ Beauty product API integration
- โ Cosmetic-specific data fields
- โ Period after opening support
- โ Ingredient safety analysis
OpenProductsFacts #
- โ General product API integration
- โ Product category system
- โ Multi-database search
- โ Unified product interface
๐ License #
This project is licensed under the MIT License - see the LICENSE file for details.
๐ Acknowledgments #
- OpenFoodFacts for the amazing open data
- ๐ Open Prices for crowdsourced pricing data
- OpenBeautyFacts for cosmetic product data
- OpenProductsFacts for general product data
- The Dart/Flutter community for excellent tooling
Beauty Products #
// Get beauty product by barcode
final beautyProduct = await WeebiOpenFoodFactsService.getBeautyProduct('1234567890123');
// Search beauty products
final beautyResults = await WeebiOpenFoodFactsService.searchBeautyProducts(
query: 'shampoo',
brand: 'L\'Oreal',
category: 'Hair Care',
);
// Get beauty categories
final beautyCategories = await WeebiOpenFoodFactsService.getBeautyCategories();
General Products #
// Get general product by barcode
final generalProduct = await WeebiOpenFoodFactsService.getGeneralProduct('1234567890123');
// Search general products
final generalResults = await WeebiOpenFoodFactsService.searchGeneralProducts(
query: 'smartphone',
brand: 'Apple',
category: 'Electronics',
);
// Get general product categories
final generalCategories = await WeebiOpenFoodFactsService.getGeneralCategories();