wangyaodi@gmail.com	

     2011/07/24	



  Copyright 2010, Intridea Inc. All Rights Reserved.
About Me	

                     Symbol - yorzi	

                      Details - about.me/wangyaodi                      	

                      Senior Engineer at Intridea Inc.	


                    More Links:	

        	

          http://github.com/yorzi	

                     http://twitter.com/yorzi	

Andy Wang	

         http://more-sites/yorzi	



                Copyright 2010, Intridea Inc. All Rights Reserved.
What’s Grape?	




    Copyright 2010, Intridea Inc. All Rights Reserved.
Copyright 2010, Intridea Inc. All Rights Reserved.
https://github.com/mbleigh	

     https://github.com/intridea/omniauth	

https://github.com/mbleigh/acts-as-taggable-on	



                 Copyright 2010, Intridea Inc. All Rights Reserved.
Ok, BUT
What’s Grape?	




    Copyright 2010, Intridea Inc. All Rights Reserved.
“An opinionated
      micro-framework 
    for creating REST-like
         APIs in Ruby”	


        https://github.com/intridea/grape	

http://www.infoq.com/articles/rest-introduction	

                 Copyright 2010, Intridea Inc. All Rights Reserved.
Ruby makes hard
  things easy	




     Copyright 2010, Intridea Inc. All Rights Reserved.
But APIs still
 aren’t easy	




    Copyright 2010, Intridea Inc. All Rights Reserved.
APIs in Rails are
 too entangled	




     Copyright 2010, Intridea Inc. All Rights Reserved.
APIs in Sinatra are
   too manual	




      Copyright 2010, Intridea Inc. All Rights Reserved.
Copyright 2010, Intridea Inc. All Rights Reserved.
Copyright 2010, Intridea Inc. All Rights Reserved.
How To Use Grape?	




      Copyright 2010, Intridea Inc. All Rights Reserved.
Copyright 2010, Intridea Inc. All Rights Reserved.
Remember:
    Grape APIs are
   Rack applications	


http://ruby.about.com/od/rack/a/What-Is-Rack.htm	

                 Copyright 2010, Intridea Inc. All Rights Reserved.
Basic API	





  Copyright 2010, Intridea Inc. All Rights Reserved.
Result,
JSON Serialization	




      Copyright 2010, Intridea Inc. All Rights Reserved.
Add Prefix	





  Copyright 2010, Intridea Inc. All Rights Reserved.
Add Version




   Copyright 2010, Intridea Inc. All Rights Reserved.
Add Namespace




     Copyright 2010, Intridea Inc. All Rights Reserved.
Other Namespacing 
    Key words	





      Copyright 2010, Intridea Inc. All Rights Reserved.
Add Basic Auth




     Copyright 2010, Intridea Inc. All Rights Reserved.
Use Helpers




   Copyright 2010, Intridea Inc. All Rights Reserved.
Raise Error




   Copyright 2010, Intridea Inc. All Rights Reserved.
Error Details	





   Copyright 2010, Intridea Inc. All Rights Reserved.
How To 
Run Grape APIs?	




     Copyright 2010, Intridea Inc. All Rights Reserved.
Remember:
 Grape APIs are
Rack applications	



      Copyright 2010, Intridea Inc. All Rights Reserved.
Run As a Rack App	




Run `rackup` in Rack App(API) folder	




          Copyright 2010, Intridea Inc. All Rights Reserved.
Grape with Rails 2.3.x	





        Copyright 2010, Intridea Inc. All Rights Reserved.
Grape with Rails 3.x	





       Copyright 2010, Intridea Inc. All Rights Reserved.
Any Future Feature?
       YES!	




        Copyright 2010, Intridea Inc. All Rights Reserved.
Near Future	

         *Support for XML formatting	

        *Multiple-file APIs (modularity)	

   *OAuth 1.0a and 2.0 authentication support	

                Filters/Callbacks	



      https://github.com/makandra/modularity	

http://code.dblock.org/modularizing-a-ror-grape-api	

                  Copyright 2010, Intridea Inc. All Rights Reserved.
Medium Future	

YARD extensions for self-documenting APIs	

    Plugin System for easy extension	

           Internal API Access	

              Rate Limiting	

          Lifecycle Automation	



              Copyright 2010, Intridea Inc. All Rights Reserved.
Far Future	

Streaming API support	

   PubSubHubBub	





    Copyright 2010, Intridea Inc. All Rights Reserved.
Resources  References	

     RubyConf 2010 presentation about Grape.	

 http://confreaks.net/videos/475-rubyconf2010-the-
                   grapes-of-rapid	

  https://github.com/downloads/intridea/grape/The
            %20Grapes%20of%20Rapid.pdf	


           Example Rails implementation	

 http://martinciu.com/2011/01/mounting-grape-api-
             inside-rails-application.html	


                 Copyright 2010, Intridea Inc. All Rights Reserved.
Demo  Sample	

    Demo API with Sinatra App.	

https://github.com/mbleigh/conf_ask	

http://www.arailsdemo.com/posts/30	


   Well Documented Sample API.	

   https://gist.github.com/892282	





          Copyright 2010, Intridea Inc. All Rights Reserved.
Copyright 2010, Intridea Inc. All Rights Reserved.
Thank You!	




   Copyright 2010, Intridea Inc. All Rights Reserved.

Rapid-ruby-api-on-grape

  • 1.
    wangyaodi@gmail.com 2011/07/24 Copyright 2010, Intridea Inc. All Rights Reserved.
  • 2.
    About Me  Symbol - yorzi Details - about.me/wangyaodi Senior Engineer at Intridea Inc. More Links:  http://github.com/yorzi  http://twitter.com/yorzi Andy Wang  http://more-sites/yorzi Copyright 2010, Intridea Inc. All Rights Reserved.
  • 3.
    What’s Grape? Copyright 2010, Intridea Inc. All Rights Reserved.
  • 4.
    Copyright 2010, IntrideaInc. All Rights Reserved.
  • 5.
    https://github.com/mbleigh https://github.com/intridea/omniauth https://github.com/mbleigh/acts-as-taggable-on Copyright 2010, Intridea Inc. All Rights Reserved.
  • 6.
    Ok, BUT What’s Grape? Copyright 2010, Intridea Inc. All Rights Reserved.
  • 7.
    “An opinionated micro-framework for creating REST-like APIs in Ruby” https://github.com/intridea/grape http://www.infoq.com/articles/rest-introduction Copyright 2010, Intridea Inc. All Rights Reserved.
  • 8.
    Ruby makes hard things easy Copyright 2010, Intridea Inc. All Rights Reserved.
  • 9.
    But APIs still aren’t easy Copyright 2010, Intridea Inc. All Rights Reserved.
  • 10.
    APIs in Railsare too entangled Copyright 2010, Intridea Inc. All Rights Reserved.
  • 11.
    APIs in Sinatraare too manual Copyright 2010, Intridea Inc. All Rights Reserved.
  • 12.
    Copyright 2010, IntrideaInc. All Rights Reserved.
  • 13.
    Copyright 2010, IntrideaInc. All Rights Reserved.
  • 14.
    How To UseGrape? Copyright 2010, Intridea Inc. All Rights Reserved.
  • 15.
    Copyright 2010, IntrideaInc. All Rights Reserved.
  • 16.
    Remember: Grape APIs are Rack applications http://ruby.about.com/od/rack/a/What-Is-Rack.htm Copyright 2010, Intridea Inc. All Rights Reserved.
  • 17.
    Basic API Copyright 2010, Intridea Inc. All Rights Reserved.
  • 18.
    Result, JSON Serialization Copyright 2010, Intridea Inc. All Rights Reserved.
  • 19.
    Add Prefix Copyright 2010, Intridea Inc. All Rights Reserved.
  • 20.
    Add Version Copyright 2010, Intridea Inc. All Rights Reserved.
  • 21.
    Add Namespace Copyright 2010, Intridea Inc. All Rights Reserved.
  • 22.
    Other Namespacing Key words Copyright 2010, Intridea Inc. All Rights Reserved.
  • 23.
    Add Basic Auth Copyright 2010, Intridea Inc. All Rights Reserved.
  • 24.
    Use Helpers Copyright 2010, Intridea Inc. All Rights Reserved.
  • 25.
    Raise Error Copyright 2010, Intridea Inc. All Rights Reserved.
  • 26.
    Error Details Copyright 2010, Intridea Inc. All Rights Reserved.
  • 27.
    How To RunGrape APIs? Copyright 2010, Intridea Inc. All Rights Reserved.
  • 28.
    Remember: Grape APIsare Rack applications Copyright 2010, Intridea Inc. All Rights Reserved.
  • 29.
    Run As aRack App Run `rackup` in Rack App(API) folder Copyright 2010, Intridea Inc. All Rights Reserved.
  • 30.
    Grape with Rails2.3.x Copyright 2010, Intridea Inc. All Rights Reserved.
  • 31.
    Grape with Rails3.x Copyright 2010, Intridea Inc. All Rights Reserved.
  • 32.
    Any Future Feature? YES! Copyright 2010, Intridea Inc. All Rights Reserved.
  • 33.
    Near Future *Support for XML formatting *Multiple-file APIs (modularity) *OAuth 1.0a and 2.0 authentication support Filters/Callbacks https://github.com/makandra/modularity http://code.dblock.org/modularizing-a-ror-grape-api Copyright 2010, Intridea Inc. All Rights Reserved.
  • 34.
    Medium Future YARD extensionsfor self-documenting APIs Plugin System for easy extension Internal API Access Rate Limiting Lifecycle Automation Copyright 2010, Intridea Inc. All Rights Reserved.
  • 35.
    Far Future Streaming APIsupport PubSubHubBub Copyright 2010, Intridea Inc. All Rights Reserved.
  • 36.
    Resources References RubyConf 2010 presentation about Grape. http://confreaks.net/videos/475-rubyconf2010-the- grapes-of-rapid https://github.com/downloads/intridea/grape/The %20Grapes%20of%20Rapid.pdf Example Rails implementation http://martinciu.com/2011/01/mounting-grape-api- inside-rails-application.html Copyright 2010, Intridea Inc. All Rights Reserved.
  • 37.
    Demo Sample Demo API with Sinatra App. https://github.com/mbleigh/conf_ask http://www.arailsdemo.com/posts/30 Well Documented Sample API. https://gist.github.com/892282 Copyright 2010, Intridea Inc. All Rights Reserved.
  • 38.
    Copyright 2010, IntrideaInc. All Rights Reserved.
  • 39.
    Thank You! Copyright 2010, Intridea Inc. All Rights Reserved.