Unleashing Hyperdrive

Unleashing Hyperdrive

Unleashing Hyperdrive, a Swift API client utilising Hypermedia and API Blueprint

D200a17dd269fd4001bacb11662dab4b?s=128

Kyle Fuller

April 17, 2015
Tweet

Transcript

  1. Hyperdrive API Client in Swift

  2. None
  3. Traditionally

  4. "Move fast and break things" Mark Zuckerberg, Facebook

  5. "Each version will remain for at least 2 years from

    release." Facebook
  6. None
  7. None
  8. Move Fast, Break Nothing

  9. Designing API by exposing implementation details

  10. API Evolvability

  11. Ability to change implementation details

  12. Learn about controls, relations and transitions at run-time

  13. Adding new features

  14. Remove features

  15. Ability to change implementation details 4 Change fields used in

    forms 4 Change validation of attributes in forms 4 Change URIs of resources (/polls/{id} -> / questions/{slug}) 4 Change HTTP methods (PUT -> PATCH) 4 Change the content-type
  16. Teach Clients Semantic meaning of the Domain

  17. Don’t hard-code implementation details

  18. Hyperdrive

  19. hyperdrive(apiary: "pollsapi")

  20. hyperdrive(blueprint: "https://polls.apiblueprint.org/")

  21. hyperdrive(apiary: "pollsapi") { result in // Explore API feature availability

    }
  22. hyperdrive.enter("https://polls.apiblueprint.org/") { result in // Explore API feature availability }

  23. Representor

  24. if let questions = representor.links["questions"] { // The API offered

    us a link to questions } else { // Gracefully handle when this feature is missing }
  25. hyperdrive.request(questions) { result in }

  26. representor.links

  27. representor.transitions

  28. if let create = representor.transitions["create"] { // API supports creation

    } else { // Feature is missing // Let's not show the create button in our UI }
  29. let attributes = [ "question": "Favourite language?", "choices": [ "Swift",

    "Ruby", "Python", ] ] hyperdrive.request(create, attributes) { }
  30. create.attributes

  31. None
  32. create.validate(["email": "kyle"]) ❌

  33. create.validate(["email": "kyle@apiary.io"]) ✅

  34. None
  35. None
  36. Change our API

  37. Demo

  38. Hyperdrive

  39. Hyperdrive β

  40. None
  41. kyle fuller kyle @ apiary.io