Upgrade to Pro — share decks privately, control downloads, hide ads and more …

API Driven Development

API Driven Development

This talk focuses on developer/user interaction, the philosophy behind the code we write, service oriented architecture, and layering APIs.

Kenneth Reitz

February 15, 2013
Tweet

More Decks by Kenneth Reitz

Other Decks in Programming

Transcript

  1. API Driven Development
    Kenneth Reitz
    How I Develop Things and Why.
    Thursday, October 11, 12

    View Slide

  2. Hi.
    Thursday, October 11, 12

    View Slide

  3. @kennethreitz
    Thursday, October 11, 12

    View Slide

  4. Thursday, October 11, 12

    View Slide

  5. Open Source
    Thursday, October 11, 12

    View Slide

  6. Requests
    HTTP for Humans
    Thursday, October 11, 12

    View Slide

  7. Httpbin.org
    $ curl http://httpbin.org/get?test=1
    {
    "url": "http://httpbin.org/get",
    "headers": {
    "Content-Length": "",
    "Connection": "keep-alive",
    "Accept": "*/*",
    "User-Agent": "curl/7.21.4 ...",
    "Host": "httpbin.org",
    "Content-Type": ""
    },
    "args": {
    “test”: “1”
    },
    "origin": "67.163.102.42"
    }
    Thursday, October 11, 12

    View Slide

  8. Et Cetera
    • Legit: Git Work ow for Humans
    • Envoy: Subprocess for Humans
    • Tablib: Tabular Data for Humans
    • Clint: CLI App Toolkit
    • Autoenv: Magic Shell Environments
    • OSX-GCC-Installer: Provokes Lawyers
    275+ More
    Thursday, October 11, 12

    View Slide

  9. Purpose
    Thursday, October 11, 12

    View Slide

  10. We’re Diverse.
    • Product guys: non-tech cofounders
    • Sales guys: hustlers
    • Marketers: spammers
    • Designers: pixel pushers
    • Developers: code monkeys
    We come from many backgrounds.
    Thursday, October 11, 12

    View Slide

  11. What do we have
    in common?
    Thursday, October 11, 12

    View Slide

  12. We’re Makers.
    • Product guys: visionaries
    • Sales guys: sustainability
    • Marketers: communication
    • Designers: experience and philosophy
    • Developers: make the magic happen
    We craft experiences & interfaces.
    Thursday, October 11, 12

    View Slide

  13. Developers!
    Developers, Developers, Developers.
    Thursday, October 11, 12

    View Slide

  14. — Steve Jobs, 1983
    People are going to be
    spending two or three hours a day
    with these machines — more than
    they spend with a car.
    Thursday, October 11, 12

    View Slide

  15. — Steve Jobs, 1983
    Software design must be given
    at least as much consideration
    as we give automobiles today
    — if not a lot more.
    Thursday, October 11, 12

    View Slide

  16. That worked.
    Thursday, October 11, 12

    View Slide

  17. Beautiful Interfaces.
    • Industrial Design
    • Web Interfaces
    • iOS, Android, Mobile Apps
    • Desktop Clients & Applications
    Today, beautiful applications abound.
    Thursday, October 11, 12

    View Slide

  18. Hackers are
    the real Makers.
    Thursday, October 11, 12

    View Slide

  19. Developers spend 8+ hours a day
    with APIs.
    Why are they treated di erently?
    Thursday, October 11, 12

    View Slide

  20. Web Application
    Thursday, October 11, 12

    View Slide

  21. Web Application
    Tools & Utilities Web Process Worker Process
    Thursday, October 11, 12

    View Slide

  22. Web Application
    Management Tools
    Supporting Services
    Tools & Utilities Web Process Worker Process
    Thursday, October 11, 12

    View Slide

  23. Web Application
    Management Tools
    Supporting Services
    Tools & Utilities Web Process Worker Process
    Scheduled Tasks
    Deferred Tasks
    Thursday, October 11, 12

    View Slide

  24. Web Application
    Management Tools
    Supporting Services
    Tools & Utilities Web Process Worker Process
    Scheduled Tasks
    Deferred Tasks
    API Service
    CRUD Admin
    Data Persistence
    User Interface
    Authentication
    Thursday, October 11, 12

    View Slide

  25. Thursday, October 11, 12

    View Slide

  26. Web Application
    Management Tools
    Supporting Services
    Tools & Utilities Web Process Worker Process
    Scheduled Tasks
    Deferred Tasks
    API Service
    CRUD Admin
    Data Persistence
    User Interface
    Authentication
    Thursday, October 11, 12

    View Slide

  27. Web Application
    Management Tools
    Supporting Services
    Tools & Utilities Web Process Worker Process
    Scheduled Tasks
    Deferred Tasks
    API Service
    CRUD Admin
    Data Persistence
    User Interface
    Authentication
    Thursday, October 11, 12

    View Slide

  28. Web Application
    Management Tools
    Supporting Services
    Tools & Utilities Web Process Worker Process
    Scheduled Tasks
    Deferred Tasks
    API Service
    CRUD Admin
    Data Persistence
    User Interface
    Authentication
    Thursday, October 11, 12

    View Slide

  29. Web Application
    Management Tools
    Supporting Services
    Tools & Utilities Web Process Worker Process
    Scheduled Tasks
    Deferred Tasks
    API Service
    CRUD Admin
    Data Persistence
    User Interface
    Authentication
    Thursday, October 11, 12

    View Slide

  30. Web Application
    Management Tools
    Supporting Services
    Tools & Utilities Web Process Worker Process
    Scheduled Tasks
    Deferred Tasks
    API Service
    CRUD Admin
    Data Persistence
    User Interface
    Authentication
    Thursday, October 11, 12

    View Slide

  31. Web Application
    Management Tools
    Supporting Services
    Tools & Utilities Web Process Worker Process
    Scheduled Tasks
    Deferred Tasks
    API Service
    CRUD Admin
    Data Persistence
    User Interface
    Authentication
    Thursday, October 11, 12

    View Slide

  32. Web Application
    Management Tools
    Supporting Services
    Tools & Utilities Web Process Worker Process
    Scheduled Tasks
    Deferred Tasks
    API Service
    CRUD Admin
    Data Persistence
    User Interface
    Authentication
    Thursday, October 11, 12

    View Slide

  33. Web Application
    Management Tools
    Supporting Services
    Tools & Utilities Web Process Worker Process
    Scheduled Tasks
    Deferred Tasks
    API Service
    CRUD Admin
    Data Persistence
    User Interface
    Authentication
    Thursday, October 11, 12

    View Slide

  34. Web Application
    Management Tools
    Supporting Services
    Tools & Utilities Web Process Worker Process
    Scheduled Tasks
    Deferred Tasks
    API Service
    CRUD Admin
    Data Persistence
    User Interface
    Authentication
    Thursday, October 11, 12

    View Slide

  35. Web Application
    Management Tools
    Supporting Services
    Tools & Utilities Web Process Worker Process
    Scheduled Tasks
    Deferred Tasks
    API Service
    CRUD Admin
    Data Persistence
    User Interface
    Authentication
    Thursday, October 11, 12

    View Slide

  36. Web Application
    Management Tools
    Supporting Services
    Tools & Utilities Web Process Worker Process
    Scheduled Tasks
    Deferred Tasks
    API Service
    CRUD Admin
    Data Persistence
    User Interface
    Authentication
    Thursday, October 11, 12

    View Slide

  37. Web Application
    Management Tools
    Supporting Services
    Tools & Utilities Web Process Worker Process
    Scheduled Tasks
    Deferred Tasks
    API Service
    CRUD Admin
    Data Persistence
    User Interface
    Authentication
    Thursday, October 11, 12

    View Slide

  38. Web Application
    Management Tools
    Supporting Services
    Tools & Utilities Web Process Worker Process
    Scheduled Tasks
    Deferred Tasks
    API Service
    CRUD Admin
    Data Persistence
    User Interface
    Authentication
    Thursday, October 11, 12

    View Slide

  39. Web Application
    Management Tools
    Supporting Services
    Tools & Utilities Web Process Worker Process
    Scheduled Tasks
    Deferred Tasks
    API Service
    CRUD Admin
    Data Persistence
    User Interface
    Authentication
    Thursday, October 11, 12

    View Slide

  40. Web Application
    Management Tools
    Supporting Services
    Tools & Utilities Web Process Worker Process
    Scheduled Tasks
    Deferred Tasks
    API Service
    CRUD Admin
    Data Persistence
    User Interface
    Authentication
    Thursday, October 11, 12

    View Slide

  41. Web Application
    Management Tools
    Supporting Services
    Tools & Utilities Web Process Worker Process
    Scheduled Tasks
    Deferred Tasks
    API Service
    CRUD Admin
    Data Persistence
    User Interface
    Authentication
    Thursday, October 11, 12

    View Slide

  42. Web Application
    Management Tools
    Supporting Services
    Tools & Utilities Web Process Worker Process
    Scheduled Tasks
    Deferred Tasks
    API Service
    CRUD Admin
    Data Persistence
    User Interface
    Authentication
    Thursday, October 11, 12

    View Slide

  43. Web Application
    Management Tools
    Supporting Services
    Tools & Utilities Web Process Worker Process
    Scheduled Tasks
    Deferred Tasks
    API Service
    CRUD Admin
    Data Persistence
    User Interface
    Authentication
    Thursday, October 11, 12

    View Slide

  44. Web Application
    Management Tools
    Supporting Services
    Tools & Utilities Web Process Worker Process
    Scheduled Tasks
    Deferred Tasks
    API Service
    CRUD Admin
    Data Persistence
    User Interface
    Authentication
    Thursday, October 11, 12

    View Slide

  45. Web Application
    Management Tools
    Supporting Services
    Tools & Utilities Web Process Worker Process
    Scheduled Tasks
    Deferred Tasks
    API Service
    CRUD Admin
    Data Persistence
    User Interface
    Authentication
    Thursday, October 11, 12

    View Slide

  46. Thursday, October 11, 12

    View Slide

  47. End Users
    Thursday, October 11, 12

    View Slide

  48. End Users
    Developers
    Thursday, October 11, 12

    View Slide

  49. End Users
    API Service
    Developers
    Thursday, October 11, 12

    View Slide

  50. API Service
    End Users
    API Service
    Developers
    Thursday, October 11, 12

    View Slide

  51. API Service
    End Users
    API Service
    Developers
    Thursday, October 11, 12

    View Slide

  52. API Service
    End Users
    API Service
    API Service
    Developers
    Thursday, October 11, 12

    View Slide

  53. API Service
    End Users
    API Service
    API Service
    Developers
    ( )
    Thursday, October 11, 12

    View Slide

  54. API Service
    End Users
    API Service
    API Service
    Developers
    ( )
    Data Persistence
    Thursday, October 11, 12

    View Slide

  55. API Service
    End Users
    API Service
    Internal
    API Service
    Developers
    ( )
    Data Persistence
    Thursday, October 11, 12

    View Slide

  56. API Service
    End Users
    API Service
    Internal
    API Service
    Developers
    ( )
    Data Persistence
    Message Queue Workers
    Thursday, October 11, 12

    View Slide

  57. Everything is a remix*.
    * APIs Rule Everything Around Us.
    Thursday, October 11, 12

    View Slide

  58. How?
    Thursday, October 11, 12

    View Slide

  59. Step I: Have an Issue.
    Thursday, October 11, 12

    View Slide

  60. A Real, Tangible Problem.
    You can't solve a problem properly if
    you don't experience it rsthand.
    Thursday, October 11, 12

    View Slide

  61. Example: OneNote.
    • Hierarchical, freeform note-taking
    software that assumes nothing.
    • Only available on Windows.
    • I want to make OneNote for OS X.
    • It would be incredible.
    The nest note-taking platform on earth.
    Thursday, October 11, 12

    View Slide

  62. GitHub Success
    • GitHub wasn't built for the developer
    community at large.
    • Resonated with millions of developers.
    • They themselves happen to be
    developers.
    Over two million people collaborating.
    Thursday, October 11, 12

    View Slide

  63. Other’s Success
    • Gumroad, built for the founder.
    • 37 Signals product, build for the team.
    • Ruby on Rails, by Rubyists for Rubyists.
    Thursday, October 11, 12

    View Slide

  64. Optimization
    • Feature driven development?
    • Pro t driven development?
    • Growth driven development?
    • Problem driven development.
    What drives your decisions?
    Thursday, October 11, 12

    View Slide

  65. pra•gmat•ic |pragˈmatik|, adj:
    Dealing with things sensibly and realistically in
    a way that is based on practical rather than
    theoretical considerations
    Thursday, October 11, 12

    View Slide

  66. Requests Success
    • Python is a language built for Humans.
    • Why should HTTP be non-trivial?
    • I explored and discovered what I really
    needed, and built it.
    • I had a real problem that I solved for
    myself.
    Thursday, October 11, 12

    View Slide

  67. Requests Success
    • At rst, Requests was far from
    powerful.
    • But, it deeply resonated with people.
    • Features grew over time, but the API
    was never compromised.
    • Quite popular.
    Thursday, October 11, 12

    View Slide

  68. Developers spend 8+ hours a day
    with APIs.
    Build for yourself—a developer.
    Thursday, October 11, 12

    View Slide

  69. Step II: Respond.
    Thursday, October 11, 12

    View Slide

  70. Write the README.
    Thursday, October 11, 12

    View Slide

  71. • Before any code is written, write
    the README — show some
    examples.
    • Write some code with the
    theoretical code that you’ve
    documented.
    Thursday, October 11, 12

    View Slide

  72. Achievement Unlocked!
    • Instead of engineering something to get
    the job done, you interact with the
    problem itself and build an interface that
    reacts to it.
    • You discover it. You respond to it.
    Thursday, October 11, 12

    View Slide

  73. • Great sculptures aren’t engineered or
    manufactured—they’re discovered.
    • The sculptor studies and listens to the
    marble. He identi es with it.
    • Then, he responds.
    • Setting free something hidden that
    inside all along.
    Sculptures, Etc.
    Thursday, October 11, 12

    View Slide

  74. • It’s not about a design that will
    “work” on a phone, tablet, and
    desktop.
    • It’s about making something that
    identi es itself enough to respond to
    the environment it’s placed in.
    • Free of arbitrary constraints.
    Responsive Design
    Thursday, October 11, 12

    View Slide

  75. Readme-Driven Development?
    Responsive API Design.
    Thursday, October 11, 12

    View Slide

  76. Step III: Build.
    Thursday, October 11, 12

    View Slide

  77. • Once you discover the API: build it.
    • Write all the code necessary to make
    exactly what you documented happen.
    • Complex code? Layer your API.
    • “Porcelain” layer is documented.
    Responsive Design
    Thursday, October 11, 12

    View Slide

  78. The API is all that matters.
    Everything else is secondary.
    Thursday, October 11, 12

    View Slide

  79. Do unto others as you would have
    them do to you?
    Build tools for others that you want
    to be built for you.
    Thursday, October 11, 12

    View Slide

  80. Pro Tips™
    Thursday, October 11, 12

    View Slide

  81. CONSTRAINTS
    FOSTER
    CREATIVITY
    Thursday, October 11, 12

    View Slide

  82. Open Source
    All The Things!
    Thursday, October 11, 12

    View Slide

  83. Build for Open Source
    • Components become concise & decoupled.
    • Concerns separate themselves.
    • Best practices emerge (e.g. no creds in code).
    • Documentation and tests become crucial.
    • Code can be released at any time.
    Thursday, October 11, 12

    View Slide

  84. Build for Open Source
    • Components become concise & decoupled.
    • Concerns separate themselves.
    • Best practices emerge (e.g. no creds in code).
    • Documentation and tests become crucial.
    • Code can be released at any time.
    Thursday, October 11, 12

    View Slide

  85. Build for Services
    • Components become concise & decoupled.
    • Concerns seperate themselves.
    • Best practices emerge (e.g. ideal tools).
    • Documentation and contracts become crucial.
    • Services can be scaled separately at any time
    • Dogfood is delicious.
    Thursday, October 11, 12

    View Slide

  86. — Pieter Hintjens
    Simplicity is always
    better than functionality.
    Thursday, October 11, 12

    View Slide

  87. github.com/kennethreitz
    Questions?
    Thursday, October 11, 12

    View Slide