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

Building APIs that delight (Part I)

Steven Ringo
February 14, 2014

Building APIs that delight (Part I)

An overview of building APIs in Ruby, Rails and related. Looking at REST, API design, tooling, documentation and practices.

Steven Ringo

February 14, 2014
Tweet

More Decks by Steven Ringo

Other Decks in Technology

Transcript

  1. A RESTifarian is a zealous proponent of the REST software

    architectural style as defined by Roy T. Fielding in Chapter 5 of his PhD. dissertation at UC Irvine. You can find RESTifarians in the wild on the REST-discuss mailing list. But be careful, RESTifarians can be extremely meticulous when discussing the finer points of REST.
  2. A RESTifarian is a zealous proponent of the REST software

    architectural style as defined by Roy T. Fielding in Chapter 5 of his PhD. dissertation at UC Irvine. You can find RESTifarians in the wild on the REST-discuss mailing list. But be careful, RESTifarians can be extremely meticulous when discussing the finer points of REST.
  3. Resource POST create GET read PUT / PATCH update* DELETE

    delete /dogs Create a new dog List dogs Bulk update dogs Delete all dogs /dogs/fido Show Fido Edit Fido Delete Fido
  4. Keep URLs simple and intuitive Avoid verbs* Keep to two

    base URLs per resource. Keep verbs out of your base URLs Use HTTP verbs on collections and elements
  5. { "invoices": [ { "invoiceId": "402892053e100406013e1024aaec00d7", "invoiceNumber": "INV00000091", "invoiceAmount": 801.73

    } ], "paymentId": "402892053e100406013e1024ab7c00e3", "amountCollected": 801.73, "success": true } Pay invoice/s
  6. { "payment": { "id": "402892053e100406013e1024ab7c00e3", "amount_collected": 801.73 }, "invoices": [

    { "invoice": { "id": "402892053e100406013e1024aaec00d7", "number": "INV00000091", "amount": 801.73 } } ] } Pay invoice/s
  7. { “invoice_payment": { "id": "402892053e100406013e1024ab7c00e3", "amount_collected": 801.73, "invoices": [ {

    "invoice": { "id": "402892053e100406013e1024aaec00d7", "number": "INV00000091", "amount": 801.73 } } ] } } Pay invoice/s
  8. GET /convert?from=AUD&to=USD&amount=100 POST /convert { "convert": { "from": "AUD", "to":

    "USD", "amount": 100, "account": { "id": "184498321" } } }
  9. Everything worked: 200 OK ! You did something wrong: 400

    Bad Request ! We did something wrong: 500 Internal Server Error