
Security News
Researcher Exposes Zero-Day Clickjacking Vulnerabilities in Major Password Managers
Hacker Demonstrates How Easy It Is To Steal Data From Popular Password Managers
A ruby gem wrapping API of USDA National Nutrient Database which will let you instantly search for nutrition data. You may also consider importing the database with usda-nutrient-database gem.
Add this line to your application's Gemfile:
gem 'usda_ndb'
And then execute:
$ bundle
Or install it yourself as:
$ gem install usda_ndb
Visit https://api.data.gov/signup/ and get a free data.gov API key. Then create initializer
$ rails generate usda_ndb:install
and set your key in /config/initializers/usda_ndb.rb.
UsdaNdb.configure do |config|
config.api_key = 'Your API key'
end
Then you can use it.
# to search for products
UsdaNdb.search('apple raw')
# => {"list"=>{"q"=>"apple raw", "sr"=>"28", "ds"=>"any", "start"=>0, "end"=>22, "total"=>22, "group"=>"", "sort"=>"r", "item"=>[{"offset"=>0, "group"=>"Fruits and Fruit Juices", "name"=>"Apples, raw, with skin", "ndbno"=>"09003", "ds"=>"SR"}, ...
# to get nutrition data about product with concrete id(ndbno)
UsdaNdb.reports('09003')
# => {"report"=>{"sr"=>"28", "type"=>"Basic", "food"=>{"ndbno"=>"09003", "name"=>"Apples, raw, with skin", "ds"=>"Standard Reference", "ru"=>"g", "nutrients"=>[{"nutrient_id"=>"255", "name"=>"Water", ...
# to list products
UsdaNdb.list
# => {"list"=>{"lt"=>"f", "start"=>0, "end"=>50, "total"=>50, "sr"=>"28", "sort"=>"n", "item"=>[{"offset"=>0, "id"=>"09427", "name"=>"Abiyuch, raw"}, {"offset"=>1, "id"=>"09002", "name"=>"Acerola juice, raw"}, ...
You can specify additional params. A reference is here
# to list product groups instead of products
UsdaNdb.list(lt: 'g')
# => {"list"=>{"lt"=>"g", "start"=>0, "end"=>25, "total"=>25, "sr"=>"28", "sort"=>"n", "item"=>[{"offset"=>0, "id"=>"3500", "name"=>"American Indian/Alaska Native Foods"}, {"offset"=>1, "id"=>"0300", "name"=>"Baby Foods"}, ...
git checkout -b my-new-feature
)git commit -am 'Add some feature'
)git push origin my-new-feature
)FAQs
Unknown package
We found that usda_ndb demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Hacker Demonstrates How Easy It Is To Steal Data From Popular Password Managers
Security News
Oxlint’s new preview brings type-aware linting powered by typescript-go, combining advanced TypeScript rules with native-speed performance.
Security News
A new site reviews software projects to reveal if they’re truly FOSS, making complex licensing and distribution models easy to understand.