Skip to content

Ruby wrapper for Food Data Central API

License

MIT, MIT licenses found

Licenses found

MIT
LICENSE
MIT
LICENSE.txt
Notifications You must be signed in to change notification settings

humandoing/food-data-central-ruby

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

food-data-central-ruby

Hack job Ruby wrapper for Food Data Central API with no testing whatsoever so please use at your own risk.

REST API

This gem assumes that you want data returned in JSON format. There may be support for XML in the future.

Getting started

Add the gem to your Gemfile:

gem 'food-data-central-ruby', '~> 0.1', git: 'https://github.com/humandoing/food-data-central-ruby', branch: 'main'

Setting the API Key

All calls to the API require a registered data.gov api_key. If you're using Rails, you can set up your API in an initializer like this:

# config/initializer/ndb-api.rb
FoodDataCentral.configure do |config|
  config.api_key = ENV["OPEN_GOV_API_KEY"]
end

Search

The Search request is wrapped in a simple .perform method on FoodDataCentral::Search and can be used like so:

FoodDataCentral::Search.perform(generalSearchInput: "butter")

Full list of options can be found in the Search Documentation

Food Details

The Food Details request is wrapped in a simple .retrieve method on FoodDataCentral::FoodDetails and can be used like so:

FoodDataCentral::FoodDetails.retrieve(fdcId)

Acknowledgements

Largely based on (wholly copied/modified from) https://github.com/alexstophel/ndb-ruby

About

Ruby wrapper for Food Data Central API

Resources

License

MIT, MIT licenses found

Licenses found

MIT
LICENSE
MIT
LICENSE.txt

Stars

Watchers

Forks

Packages

No packages published