Understanding and Using Rest APIs

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    Favorites, Groups & Events

    Understanding and Using Rest APIs - Presentation Transcript

    1. REST 11.07.2009
      Understanding and Using RESTful APIs
    2. About Me
      • Developing software for 15 years
      • Bulk of experience on enterprise-scale applications
      • Microsoft platform (mostly)
      • KeyLimeTie
    3. Overview
      Although REST is 10 years old, APIs based on the REST model continue to become an integral part of the technology landscape.
      ProgrammableWeb.com lists 1051 RESTful APIs, 4422 Mashups.
      We’ll look at
      • Basic REST Concepts
      • Using REST
      • WADL
    4. Rest overview
    5. REST Overview
      APIs based on the Representational State Transfer (REST) architecture dominate web 2.0 mash-up and social media development.
      There are a number of frameworks available that support the development of RESTful APIs (WCF, JAX-RS, Wicket, Zend)
      We are still missing an established mechanism for documentation and discovery and client-side tool support for rapid implementation.
    6. REST Overview
      REST-style architectures consist of clients and servers.
      Requests and responses are built around the transfer of "representations" of "resources".
      A resource is any entity that can be addressed in a URI (an account, an employee, a physical file)
      A representation of a resource is any information that captures the current or intended state of a resource. All information necessary to process and complete a request is contained within it.
    7. Example
      Resource (Twitter Public Timeline) http://twitter.com/statuses/public_timeline.xml
      Resource (Twitter User)
      http://twitter.com/users/petermorano.xml
    8. REST Overview
      REST-style architectures consist of clients and servers.
      Requests and responses are built around the transfer of "representations" of "resources".
      A resource is any entity that can be addressed in a URI (an account, an employee, a physical file)
      A representation of a resource is any information that captures the current or intended state of a resource. All information necessary to process and complete a request is contained within it.
    9. Wait a Minute
      If this sounds a lot like the Web, it’s because the Web is a REST implementation
      Roy Fielding, who created REST, was also one of the principal authors of HTTP
    10. REST Basics
      The REST architecture was designed around a few key principles:
      • Use HTTP Methods (and Response Codes)
      • Be Stateless and Cacheable
      • Use Addressable Resources
      • Support the transfer of Representations
    11. REST Basics
      The REST architecture was designed around a few key principles:
      • Use HTTP Methods (and Response Codes)
      • Be Stateless and Cacheable
      • Use Addressable Resources
      • Support the transfer of Representations
    12. HTTP Methods
      Map to CRUD Operations
      Action
      SQL
      HTTP Method
      Create
      Insert
      Post
      Read
      Select
      Get
      Update
      Update
      Put
      Delete
      Delete
      Delete
    13. URI Examples
      GET
      http://www.example.com/v1/employees
      GET
      http://www.example.com/v1/employees/1824
      POST
      http://www.example.com/v1/employees
      PUT
      http://www.example.com/v1/employees/1513
      DELETE
      http://www.example.com/v1/employees/1222
    14. REST Basics
      The REST architecture was designed around a few key principles:
      • Use HTTP Methods (and Response Codes)
      • Be Stateless and Cacheable
      • Use Addressable Resources
      • Support the transfer of Representations
    15. Stateless and Cacheable
      • No State Stored on the Server
      • Every HTTP request executes in complete isolation on the server
      • Easier to scale because of GET method
    16. REST Basics
      The REST architecture was designed around a few key principles:
      • Use HTTP Methods (and Response Codes)
      • Be Stateless and Cacheable
      • Use Addressable Resources
      • Support the transfer of Representations
    17. Resources
      • Any THING – person, concept, artifact
      • Anything you can point to
      • Explicit Request and Response – No State
    18. REST Basics
      The REST architecture was designed around a few key principles:
      • Use HTTP Methods (and Response Codes)
      • Be Stateless and Cacheable
      • Addressable Resources
      • Support the transfer of Representations
    19. Representations
      • A serializable description of a Resource
      • Resources are modifiable through Representations
      • XML
      • JSON
      • Binary Formats (jpg, gif, mpeg)
    20. REST Pros
      Cacheable
      Scalable
      Different Representations
      Human Readable Results
      Lightweight
    21. REST Cons
      Must be HTTP
      No Atomic Transactions
      No Standards for security except HTTPS
      No Standardized Discovery
    22. REST vs. SOAP
      Unlike SOAP-based web services, there is no "official" standard for RESTful web service.
      Though not a standard, a RESTful implementation uses standards like HTTP, URL, XML, GIF, etc.
    23. REST vs. SOAP
      SOAP
      • Protocol
      • Verbose Payload
      • Envelope
      • Not easily readable
      • Requires Development Tools
      • Uses POST Method
      • Supports Transactions
      • Standardized Discovery
      • WSDL
      REST
      • Architecture
      • Lightweight Payload
      • Postcard
      • Human Readable Results
      • Easy to work with, Brower-testable
      • GET Method supports caching
      • No Transactions
      • Discovery
      • WADL?
    24. USING Rest
    25. USING REST
      Think of a REST API as another data source
      Details depend on the language, but there are common steps:
      • Serialize the representation (if PUT or POST)
      • Format the URI (parameters, variables)
      • Encode Authentication into the Header
      • Make Call
      • Deserialize Response
    26. USING REST
      Three basic options for consuming RESTful APIs
      • Use the service’s toolkit (not always available)
      • Community-built library/wrapper
      • code.google.com
      • www.codeplex.com
      • Code your own implementation
    27. Community Built
      Upside
      • Ready to use
      Downside
      • It’s not your code
      • You may be waiting for the library to become available.
      • Enterprise clients may have concerns
    28. Writing Your Own
      Upside
      • You know the code
      Downside
      • Manual Discovery Process
      • Implementation can be tedious
    29. Tools
      Tools for testing RESTful APIs
      • Curl
      • Eclipse Http4e
      • Fiddler
      • Your Browser (limited)
    30. WADL
    31. WADL
      Web Application Discovery Language (WADL)
      Created in 2005 by Marc Hadley of Sun Microsystems
      Submitted to W3C on 8/31/2009
      REST’s Answer to WSDL
      Specification: https://wadl.dev.java.net/
    32. What WADL Gets You
      Reduced Errors in Discovery
      Opportunities for Code Generation
      Spend more time building your application and less time implementing APIs
    33. So Where Is It?
      Currently in Submission to W3C
      API Providers are slow to adopt, so tool providers are slow to implement
      There are projects underway to generate code from WADL, and at least one tool that helps in creating WADL
    34. WADL Demo
      Project on code.google.com
      Online Version: http://tomayac.de/rest-describe/latest/RestDescribe.html
    35. References
      http://en.wikipedia.org/wiki/Representational_State_Transfer
      http://weblogs.java.net/blog/mhadley/archive/2005/05/introducing_wad.html
      http://blog.tomayac.de/index.php?date=2007-05-23
      RESTful Web Services – Richardson, Ruby – O’Reilly Press
    SlideShare Zeitgeist 2009

    + Peter MoranoPeter Morano Nominate

    custom

    157 views, 0 favs, 0 embeds more stats

    Understanding and Using Rest APIs presented at Soci more

    More info about this document

    © All Rights Reserved

    Go to text version

    • Total Views 157
      • 157 on SlideShare
      • 0 from embeds
    • Comments 0
    • Favorites 0
    • Downloads 4
    Most viewed embeds

    more

    All embeds

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?

    Categories