3 ms·
REST is an RPC?
by itake 4y ago
REST is an RPC?
- peterhunt 4y agoNot in the eyes of its creator https://roy.gbiv.com/untangled/2008/rest-apis-must-be-hypertext-driven https://roy.gbiv.com/untangled/2008/rest-apis-must-be-hypert...
- LudwigNagasena 4y agoIs there a single example of API that fits that definition of REST though?
- empthought 4y agoHATEOAS is the search term you want to use. “Hypermedia as the engine of application state.” PayPal and GitHub APIs tend to work this way. They return a pile of hyperlinks.
- LudwigNagasena 4y agoIf by "tend to work that way" you mean that they satisfy around 20% of the requirements in the post by Roy T. Fielding as opposed to other services that satisfy only 10%...
- empthought 4y agoI don't think you are familiar with the GitHub REST API; none of Fielding's points apply to it.
- LudwigNagasena 4y agoI honestly don’t know how someone can design a truly HATEOAS API without breaking everyone’s expectations and making it a chore for people to deal with it. If stuffing a bunch of links into your JSON response is what truly transforms your RPC into REST (I don’t see what else makes GitHub API so different from other APIs), then I don’t even know what’s the point of that. And surely it is only superficially similar to the non-API REST, ie how simple websites usually work.
- progval 4y agoHTTP+HTML+CSS (and Javascript) is the REST API used to communicate between clients (browsers) and servers. It's not a coincidence, it was the point of the thesis defining REST to formalize and improve the Web. See: https://www.ics.uci.edu/~fielding/pubs/dissertation/introduction.htm https://www.ics.uci.edu/~fielding/pubs/dissertation/introduc... In terms of what we think of as an API today, my favorite is SWORD: https://sword.cottagelabs.com https://sword.cottagelabs.com In particular, it does not define any URL scheme, client applications are expected to read links from the XML (for v1 and v2) or JSON (for v3) body.
- dboreham 4y agoYes. All these interactions are "request message with immediate response message" protocols. Everything else is hand waving and religion.
- ako 4y agoRest is more like a database: a data/resource model, with a fixed set of operations you can use on this model. RPC is like stored procedures in a database. Some databases implementations only provide access to data through stored procedures, hiding the underlying tables. The first is usually more flexible to the client, he can decide what data it needs. RPC in a database is gives the server more control over the client: what data it can get, how it can be retrieved/manipulated. This introduces tighter coupling between client and server, which can be a problem is you have many unknown 3rd party clients.
- itake 4y agoThe "data/resource" model also "hides the underlying tables". For example, `POST users/1/emails` might "create" an email, but really its triggering a API call to an external service. I am not seeing the difference between REST and RPC.