Your SlideShare is downloading. ×
0
A Practical Guide to Hypermedia APIs     Eric Oestrich     @ericoestrich   @smartlogicsolutions
woofound.com
That was this project     Prepare yourself
Please note that this has been    heavily stripped down Dont want to give everything away
But firstHypermedia Basics
Resources != Models
HTTP is your friend methods and status codes
Client knows only one         URL         "/"
Media types    HAL
Sample HAL Response{ "status": "Processing", "_embedded": {   "items": [     {       "name": "Book",       "_links":{ "sel...
Server
Controllers● Use respond_to and respond_with
Models● Doesnt have to be a subclass of  ActiveRecord::Base
Serializers●   Disable root●   Links●   Embedded resources●   Changing serializer representations
Client
Basics● Uses Faraday● Basic auth over SSL
Resources● Data only● Convenience methods● Links
Loaders● Pull data down from the API● Only GETs
Services● Very similar to Loaders● Push data back up
Integrating with Rails
Problems● There are no ids● Speed
Resources● Creating a Hypermedia Client  ○ http://blog.oestrich.org/2012/12/creating-a-      hypermedia-client/● ActiveMod...
Useful gems for apis●   rspec_api_documentation●   raddocs●   letter●   json_spec●   vcr●   webmock●   cane
Hobostove    Campfire for the command linehttps://github.com/oestrich/hobostove
A Practical Guide to Hypermedia APIs
Upcoming SlideShare
Loading in...5
×

A Practical Guide to Hypermedia APIs

1,601

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
1,601
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
9
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "A Practical Guide to Hypermedia APIs"

  1. 1. A Practical Guide to Hypermedia APIs Eric Oestrich @ericoestrich @smartlogicsolutions
  2. 2. woofound.com
  3. 3. That was this project Prepare yourself
  4. 4. Please note that this has been heavily stripped down Dont want to give everything away
  5. 5. But firstHypermedia Basics
  6. 6. Resources != Models
  7. 7. HTTP is your friend methods and status codes
  8. 8. Client knows only one URL "/"
  9. 9. Media types HAL
  10. 10. Sample HAL Response{ "status": "Processing", "_embedded": { "items": [ { "name": "Book", "_links":{ "self": { "href" => "http://example.com/items/1" } } } ] }, "_links": { "self" => { "href" => "http://example.com/orders/1" } }}
  11. 11. Server
  12. 12. Controllers● Use respond_to and respond_with
  13. 13. Models● Doesnt have to be a subclass of ActiveRecord::Base
  14. 14. Serializers● Disable root● Links● Embedded resources● Changing serializer representations
  15. 15. Client
  16. 16. Basics● Uses Faraday● Basic auth over SSL
  17. 17. Resources● Data only● Convenience methods● Links
  18. 18. Loaders● Pull data down from the API● Only GETs
  19. 19. Services● Very similar to Loaders● Push data back up
  20. 20. Integrating with Rails
  21. 21. Problems● There are no ids● Speed
  22. 22. Resources● Creating a Hypermedia Client ○ http://blog.oestrich.org/2012/12/creating-a- hypermedia-client/● ActiveModel::Serializers ○ https://github.com/rails-api/active_model_serializers● Abusing ActiveModel::Serializers for HAL ○ http://blog.oestrich.org/2012/10/abusing-active- model-serializers-for-hal/● httpstatus.es
  23. 23. Useful gems for apis● rspec_api_documentation● raddocs● letter● json_spec● vcr● webmock● cane
  24. 24. Hobostove Campfire for the command linehttps://github.com/oestrich/hobostove
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×