搜尋套件、儲存庫與 APP 分類

套件詳情v3.32.0

openfoodfacts

Dart 套件用於 Open Food Facts API,一個由每個人為每個人建立的食品產品資料庫。

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
1.1萬
喜歡數
160
Pub 分數
160

安裝套件

flutter pub add openfoodfacts

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

openfoodfacts Dart 套件提供對 Open Food Facts API 的便捷存取,這是一個由全球使用者共同貢獻的食品產品協作資料庫。它讓開發者能夠取得詳細的產品資訊,例如成分、營養資訊、過敏原和條碼資料。此套件專為跨平台應用設計,支援 Android、iOS、Web、macOS、Windows 及 Linux。該套件簡化了與 Open Food Facts 資料庫的整合,非常適合專注於食品透明度、飲食追蹤或營養分析的應用程式。

適用情境

  • 透過條形碼查找食品產品
  • 營養資訊檢索
  • 過敏原和成分掃描
  • 飲食追蹤應用程式
  • 永續食品選擇研究

主要特色

  • 跨平台相容性
  • 即時產品資料存取
  • 支援條碼和關鍵字搜尋
  • 開源且由社群驅動
  • 簡單 API 結合

適合對象

  • 健康與保健應用
  • 食品標籤工具
  • 飲食管理平台
  • 教育類食品科學應用
  • 注重永續性的應用程式

使用建議

  • 依賴外部API的可用性
  • 資料品質因使用者貢獻而異
  • 需要互聯網連接以進行即時查詢
  • 有限的離線功能
  • 在高使用量期間可能會應用速率限制

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

Open Food Facts - Dart

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.

General principles, how does it work ?

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.

Weekly meetings (currently inactive)

  • We e-meet on Fridays at 09:00 Paris Time (08:00 London Time, 11:30 IST, 12:00 AM PT)
  • Google Meet Video call link: https://meet.google.com/gnp-frks-esc
  • Join by phone: https://tel.meet/gnp-frks-esc?pin=1110549945262
  • Add the Event to your Calendar by adding the Open Food Facts community calendar to your calendar
  • Weekly Agenda: please add the Agenda items as early as you can. Make sure to check the Agenda items in advance of the meeting, so that we have the most informed discussions possible, leading to argumented decisions.
  • The meeting will handle Agenda items first, and if time permits, collaborative bug triage.
  • We strive to timebox the core of the meeting (decision making) to 30 minutes, with an optional free discussion/live debugging afterwards.
  • We take comprehensive notes in the Weekly Agenda of agenda item discussions and of decisions taken.

Usage

Installation

Follow the installing instructions on pub.dev.

How to authenticate

For most queries no authentication is required! :) Though we recommend to set a User-Agent to not to be blocked by mistake.

Setup (Optional)

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.

Migrations

Find migration instructions here.

Features

Code examples for the following tasks:

Reading data
Writing data
Robotoff support

Robotoff it the Open Food Facts AI which analyze every new pictures to extract new data.

Folksonomy Engine

Folksonomy is adding several kinds of new individual data properties to Open Food Facts or Open Products Facts.

Contributing data

Handle Open Food Facts accounts

Some queries which modify or enter data need a user account to validate this request. There are multiple ways to handle user accounts:

  1. Let your users login / create Open Food Facts user accounts (Recommended)
  2. Create a global user for your app through which all requests run

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:

If your users do not expect a specific result immediately (eg. Inventory apps)
  • Send photos (front/nutrition/ingredients/packaging): most painless thing for your users
  • The Open Food Facts AI Robotoff will generate some derived data from the photos
  • Overtime, other apps, and the Open Food Facts community will fill the data gaps
If your users do expect a result immediately (eg Nutrition apps, Scoring apps…)
  • Send nutrition facts + category > get the Nutri-Score
  • Send ingredients > get the NOVA group (about food ultra-processing), additives, allergens, normalized ingredients, vegan, vegetarian…
  • Send category (strict minimum) + labels + origins of ingredients + packaging (photo and text) > get the Eco-Score (about environmental impact)

Open Data License

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.

Useful recourses

Contribute to the package

If found a bug or missing features in this package, please open an issue for it.

Support

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)

Testing

Execute the following command from the root of the repository to run the tests:

dart test

Applications using this SDK

Official application

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.

Third party applications

Feel free to open a PR to add your application in this list.

Authors

Thanks to Alexander Schacht and Primaël Quémerais for the initial creation of this package.

Contributors

Drag Racing

所屬分類

依賴

依賴清單 4 項

原始碼儲存庫

使用此套件的專案