Slide 1

Slide 1 text

Building APIs that delight (Part I) 11 February 2014 Rorosyd Steven Ringo | stevenringo | [email protected]

Slide 2

Slide 2 text

$$$ Making it easier to do business with you

Slide 3

Slide 3 text

Platform-agnostic Decoupled Microservices Managed independently Software half-life

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

Will it fit in my head?

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

No content

Slide 8

Slide 8 text

No content

Slide 9

Slide 9 text

HTTPs RESTFUL

Slide 10

Slide 10 text

RESTFUL = REST + STFU + LOL

Slide 11

Slide 11 text

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.

Slide 12

Slide 12 text

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.

Slide 13

Slide 13 text

Affordances Easy discoverability of possible actions

Slide 14

Slide 14 text

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

Slide 15

Slide 15 text

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

Slide 16

Slide 16 text

Plural vs singular?

Slide 17

Slide 17 text

Nouns? calculate, translate, convert, subscribe, deploy* *so-called non-resources

Slide 18

Slide 18 text

No content

Slide 19

Slide 19 text

No content

Slide 20

Slide 20 text

A little secret:
 
 I don’t want to know about your persistence

Slide 21

Slide 21 text

/dogs/1482 /dogs/809608a0-92e1 /dogs/fido

Slide 22

Slide 22 text

/dogs/1482 /dogs/809608a0-92e1 /dogs/fido ✗

Slide 23

Slide 23 text

/dogs/1482 /dogs/809608a0-92e1 /dogs/fido ~ ✗

Slide 24

Slide 24 text

/dogs/1482 /dogs/809608a0-92e1 /dogs/fido ✓ ~ ✗

Slide 25

Slide 25 text

/vet/pittwater/dogs/fido /vet/7e9d37f0-92b7/dogs/ef6a43d3-cd7b

Slide 26

Slide 26 text

Representation

Slide 27

Slide 27 text

{ "invoices": [ { "invoiceId": "402892053e100406013e1024aaec00d7", "invoiceNumber": "INV00000091", "invoiceAmount": 801.73 } ], "paymentId": "402892053e100406013e1024ab7c00e3", "amountCollected": 801.73, "success": true } Pay invoice/s

Slide 28

Slide 28 text

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

Slide 29

Slide 29 text

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

Slide 30

Slide 30 text

One root JSON object Arrays of JSON primitives Echo changes Partial objects

Slide 31

Slide 31 text

GET /convert?from=AUD&to=USD&amount=100 POST /convert { "convert": { "from": "AUD", "to": "USD", "amount": 100, "account": { "id": "184498321" } } }

Slide 32

Slide 32 text

No content

Slide 33

Slide 33 text

Everything worked: 200 OK ! You did something wrong: 400 Bad Request ! We did something wrong: 500 Internal Server Error

Slide 34

Slide 34 text

201 Created 304 Not Modified 404 Not Found 401 Unauthorized 403 Forbidden

Slide 35

Slide 35 text

No content

Slide 36

Slide 36 text

Talking all the API things

Slide 37

Slide 37 text

SDKs testing tooling metrics caching versioning rate-limiting deployment authorisation authentication load balancing documentation

Slide 38

Slide 38 text

My big fat MF rails app

Slide 39

Slide 39 text

See you next time :-)