All Projects → openfoodfacts → openfoodfacts-ruby

openfoodfacts / openfoodfacts-ruby

Licence: MIT license
Open Food Facts API Wrapper

Programming Languages

ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to openfoodfacts-ruby

smooth-app
The new Open Food Facts mobile application for Android and iOS, crafted with Flutter and Dart
Stars: ✭ 187 (+592.59%)
Mutual labels:  food, openfoodfacts
openfoodfacts-laravel
Open Food Facts API wrapper for Laravel
Stars: ✭ 117 (+333.33%)
Mutual labels:  food, openfoodfacts
openfoodfacts-go
Go Wrapper for Open Food Facts
Stars: ✭ 34 (+25.93%)
Mutual labels:  food, openfoodfacts
Algorithms
Short explanations and implementations of different algorithms in multiple languages
Stars: ✭ 37 (+37.04%)
Mutual labels:  hacktoberfest2020
redisplanet
Redisplanet - An Ultimate Hands-on Labs on Redis
Stars: ✭ 24 (-11.11%)
Mutual labels:  hacktoberfest2020
say-their-names-android
Welcome to the Say Their Names project - android module
Stars: ✭ 18 (-33.33%)
Mutual labels:  hacktoberfest2020
Coronavirus
Java API Wrapper for tracking coronavirus (COVID-19, SARS-CoV-2) via https://git.io/Jvoep
Stars: ✭ 16 (-40.74%)
Mutual labels:  api-wrapper
ProjectLockdown
Project Lockdown (an initiative from The IO Foundation) is a civic tech, interactive platform providing an overview of the state of Human and Digital Rights around the globe. It evaluates policies obtained from official sources that may impact their observance. It provides, among other tools, a layered map interface that allows for a visual repr…
Stars: ✭ 34 (+25.93%)
Mutual labels:  hacktoberfest2020
awesome-nuxt
🎉 A curated list of awesome things related to Nuxt.js
Stars: ✭ 17 (-37.04%)
Mutual labels:  hacktoberfest2020
golang-health-checker
A simple package to allow you to track your application healthy
Stars: ✭ 12 (-55.56%)
Mutual labels:  hacktoberfest2020
Indoor-Positioning-System
An indoor positioning system (IPS) is a system to locate objects or people inside a building using radio waves, magnetic fields, acoustic signals, or other sensory information.
Stars: ✭ 31 (+14.81%)
Mutual labels:  hacktoberfest2020
instapro
professional instagram tool for developers
Stars: ✭ 81 (+200%)
Mutual labels:  api-wrapper
awesome-translations
😎 Awesome lists about Internationalization & localization stuff. l10n, g11n, m17n, i18n. Translations! 🌎🌍
Stars: ✭ 54 (+100%)
Mutual labels:  hacktoberfest2020
monzo-python
💳 A python SDK for interacting with the Monzo API.
Stars: ✭ 38 (+40.74%)
Mutual labels:  api-wrapper
crate-sample-apps
A JavaScript guestbook app with a number of different backend implementations, each using a different client library to communicate with CrateDB.
Stars: ✭ 57 (+111.11%)
Mutual labels:  hacktoberfest2020
xforwardy
Host Header Injection Scanner
Stars: ✭ 32 (+18.52%)
Mutual labels:  hacktoberfest2020
moonstone
A simple dogehouse.tv API wrapper
Stars: ✭ 38 (+40.74%)
Mutual labels:  api-wrapper
fooddist
An open-source food image embedding model
Stars: ✭ 26 (-3.7%)
Mutual labels:  food
mailerlite-api-python
Python wrapper for Mailerlite API v2
Stars: ✭ 31 (+14.81%)
Mutual labels:  api-wrapper
HacktoberFest2020-1
Open for all and will be accepted within 24 hrs. For contributing. Write program in any language,Make sure you write your name as well
Stars: ✭ 89 (+229.63%)
Mutual labels:  hacktoberfest2020

Open Food Facts

Gem Version Build Status RuboCop Documentation

API Wrapper for Open Food Facts, the open database about food.

Installation

Add this line to your application's Gemfile:

gem 'openfoodfacts'

And then execute:

$ bundle

Or install it yourself as:

$ gem install openfoodfacts

Models

All data is available for World, French, UK and US version for now. You should update the gem page URLs mapping for others.

  • Additive
  • Brand
  • Category
  • City
  • Contributor
  • Country
  • EntryDate
  • Faq
  • IngredientThatMayBeFromPalmOil
  • Label
  • LastEditDate
  • Language
  • Locale
  • ManufacturingPlace
  • Mission
  • NumberOfIngredients
  • NutritionGrade
  • Origin
  • PackagerCode
  • Packaging
  • Press
  • Product
  • ProductState
  • PurchasePlace
  • Store
  • Trace
  • User

Usage

require 'openfoodfacts'

# Browse a product

code = "3029330003533"
product = Openfoodfacts::Product.get(code, locale: 'fr')

product.product_name
# => "Crousti Moelleux Complet"

product.nutriments.to_hash
# => {"sodium"=>"0.44", "sugars"=>6.5, "fat_unit"=>"g", "carbohydrates_unit"=>"g", "proteins_unit"=>"g", "nutrition-score-fr_100g"=>-2, "fat"=>2.5, "proteins_serving"=>12.8, "sodium_serving"=>0.535, "salt"=>1.1176, "proteins"=>10.5, "nutrition-score-uk_serving"=>-2, "nutrition-score-fr"=>-2, "fat_serving"=>3.04, "sugars_unit"=>"g", "sugars_100g"=>"6.5", "sodium_unit"=>"g", "saturated-fat_unit"=>"g", "saturated-fat_serving"=>0.608, "sodium_100g"=>0.44, "fiber_unit"=>"g", "energy"=>1067, "energy_unit"=>"kJ", "sugars_serving"=>7.9, "carbohydrates_100g"=>44, "nutrition-score-uk"=>-2, "proteins_100g"=>10.5, "fiber_serving"=>7.29, "carbohydrates_serving"=>53.5, "nutrition-score-fr_serving"=>-2, "energy_serving"=>1300, "fat_100g"=>"2.5", "saturated-fat_100g"=>"0.5", "nutrition-score-uk_100g"=>-2, "fiber"=>6, "salt_serving"=>1.36, "salt_100g"=>"1.1176", "carbohydrates"=>44, "fiber_100g"=>6, "energy_100g"=>1067, "saturated-fat"=>0.5}

# Update product

user = Openfoodfacts::User.login("USERNAME", "PASSWORD")
if user
    product.brands = "Jacquet"
    product.update
    # true
end

# Search products

products = Openfoodfacts::Product.search("Chocolate", locale: 'world', page_size: 3)
# => [#<Openfoodfacts::Product _id="3045140105502" code="3045140105502" id="3045140105502" image_small_url="https://en.openfoodfacts.org/images/products/304/514/010/5502/front.7.100.jpg" lc="en" product_name="Milka au lait du Pays Alpin">, #<Openfoodfacts::Product _id="3046920028363" code="3046920028363" id="3046920028363" image_small_url="https://en.openfoodfacts.org/images/products/304/692/002/8363/front.5.100.jpg" lc="en" product_name="Tableta de chocolate negro \"Lindt Excellence\" 85% cacao">, #<Openfoodfacts::Product _id="3046920029759" code="3046920029759" id="3046920029759" image_small_url="https://en.openfoodfacts.org/images/products/304/692/002/9759/front.9.100.jpg" lc="en" product_name="Tableta de chocolate negro \"Lindt Excellence\" 90% cacao">]

# You might need to fetch full product data from results

products.first.fetch

# By product state

product_states = Openfoodfacts::ProductState.all
product_states.last.products

# Config

Openfoodfacts::Locale.all
# => ["ad", "ad-es", "ad-fr", "ad-pt", "ae", "al", "am", "ar", "at", "au", "ax", "az", "bd", "be", "be-de", "be-fr", "bf", "bg", "bi", "bi-rn", "bn", "br", "by", "by-be", "bz", "ca", "ca-fr", "cg", "ch", "ch-fr", "ch-it", "ci", "cl", "cn", "co", "cr", "cu", "cy", "cy-tr", "cz", "de", "dk", "do", "dz", "dz-fr", "ec", "eg", "es", "es-ca", "es-eu", "es-gl", "fi", "fi-sv", "fr", "ga", "gf", "gn", "gp", "gr", "hk", "hr", "hu", "id", "ie", "ie-ga", "il", "il-ar", "il-ru", "in", "iq", "iq-ku", "ir", "is", "it", "jp", "ke", "ke-sw", "kh", "kr", "kw", "kz", "kz-kk", "lb", "lk", "lk-ta", "lu", "lu-de", "lu-lb", "lv", "ma", "ma-es", "ma-fr", "mc", "md", "mf", "ml", "mn", "mo", "mo-zh", "mq", "mr", "mt", "mt-mt", "mu", "mx", "my", "nc", "nl", "no", "nz", "nz-mi", "pa", "pe", "pf", "ph", "ph-tl", "pl", "pm", "pt", "qa", "re", "ro", "rs", "ru", "sa", "se", "sg", "sg-ms", "sg-ta", "sg-zh", "si", "sk", "sn", "sy", "th", "tn", "tr", "tw", "tz", "tz-sw", "ua", "uk", "us", "ve", "vn", "vu", "vu-bi", "world", "ye", "yt", "za", "za-af", "za-nr", "za-ss", "za-st", "za-tn", "za-ts", "za-ve", "za-xh", "za-zu"]

Development

After checking out the repo, run bin/setup to install dependencies. Then, run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release to create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

  1. Fork it ( https://github.com/openfoodfacts/openfoodfacts-ruby/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].