Designing Restful APIs


@skorfmann

Let's Build an API



"Hey, we will need an api!"
-
"Alright, brb - I'm gonna build you something"




YOU'RE DOING IT WRONG!

API Design Process



  1. Research
  2. Design
  3. Client (Mock Endpoint)
  4. Actual Implementation

Research


  • Audience
  • Goals

Design


  • Standards
  • Documentation
  • Feedback



Standards



Existing Standards



  • JSON API
  • HAL
  • Siren
  • Hyper JSON
  • ...

Documentation





  • API Blueprint
  • Slate
  • Swagger


API Blueprint



  • Markdown
  • Custom Extensions
  • API Mocks
  • Tools

Blueprint Markdown


+ Request JSON Message
    
    + Headers

            Accept: application/json

+ Response 200 (application/json)

    + Body

            { "message": "Hello World!" }  

Blueprint Markdown



+ Parameters

    + id (number, `1`)

Blueprint Tools



  • API Mock
  • Dredd (Test Your Documentation)
  • Aglio (Generate Static Website)


Apiary.io


  • Host API Blueprints
  • Code Examples
  • API Mock Endpoint






Client Implementation


  • Self-Contained
  • Mock Endpoint

Ember Data



Client Libraries



  • Mock Endpoint
  • Test Mode


Last But Not Least



  • Expected Errors
  • Exceptions
  • Testable Examples (Stripe)



Thanks!



@skorfmann

sebastian@saigonium-labs.com

Designing Restful APIs

By skorfmann

Designing Restful APIs

  • 892