RESTful API with Grape

RESTful API with Grape

C4632f4ce0cf63e66d0bb89bce4b0369?s=128

Charles Lalonde

May 20, 2016
Tweet

Transcript

  1. 4.
  2. 5.
  3. 6.
  4. 7.
  5. 8.
  6. 9.
  7. 11.

    Why Grape? • Framework to build API • Easily extensible

    • Supports Rails, Sinatra 
 and others
  8. 13.

    • app/ • api/ • v1/ • base.rb Create folder

    structure Setup Rails in 4 simple steps
  9. 14.
  10. 16.

    Setup Rails in 4 simple steps • Versioning • Format

    • Endpoint mounting • Default headers • Logs
  11. 18.

    { Grape } Basic • Call Overview • Headers •

    Parameters • Http Methods • Error Handling • Helpers
  12. 19.

    Overview • Resource • Route params • HTTP methods •

    Parameters GET api.montrealrb.com/v1/:resource/:route_param
  13. 20.

    Headers • Useful for bots • Alerting users of deprecated

    endpoints • Allow multiple origins • etc
  14. 26.

    { Grape } gem extension WineBouncer 
 Oauth2 protection with

    Doorkeeper
 https://github.com/antek-drzewiecki/wine_bouncer grape-rails-cache
 Server side cache
 https://github.com/monterail/grape-rails-cache grape-swagger
 Automatically generate documentation
 https://github.com/ruby-grape/grape-swagger
  15. 28.
  16. 29.

    Unsplash API Stats API Requests 230 740 265 Last 30

    days API Developers 2 479 Approved Applications 184