Punchfork
A simple Ruby library for searching recipes with punchfork.com
Install
add it to your Gemfile:
gem 'punchfork'
configure your API key in config/initializers/punchfork.rb
Punchfork.setup do |config| config.api_key = 'your-api-key' config.protocol = 'https' # defaults to http end
Usage
Search for recipes using ingredients:
search = Punchfork.search(:garlic, :tomatoes) search.count # => 10 search.recipes.length # => 10
Any options you pass to the search method will automatically be appended to the querystring sent to punchfork.com. For example:
search = Punchfork.search(:tomato, count:50)
search.count # => 50
Check out the full set of options at http://punchfork.com/api#apidocs
Due to a lack of support of images being served over https, I have implemented a rewrite method to do this for you in the Recipe object: recipe = search.recipes.first recipe.thumb # http://img.punchfork.net/f9c6047f7958927a0cff232e0da16853_250x250.jpg recipe.secure_thumb # https://s3.amazonaws.com/img.punchfork.net/f9c6047f7958927a0cff232e0da16853_250x250.jpg recipe.secure_url(recipe.thumb) # https://s3.amazonaws.com/img.punchfork.net/f9c6047f7958927a0cff232e0da16853_250x250.jpg
Debugging
If you are not getting the response back you expect you can run your app in debug mode and check the logs: rails server PUNCHFORK_DEBUG=true
Contact
If you have any issues or questions, please open a ticket through github: https://github.com/gabeodess/Punchfork/issues
License
This project rocks and uses MIT-LICENSE.