Designing an API

1,188 views
1,124 views

Published on

History, design choices, service aggregation, levels of REST,

Published in: Business, Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,188
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
12
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Designing an API

  1. 1. API Design Choices: Audience,Aggregation & beyondBy Jacob Ideskog, Solution Architect@jacobideskog, @2botechCopyright © 2013 Twobo Technologies AB. All rights reserved.
  2. 2. Agenda History Trends REST Aggregation vs MashupsCopyright © 2013 Twobo Technologies AB. All rights reserved.
  3. 3. Disruptive trendsCloudComputingSocialNetworksMobileBigDataCopyright © 2013 Twobo Technologies AB. All rights reserved.
  4. 4. Back in the daysCopyright © 2013 Twobo Technologies AB. Allrights reservedWeb apps have evolvedfrom CGI tothe cloudHTTP, HTML, CGICOM & CORBASOAP & SOAWeb 2.0 & RESTThe CloudCloud APIs
  5. 5. How to start? Design-by-buzzwordCopyright © 2013 Twobo Technologies AB. Allrights reservedHypermediaNode.jsJSON REST
  6. 6. Target Audience Who is it for? Apps? Mobile Apps? Internal Apps Other Services? All of the above?Copyright © 2013 Twobo Technologies AB. Allrights reserved
  7. 7. Target Architecture What are you serving Processing services Data services Communication services ?Copyright © 2013 Twobo Technologies AB. Allrights reserved
  8. 8. The glorious REST Representional State Transfer Highly Scalable Uses URI identifiers No state on server side Hyperlinked No uniform standard NOT A PROTOCOLCopyright © 2013 Twobo Technologies AB. Allrights reserved
  9. 9. Resource or serviceCopyright © 2013 Twobo Technologies AB. Allrights reserved http://martinfowler.com/articles/richardsonMaturityModel.htmlLevel 0: The Swamp of POXLevel 1: ResourceLevel 2: HTTP VerbsLevel 3: Hypermedia ControlsGlory of Rest
  10. 10. Level 0 Swamp of POXCopyright © 2013 Twobo Technologies AB. Allrights reservedCopyright © 2013 Twobo Technologies AB. Allrights reservedPOST <getBook>POST <deleteUser><book ...<ok .../api XML RPC all over again
  11. 11. Level 1 Resources Uses URIs But still XML messages as operationsCopyright © 2013 Twobo Technologies AB. Allrights reservedPOST <getBook>POST <deleteUser><book ...<ok .../books/2/users/24
  12. 12. Level 2 HTTP Verbs Utilizes the semantics of HTTPCopyright © 2013 Twobo Technologies AB. Allrights reservedGET - Read a resourceHEAD – Read metadata about resourceOPTIONS – Read what operations are availablePOST – Add a new resource, or run operationPUT – Replace existing resource completelyDELETE – Remove resource(PATCH – Update existing resource in place)GET ?pagesize=A4DELETE200 OK <book ...201 No Content/books/2/users/32
  13. 13. Level 3 The Glory of REST HATEOAS Hypermedia As The Engine Of Application State Or simply: Hypermedia Let the Media Type tell you what to do Hyperlink, hyperlink hyperlinkCopyright © 2013 Twobo Technologies AB. Allrights reserved
  14. 14. ExampleCopyright © 2013 Twobo Technologies AB. Allrights reservedcurl –v http://localhost/stuff<stuff xmlns:tt=http://example.com/rest tt:rel=”/stuff"><more-stuff tt:rel="/stuff/more-stuff"/><other-stuff tt:=”/stuff/other-stuff"/><data><entry>Interesting 1</entry><entry>Interesting 2</entry></stuff>curl –v http://localhost/stuff/more-stuff<more-stuff xmlns:tt=http://example.com/rest tt:rel=”/stuff/more-stuff"><things tt:rel="/stuff/more-stuff/things"/></more-stuff>
  15. 15. Ring a bell?Copyright © 2013 Twobo Technologies AB. Allrights reservedcurl –v http://localhost/v2/stuff<html><div id=“stuff”><a href=“/stuff/more-stuff”/><a href=“/stuff/other-stuff/><ol id=“data”><li id=“entry1”>Interesting 1</li><li id=“entry2”>Interesting 2</li></ol><form action=“/stuff” ><input type=“text” name=“value” /></form></div></html>
  16. 16. The Real World But? My API uses other APIsCopyright © 2013 Twobo Technologies AB. Allrights reserved
  17. 17. The power of Mashups Web mashup is easy API mashup is harder But the payoff is greater API aggregation is really hard And believe me, you’ll need to do it anyway…Copyright © 2013 Twobo Technologies AB. Allrights reserved
  18. 18. Mashups vs. AggregationsCopyright © 2013 Twobo Technologies AB. Allrights reservedMashup Aggregation
  19. 19. Why is it hard Different backend states and protocols Different authentication methods Different lookup schemes Backend versioningCopyright © 2013 Twobo Technologies AB. Allrights reserved1st Original APINew‘Aggregated’ API2ndOriginal APIOperationallyinteresting
  20. 20. Aggregators Don’t invent the wheel Once your API is advanced enough, you’ll have tomash-up But do you need aggregation? If so: Identify the “operationally interesting” area Focus on that Mashup the restCopyright © 2013 Twobo Technologies AB. All rights reserved
  21. 21. The Real World Ah, the power of API Gateways!Copyright © 2013 Twobo Technologies AB. Allrights reserved
  22. 22. Summary Who is it for? What are you selling? Hypermedia in REST Mash-ups vs. AggregationsCopyright © 2013 Twobo Technologies AB. Allrights reserved
  23. 23. Questions & thanks@2botechwww.2botech.com@jacobideskogCopyright © 2013 Twobo Technologies AB. All rights reserved

×