I am not sure I follow his point about why HATEOAS is not practical, but I know that I have been able to make it work in my own REST APIs using content types. I only return JSON if the Accept header specifies "application/json". (Which is probably what you should be doing anyhow.) I usually also allow an HTML fragment response for the "text/html-fragment" Accept type. The default response type (or if "text/html" is e…
Designing a Pragmatic RESTful API
31–40 of 139 posts
Re: Designing a Pragmatic RESTful API
#32That article sums up exactly my own distillation into practical terms of all that information out there. I wish I had read it first.
Re: Designing a Pragmatic RESTful API
#33This is a well-written and informative article, kudos. That said, it reminds me how fucking overcomplicated REST HTTP API is for 99% of uses. As an API user, all I want is to call a function on a server, pass it some arguments and get a result. I want it to be dead simple, and REST is probably the opposite of that. Finally, it also occurs to me that most API calls may call one function which returns lots of data that…
If you want a performance advantage you must parse the limit-params and select only the needed fields from db and send them to client. But this make the backend complicated.
If something is misspelled (frontend/backend) you need more time to find the error.
It is easier and cleaner provide some additional calls for specific data (like lastLogin).
If you use something like Backbone in frontend, you are happy to access all needed data so easy, why restrict them?
Ok if you have an heavy used performance critic application, you can start optimizing. But why, welcome to the cloud, add some processes ;-)
Re: Designing a Pragmatic RESTful API
#34I am not sure I follow his point about why HATEOAS is not practical, but I know that I have been able to make it work in my own REST APIs using content types. I only return JSON if the Accept header specifies "application/json". (Which is probably what you should be doing anyhow.) I usually also allow an HTML fragment response for the "text/html-fragment" Accept type. The default response type (or if "text/html" is e…
Content types and HATEOAS are orthogonal properties, I'm not sure how you made the latter work using the former?
Re: Designing a Pragmatic RESTful API
#35I'm slightly a bigger proponent of HATEOAS, but if you don't need it yet, I think you can always add it in later. I've been the giver and receiver of bad things when it's not followed, but that is generally around massive projects.
Re: Designing a Pragmatic RESTful API
#36Re: Designing a Pragmatic RESTful API
#37Re: Designing a Pragmatic RESTful API
#38RESTful design is still one of the tricky problems I meet on a daily basis. For example, I have blog application in which each blog entry can have multiple versions in its revision history. What should the restful api look like to provide the ability to revert to a certain version?
You could then PATCH the BlogPost with the link to whatever BlogPostVersion you want to update to.
Curious to see what others would recommend.
Re: Designing a Pragmatic RESTful API
#39This is a well-written and informative article, kudos. That said, it reminds me how fucking overcomplicated REST HTTP API is for 99% of uses. As an API user, all I want is to call a function on a server, pass it some arguments and get a result. I want it to be dead simple, and REST is probably the opposite of that. Finally, it also occurs to me that most API calls may call one function which returns lots of data that…
REST only looks complicated because you're seeing it with RPC goggles. In REST, you don't call functions, you just ask for documents and send documents to the server(s). There's nothing particularly complicated in it, it's just a different approach. That said, this article isn't particularly faithful to REST.
Re: Designing a Pragmatic RESTful API
#40RESTful design is still one of the tricky problems I meet on a daily basis. For example, I have blog application in which each blog entry can have multiple versions in its revision history. What should the restful api look like to provide the ability to revert to a certain version?
Seriously REST isn't a mystery. I think the problem is few understand what it is. Here is my 30-second version:
1. Identification of resources and manipulation through representations. This means a network resource should have a URL that is the same no matter what you are doing to it - getting changing, removing, modifying or any custom manipulation. For the Web, use HTTP verbs and request body data to define the actions.
2. Self-descriptive error messages. Don't return 200 OK for everything. Use status codes and verbose response bodies to describe what happened.
3. Hypermedia as the engine of application state. Expose ALL functionality in HTML using hyperlinks and forms.