All these "best practices" are exactly why I embraced GraphQL quickly and flushed "REST" down the toilets for big projects (http+json is fine for small ones, since no lib overhead). GraphQL is unashamedly the new SOAP. I.e. we have a spec, not a series of "best practices" thus endless architectural debates where people are shamed for 'doing it the wrong way' online. - Accept and respond with JSON: No, why? what if I…
> GraphQL is unashamedly the new SOAP ...may not be the advertising you think it is.
Best practices for REST API design (2020)
11–20 of 273 posts
Re: Best practices for REST API design (2020)
#12Great post. Nothing flashy, walks through basics and principles. I do love the simplicity of REST and unless you need some graph would recommend folks stick with it over GraphQL
Re: Best practices for REST API design (2020)
#13> Then if we try to submit the payload with the email value that already exists in users, we’ll get a 400 response status code with a 'User already exists' message to let users know that the user already exists. With that information, the user can correct the action by changing the email to something that doesn’t exist. I was always under the impression that 409 would be the "correct" code here, while you'd use 400 i…
The ambiguity is probably why most people just use 400 and call it a day.
Re: Best practices for REST API design (2020)
#14I interrupted my reading at 'Accept and respond with JSON' to write this comment, before I skipped over that section and returned to reading the rest. Folks that aren't aware of Webmachine should take a look: https://github.com/webmachine/webmachine The 'Accept' header should determine the response type, but content negotiation is something that few bother to implement. Webmachine does that for you, among other thing…
Also, the HTTP decision diagram: https://github.com/for-GET/http-decision-diagram/tree/master...
Re: Best practices for REST API design (2020)
#15Re: Best practices for REST API design (2020)
#16GraphQL is far superior for development speed, API flexibility and extensibility, authorisation, discovery, testing, and less bugs.
Re: Best practices for REST API design (2020)
#17> Then if we try to submit the payload with the email value that already exists in users, we’ll get a 400 response status code with a 'User already exists' message to let users know that the user already exists. With that information, the user can correct the action by changing the email to something that doesn’t exist. I was always under the impression that 409 would be the "correct" code here, while you'd use 400 i…
Isn’t 409 if you’re trying to update an existing record (PUT) and not create a new record (POST)? The ambiguity is probably why most people just use 400 and call it a day.
Re: Best practices for REST API design (2020)
#18I've written a comprehensive one on this topic a few years ago: https://www.vinaysahni.com/best-practices-for-a-pragmatic-re...
Re: Best practices for REST API design (2020)
#19How do you distinguish between an invalid path (no end point) and a valid path requesting a resource that doesn’t exist?
Re: Best practices for REST API design (2020)
#20All these "best practices" are exactly why I embraced GraphQL quickly and flushed "REST" down the toilets for big projects (http+json is fine for small ones, since no lib overhead). GraphQL is unashamedly the new SOAP. I.e. we have a spec, not a series of "best practices" thus endless architectural debates where people are shamed for 'doing it the wrong way' online. - Accept and respond with JSON: No, why? what if I…