This document discusses making REST APIs more usable. It provides examples of REST API design principles like using hypermedia to link related resources, returning error responses consistently, and supporting multiple formats and authentication methods. REST APIs should aim to be discoverable, standardized, and usable for both developers and end users.
11. La usabilidad Web es un
enfoque para construir
sitios web faciles de usar
'
para un usuario final, sin
que se requiera ninguna
formacion especializada
'
17. modelo de
recursos
Autenticación y
(NO) Estado
formatos
Estados y gestión versionado
de errores múltiples
analítica consumidores
monetización paginación
Documentación Escalabilidad
first class api? cuotas
metadatos
… y uSaBiLidAd cachés
18. BASIC ACCESS AUTHENTICATION
authenticate_or_request_with_http_basic do |login, password|
User.find_by_login_and_password login, password
end
User and password must be passed every time
TOKEN
Digest::SHA1.hexdigest( Time.now.to_s.split(//).sort_by {rand}.join )
User.find_by_login_and_api_key( params[:login], params[:api_key] )
Client can send it as a parameter or as a header
OAUTH
Depends on third party libraries
Requires initial registration of client and more integration
20. huddle
twitter 200 OK
200 OK Success! 201 Created
304 Not Modified 202 Accepted
400 Bad Request 400 Bad Request
401 Unauthorized 401
403 Forbidden Unauthorized
404 Not Found 403 Forbidden
406 Not Acceptable 404 Not Found
420 Enhance Your Calm 410 Gone
invoicefu
500 Internal Server
200 OK Success!
Error
201 Created
502 Bad Gateway
304 Not Modified
503 Service Unavailable
401 Unauthorized
404 Not Found
Useful Status 422 Unprocessable Entity
429 Too many requests 406 Not Acceptable
204 No Content 500 Internal Server Error
21. Accept: application/vnd.aspgems.invoicefu.v1.xml
THE
ACCEPT
HEADER
HTTP/REST Standard Not everyone Less obvious
Unambiguous supports headers Harder to use
Resources != or custom types. Non standard content-
Representations Generic content types
Version as you need it types are Skips HTTP server logs
preferred
22.
23.
24. REST explicado por un señor
que tan listo no será cuando
no usa gafas
client-server,stateless,layered,cacheable
Resources
Resource Identifiers
Resource metadata
Uniform interface
operations
Representations
Representation metadata
HATEOAS
Optionally: code on demand señor sin gafas
25. INTERFAZ UNIFORME
get, HEAD, TRACE,
OPTIONS
post, put*, delete*,
PATCH*
*fallbacks para clientes viejos o
incompletos
35. Mike Kelly
{
"_links": {
"self": { "href": "..." }
},
"title": "Real World ASP.NET MVC3",
"description": "In this advanced, somewhat-opinionated...",
"permitted": true,
"_embedded": {
"episodes": [{
"_links": {
"self": { "href": "..." },
"media": [{
"type": "video/webm; codecs='vp8.0, vorbis'",
"href": "..."
},{
"type": "video/ogg; codecs='theora, vorbis'",
"href": "..."
}]
},
"title": "Foundations",
"description": "In this episode we talk about what it is we're doing: building our
startup and getting ourselves off the ground. We take..",
"released": 1306972800
}