Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/openfoodfacts/openbeautyfacts-ruby
Open Beauty Facts API Wrapper 💎💄
https://github.com/openfoodfacts/openbeautyfacts-ruby
api-wrapper cosmetic hacktoberfest openbeautyfacts ruby
Last synced: about 2 months ago
JSON representation
Open Beauty Facts API Wrapper 💎💄
- Host: GitHub
- URL: https://github.com/openfoodfacts/openbeautyfacts-ruby
- Owner: openfoodfacts
- License: mit
- Created: 2016-04-09T15:29:38.000Z (over 8 years ago)
- Default Branch: main
- Last Pushed: 2024-09-04T14:40:58.000Z (4 months ago)
- Last Synced: 2024-10-29T22:38:11.992Z (2 months ago)
- Topics: api-wrapper, cosmetic, hacktoberfest, openbeautyfacts, ruby
- Language: Ruby
- Homepage:
- Size: 670 KB
- Stars: 8
- Watchers: 2
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE.txt
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# Open Beauty Facts Ruby SDK
[![Gem Version](https://badge.fury.io/rb/openbeautyfacts.svg)](https://badge.fury.io/rb/openbeautyfacts)
[![Build Status](https://github.com/openfoodfacts/openbeautyfacts-ruby/actions/workflows/ruby.yml/badge.svg)](https://github.com/openfoodfacts/openbeautyfacts-ruby/actions/workflows/ruby.yml)
[![RuboCop](https://github.com/openfoodfacts/openbeautyfacts-ruby/actions/workflows/rubocop-analysis.yml/badge.svg)](https://github.com/openfoodfacts/openbeautyfacts-ruby/actions/workflows/rubocop-analysis.yml)
[![Documentation](https://inch-ci.org/github/openfoodfacts/openbeautyfacts-ruby.svg?branch=master)](https://inch-ci.org/github/openfoodfacts/openbeautyfacts-ruby)API Wrapper for [Open Beauty Facts](https://openbeautyfacts.org/), the open database about beauty products.
- We have a similar package for food: https://github.com/openfoodfacts/openfoodfacts-ruby
- Note: This package needs updates for the newest APIs.
- Please see on https://wiki.openfoodfacts.org/API/Ruby how to join the community to help## Installation
Add this line to your application's Gemfile:
```ruby
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
```ruby
require 'openbeautyfacts'# Browse a product
code = "3029330003533"
product = Openbeautyfacts::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 = Openbeautyfacts::User.login("USERNAME", "PASSWORD")
if user
product.brands = "Jacquet"
product.update
# true
end# Search products
products = Openbeautyfacts::Product.search("Chocolate", locale: 'world', page_size: 3)
# => [#, #, #]# You might need to fetch full product data from results
products.first.fetch
# By product state
product_states = Openbeautyfacts::ProductState.all
product_states.last.products# Config
Openbeautyfacts::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](https://rubygems.org).
## Contributing
1. Fork it ( https://github.com/openfoodfacts/openbeautyfacts-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## Third party applications
If you use this SDK, feel free to open a PR to add your application in this list.## Authors