Open Beauty Facts
API Wrapper for Open Beauty Facts, the open database about beauty products.
Installation
Add this line to your application's Gemfile:
gem 'openbeautyfacts'
And then execute:
$ bundle
Or install it yourself as:
$ gem install openbeautyfacts
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
- Locale
- ManufacturingPlace
- Mission
- NumberOfIngredients
- Origin
- PackagerCode
- Packaging
- PeriodAfterOpening
- Press
- Product
- ProductState
- PurchasePlace
- Store
- Trace
- User
Usage
require 'openbeautyfacts'
code = "3029330003533"
product = Openbeautyfacts::Product.get(code, locale: 'fr')
product.product_name
product.nutriments.to_hash
user = Openbeautyfacts::User.login("USERNAME", "PASSWORD")
if user
product.brands = "Jacquet"
product.update
end
products = Openbeautyfacts::Product.search("Chocolate", locale: 'world', page_size: 3)
products.first.fetch
product_states = Openbeautyfacts::ProductState.all
product_states.last.products
Openbeautyfacts::Locale.all
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
- Fork it ( https://github.com/openfoodfacts/openbeautyfacts-ruby/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request