Giter Site home page Giter Site logo

openfoodfacts / api-documentation Goto Github PK

View Code? Open in Web Editor NEW
18.0 15.0 7.0 84.73 MB

Version 2 of the documentation of the V1 API. The code behind the API is at https://github.com/openfoodfacts/openfoodfacts-server. An effort is made there to create a V3 of the documentation based on OpenAPI

api documentation openfoodfacts hacktoberfest

api-documentation's People

Contributors

alexgarel avatar dependabot[bot] avatar gitbook-com[bot] avatar m123-dev avatar marinahgtech avatar ocervell avatar raphael0202 avatar roxie-32 avatar stephanegigandet avatar teleboas avatar teolemon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

api-documentation's Issues

Add those parameters to the advanced search doc

Add those parameters to the advanced search doc
https://openfoodfacts.github.io/api-documentation/#jump-5Filtering-SEARCHparameters

  | <option value="ingredients" label="ingredients">ingredients</option>

  | <option value="nova_groups" label="NOVA groups">NOVA groups</option>
  |  
  | <option value="languages" label="languages">languages</option>
  |  
  | <option value="creator" label="contributors">contributors</option>
  |  
  | <option value="editors" label="editors">editors</option>
  |  
  | <option value="lang" label="main language">main language</option>

Add user-input to json

As I understand it, now most fields have een parsed by product opener. This implies that capitalization and special characters have been removed. This process is irreversible. And we lost what the user tried to input.
It would be nice to have the original input (add _orig to field as with the producer codes), so a nicer output can be presented to the user.

Test gitbook / github / openapi intregration

  • create a new test repository (on Funke’s GitHub account, or we can create one on openfoodfacts account if needed)
  • add an introduction md file
    • test modifying md file either from github or from gitbook
  • an openapi file
    • document GET /api/v2/product/[barcode number]
    • integrate to gitbook
    • modify on github to see how gitbook handles it
  • test loading openapi file generated from existing postmal documentation

Add documentation for the Search V2 API

What

  • Add documentation for the Search V2 API

examples

Document the suggest.pl API

Loading time / abstraction?

For me the documentation has horrible loading times, the index.html file has 554.644 lines of computer generated code which will increase in the future with documenatation from robotoff and other features.
(The 3300 lines in off-pm-collection.js should be okay for now I think).

I would suggest that we divide the documentation a bit more. But that would probably mean that we have to move away from docgen

Any opinions on this

What can I help with ?

Who for

What

Fix bugs

Simplify, clarify and fix the existing documentation

  • Fix the image upload explanations

Document new APIs

Create API use cases

Document and valorize the SDKs within the doc

Disseminate the doc

To be sorted

Done

Why

  • The better the documentation, the easier it is to use the API, the better Open Food Facts can fulfill its mission

Better document imgid and id

What

https://world.openfoodfacts.org/product/3760284870115/tiramisu-patissier
https://world.openfoodfacts.org/images/products/376/028/487/0115/1.jpg (1 is imgid)
https://world.openfoodfacts.org/images/products/376/028/487/0115/front_fr.8.full.jpg (front_fr is id, the 8 gets assigned automatically)

Document the image refresh API

image
Ensure we can request photo updates for select products to users for images which should be taken or re-taken (because they are too old, or possibly too small / blurry).

https://fr.openfoodfacts.org/api/v0/produit/3483130043180/beurre-cru-a-la-baratte-les-petites-laiteries?fields=images_to_update_fr

It returns a hash of image types + language code (only for the requested language code which should be the language of the app). The value is 0 for images we don't have, or the age of the image (in seconds) for apps that want to add some context like "Our photo of the ingredients is 14 months old, could you take a new one?".

Sample API response

product: {
images_to_update_fr: {
packaging_fr: 0,
front_fr: 83734290,
ingredients_fr: 83734290
}
},

Pseudo code to generate button text

for field in images_to_update_fr:
if field.value=0
verb = "take"
else:
verb = "refresh"
field_name = field.split.before("")
field_language = field.split.after("
")
button_text = fetch_button_text(field_name, field_language, verb)

Strings to combine (suffix the language at the end)

"Take %s picture"
"Refresh %s picture"
"ingredients"
"front"
"nutrition"
"packaging"

Optional - mention how old the image is

How to convert seconds in human readable format: 83734290 = 2 years and 7 months (example routine to convert) - https://stackoverflow.com/questions/29681328/convert-seconds-into-years-months-weeks-hours-minutes-and-seconds

Send the right query based on the initial field in images_to_update_fr

  • Do not use the computed values in the pseudo code
  • Probably refactor the methods we currently have to pass the field name, and make it future proof if we want to add new image fields.

Extra info

app/src/main/java/openfoodfacts/github/scrachx/openfood/images/ProductImage.java

Add documentation for Data Fields

What

This file describes the fields from the CSV export of the products in the Open Food Facts database.

See https://world.openfoodfacts.org/data for more information.

The file encoding is Unicode UTF-8. The character that separates fields is <tab> (tabulation).

Generalities:

- fields that end with _t are dates in the UNIX timestamp format (number of seconds since Jan 1st 1970)
- fields that end with _datetime are dates in the iso8601 format: yyyy-mm-ddThh:mn:ssZ
- fields that end with _tags are comma separated list of tags (e.g. categories_tags is the set of normalized tags computer from the categories field)
- fields that end with a language 2 letter code (e.g. fr for French) is the set of tags in that language
- fields that end with _100g correspond to the amount of a nutriment (in g, or kJ for energy) for 100 g or 100 ml of product
- fields that end with _serving correspond to the amount of a nutriment (in g, or kJ for energy) for 1 serving of the product

List of fields:

# general information:

code : barcode of the product (can be EAN-13 or internal codes for some food stores), for products without a barcode, Open Food Facts assigns a number starting with the 200 reserved prefix
url : url of the product page on Open Food Facts
creator : contributor who first added the product
created_t : date that the product was added (UNIX timestamp format)
created_datetime : date that the product was added (iso8601 format: yyyy-mm-ddThh:mn:ssZ)
last_modified_t : date that the product page was last modified
last_modified_datetime
product_name : name of the product
generic_name
quantity : quantity and unit

# tags:

packaging : shape, material
packaging_tags
brands
brands_tags
categories
categories_tags
categories_fr
origins : origins of ingredients
origins_tags
manufacturing_places : places where manufactured or transformed
manufacturing_places_tags
labels
labels_tags
labels_fr
emb_codes
emb_codes_tags
first_packaging_code_geo : coordinates corresponding to the first packaging code indicated
cities
cities_tags
purchase_places
stores
countries : list of countries where the product is sold
countries_tags
countries_fr

# ingredients:

ingredients_text
traces
traces_tags

# misc. data:

serving_size : serving size in g
no_nutriments : indicates if the nutrition facts are indicated on the food label
additives_n : number of food additives
additives
additives_tags
ingredients_from_palm_oil_n
ingredients_from_palm_oil
ingredients_from_palm_oil_tags
ingredients_that_may_be_from_palm_oil_n
ingredients_that_may_be_from_palm_oil
ingredients_that_may_be_from_palm_oil_tags
nutrition_grade_fr : nutrition grade ('a' to 'e'). see https://fr.openfoodfacts.org/nutriscore
main_category
main_category_fr
image_url
image_small_url

# nutrition facts:

energy_100g
energy-kj_100g
energy-kcal_100g
proteins_100g
casein_100g
serum-proteins_100g
nucleotides_100g
carbohydrates_100g
sugars_100g
sucrose_100g
glucose_100g
fructose_100g
lactose_100g
maltose_100g
maltodextrins_100g
starch_100g
polyols_100g
fat_100g
saturated-fat_100g
butyric-acid_100g
caproic-acid_100g
caprylic-acid_100g
capric-acid_100g
lauric-acid_100g
myristic-acid_100g
palmitic-acid_100g
stearic-acid_100g
arachidic-acid_100g
behenic-acid_100g
lignoceric-acid_100g
cerotic-acid_100g
montanic-acid_100g
melissic-acid_100g
monounsaturated-fat_100g
polyunsaturated-fat_100g
omega-3-fat_100g
alpha-linolenic-acid_100g
eicosapentaenoic-acid_100g
docosahexaenoic-acid_100g
omega-6-fat_100g
linoleic-acid_100g
arachidonic-acid_100g
gamma-linolenic-acid_100g
dihomo-gamma-linolenic-acid_100g
omega-9-fat_100g
oleic-acid_100g
elaidic-acid_100g
gondoic-acid_100g
mead-acid_100g
erucic-acid_100g
nervonic-acid_100g
trans-fat_100g
cholesterol_100g
fiber_100g
sodium_100g
alcohol_100g : % vol of alcohol
vitamin-a_100g
vitamin-d_100g
vitamin-e_100g
vitamin-k_100g
vitamin-c_100g
vitamin-b1_100g
vitamin-b2_100g
vitamin-pp_100g
vitamin-b6_100g
vitamin-b9_100g
vitamin-b12_100g
biotin_100g
pantothenic-acid_100g
silica_100g
bicarbonate_100g
potassium_100g
chloride_100g
calcium_100g
phosphorus_100g
iron_100g
magnesium_100g
zinc_100g
copper_100g
manganese_100g
fluoride_100g
selenium_100g
chromium_100g
molybdenum_100g
iodine_100g
caffeine_100g
taurine_100g
ph_100g : pH (no unit)
fruits-vegetables-nuts_100g : % of fruits, vegetables and nuts (excluding potatoes, yams, manioc)

carbon-footprint_100g : carbon footprint (as indicated on the packaging of some products)

nutrition-score-fr_100g : Nutri-Score - Nutrition score derived from the UK FSA score and adapted for the French market (formula defined by the team of Professor Hercberg)
nutrition-score-uk_100g : nutrition score defined by the UK Food Standards Administration (FSA)

producer_product_id : product id of a product provided by the manufacturer
producer_version_id : revision id of a product provided by the manufacturer
net_weight_value
net_weight_unit
drained_weight_value : drained weight value for products like tuna in brine
drained_weight_unit : drained weight unit for products like tuna in brine
volume_value
volume_unit
other_information
conservation_conditions
recycling_instructions_to_recycle
recycling_instructions_to_discard
nutrition_grade_fr_producer
recipe_idea 
origin
customer_service
producer
preparation
warning
data_sources

code
creator
created_t
last_modified_t
product_name
generic_name
quantity
packaging
brands
categories
origins
manufacturing_places
labels
emb_codes
cities
purchase_places
stores
countries
ingredients_text
allergens
traces
serving_size
serving_quantity
no_nutriments
additives_n
additives
ingredients_from_palm_oil_n
ingredients_from_palm_oil
ingredients_that_may_be_from_palm_oil_n
ingredients_that_may_be_from_palm_oil
nutrition_grade_fr
nova_group
pnns_groups_1
pnns_groups_2
states

Document the API to retrieve all existing values of language specific fields for multilingual products

For language specific fields such as product_name or generic_name, the fields parameter of the read API enables to request a specific language (e.g. product_name_fr), or to set a preferred list of languages.

This feature allows to request a new field [field name]_languages with a hash with all existing values:

&fields=generic_name_languages:

product: {
generic_name_languages: {
en: "Chocolate cookies",
fr: "Biscuits au chocolat"
},

Postman error on import

When importing the Postman collection, Postman reports an error :
"Some of the responses exceed the maximum file size and will not be imported"

Wiki documentation claims energy-kcal nutriment info stored as kj

I hope this is the right way to report this.

This page:

https://wiki.openfoodfacts.org/Nutrients_handling_in_Open_Food_Facts

Says of the nutriment fields:

{nutrient-id}: the value converted in the default unit (currently kJ for all energy fields (including energy-kcal), otherwise gram).

Below it adds in "Possible improvements":

Store the energy-kcal values in kcal, without converting them to kJ

However, checking one or two cases from the API suggests that the energy-kcal field is in kcal, not kj, as it is approximately 4.18 times smaller, which would be about the right ratio if they were in kcal/kj, whereas would presumably be a massive discrepancy if they were both in the same units.

Examples:

Also, both fields are missing from:
https://wiki.openfoodfacts.org/API/Full_JSON_example

So I am guessing the API has changed and the wiki is now out of date?

Would you be able to confirm either way? I'm currently writing a diet diary application which would use this information, and I will be assuming that the kcal field is in fact in kcal unless you say (or I discover) otherwise.

Thanks!

GSOD'22

Hi, my name is Shola and I am a GSOD'22 applicant. I was going through the GSOD Proposal and didn't see a way to apply to the community. How is the statement of interest to be submitted? Are we required to work with the community beforehand?

Clarify WRITE API tag language behaviour

It is not clear in which language the tags should be written in the write api.

My current solution is to prefix ALL tags with the language, but is this correct?

Question about search & fields parameters

Hi, I'm trying to do 2 things which I'm not sure if it's already implemented :) :

Document the new multilingual text field `packaging_text_XX` that enables users to input the recycling instructions

What

  • Document the new multilingual text field packaging_text_XX that enables users to input the recycling instructions
  • This fields behaves exactly like the ingredients_text_XX, and the mechanism to fill it is exactly the same (get the OCR from the selected packaging_XX image, have the user check it, and then POST it to packaging_text_XX)

Why

  • Packaging is a crucial component in Eco-Score computations, and it should be easy to input those recycling instructions that are then parsed server side to compute packaging shapes and packaging materials

Part of

Document 'no_nutrition_data'

Story

  • Document 'no_nutrition_data'

Screenshot

image

Code

<div class="fieldset" id="nutrition"><legend>Nutrition facts</legend>
            <!-- extra field suffixed with _displayed to allow detecting when a box is unchecked -->
            <input type="hidden" name="no_nutrition_data_displayed" value="1">
            <input type="checkbox" id="no_nutrition_data" name="no_nutrition_data">
            <label for="no_nutrition_data" class="checkbox_label">Nutrition facts are not specified on the product.</label><br>

Part of

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.