openfoodfacts
Dart-Paket für die Open Food Facts-API, eine Lebensmittel-Datenbank, die von jedem für jeden erstellt wurde.
Open Food Facts API Wrapper
^4.12.0^1.6.0^1.9.1^1.17.014.1.02.16.06.14.16.1.01.31.21.15.1Englischer Projektschnappschuss. Aktuelle Inhalte auf GitHub.
Pub Version Run sdk tests likes popularity pub points
Dart package for the Open Food Facts API. Free and Easy access to more than 2.9 million food products information from all around the world. Open Food Facts is powered by contributors from around the world and is constantly growing thanks to them.
We use the ability of the Open Food Facts API to return products results in JSON, we then generate easily understandable objects structures to make it simple for you to use.
This plugin also allows you to edit a product or upload a new one to Open Food Facts. Using the same simple product structure you can create a product object or edit an existing one and send it to the API using a single function.
Follow the installing instructions on pub.dev.
For most queries no authentication is required! :) Though we recommend to set a User-Agent to not to be blocked by mistake.
At the beginning of the app you can define some global settings so that they don't need to be specified in each query. You can override these static values at any time in the app lifecycle.
import 'package:openfoodfacts/openfoodfacts.dart';
OpenFoodAPIConfiguration.userAgent = UserAgent(name: 'Your app name', url: 'Your url, if applicable');
OpenFoodAPIConfiguration.globalLanguages = <OpenFoodFactsLanguage>[
OpenFoodFactsLanguage.ENGLISH
];
OpenFoodAPIConfiguration.globalCountry = OpenFoodFactsCountry.FRANCE;
All possible configurations can be found here.
Find migration instructions here.
Code examples for the following tasks:
Robotoff it the Open Food Facts AI which analyze every new pictures to extract new data.
Folksonomy is adding several kinds of new individual data properties to Open Food Facts or Open Products Facts.
Some queries which modify or enter data need a user account to validate this request. There are multiple ways to handle user accounts:
Currently there is no OAuth workflow, therefor a user is just a User object in this package. So you need to get the username as well as the password from the users and store it somewhere save. For Flutter apps we recommend using the flutter_secure_storage package
For the user to be taken into account you have mount a global user at one point in your app lifecycle:
OpenFoodAPIConfiguration.globalUser = User(
userId: 'myUsername',
password: 'myPassword',
);
Regardless if you are using a global app or accounts per user. After mounting this, the user will be added to queries where the user can be attributed.
Some methods in OpenFoodAPIClient require to pass a User, there you can access the before mounted user with:
OpenFoodAPIClient.thisNeedsAnUser(
user: OpenFoodAPIConfiguration.globalUser,
...
);
Further examples:
The database in under the OdBL. This means attributing the source and also contributing back any additions (photos, data), which this package makes easy to do. You can check the terms of use here : Terms of use.
If found a bug or missing features in this package, please open an issue for it.
If you are having issues, that go beyond the scope of this package, please write to us on Slack or send us an email at reuse@openfoodfacts.org (or contact@openfoodfacts if not related to reuse)
Execute the following command from the root of the repository to run the tests:
dart test
Open Food Facts (Codename Smoothie) is the official app developed by Open Food Facts, which is available on Android and iOS. The source code is also available on GitHub.
Feel free to open a PR to add your application in this list.
Thanks to Alexander Schacht and Primaël Quémerais for the initial creation of this package.