API Cake - Build Dynamic API Wrappers
This gem allows you to easily build rich API wrappers with minimal code.
It is HTTParty with a Cake.
$ gem install apicake
Or with bundler:
Turn this hypothetical API URL:
recipes = Recipes.new recipes.cakes layers:3
Using this code only:
class Recipes < APICake::Base base_uri 'api.recipes.com' end
- Uses HTTParty
- Built in caching
- Built in save to file
- Built in response parsing (part of HTTParty)
- Built in convert and save to CSV
- Designed for GET-only APIs (e.g., data services)
Create a class and inherit from
This class automatically includes HTTParty, so you can do whatever you do in
HTTParty. In addition, the
APICake::Base class defines a
method, so any call to an undefined method, will simply be converted to a
class Recipes << APICake::Base base_uri 'api.recipes.com/v1' end recipes = Recipes.new # This will access http://api.recipes.com/v1/cakes recipes.cakes # This will access http://api.recipes.com/v1/cakes/chocolate recipes.cakes 'chocolate' # This will access http://api.recipes.com/v1/cakes/chocolate?layers=3 recipes.cakes 'chocolate', layers: 3
See the Examples folder for more examples.
APICake uses Lightly for caching. By default, cached objects are stored
./cache directory for 3600 seconds.
See the caching example.
For a detailed explanation of the services and methods you get when inheriting
APICake::Base, see the class documentation.
Real World Examples
These gems use APICake:
- Fredric - API wrapper for the FRED database (go straight to API class)
- Intrinio - API wrapper for the Intrinio data service (go straight to API class)
- Quata - API wrapper for the Quandl data service (go straight to API class)