I still like REST. Most web applications are CRUD and don't need RPC. It also provides a standard and expected interface for 3rd party developers integrating with your code. If you're a small saas startup, nobody is going to waste their time learning the particularities of your protocol. Also makes the code very easy to read if you follow best practices for MVC style webapis with dependency injection. In my view, asp.net core is the apex of all RESTful frameworks
Precisely right. Standards work cause everyone understands them. I know a PUT request is almost certainly an update of some kind. I know a POST makes something.
For most shit you wanna do, its view, edit, delete, its really not that complicated.
It's become just a word that means "interface endpoints". And frankly that's fine, it's what it is in the end. Whether in an OS, a website, or another platform.
REST is for noobs, JSON RPC is silent pro's choice :)
Make all requests POST and enjoy easy life without useless debates on should creation of resource be on POST or PUT or should you return HTTP status 404 or 200 if resource/document on server is not found (of course if should be 200 because request was a success, 404 should only be used it api method is not found).
I don't like REST either, but JSON RPC is similarly hamstrung in some scenarios (examples: streaming, CDN caching, binary encoding).
I mostly dislike REST because nobody can agree on what it is and there are too many zealots who love to bikeshed. If you stick with the simple parts of REST and ignore the zealots, it's decent enough for many scenarios.
I've yet to find an RPC protocol that fills all requirements I've encountered, they all have tradeoffs and at this point you're better off learning the tradeoffs and how to deal with them (REST, JSON RPC, gRPC, WebSockets, etc.) and how they interact with their transports (HTTP/1.1, H2, QUIC, etc.), and then play the unfortunate game of balancing tradeoffs.
ReST makes sense in certain cases, where resources are a tree (like a typical web site is a tree), with collections of leaves, and these leaves make sense by themselves. Then you can go full HATEOAS and reap some actual benefits from that.
Most of the time (like 99.9%) what you happen to need is JSON RPC. Even if some parts of your API surface look like they would fit the ReST model, the bulk does not. Ignore that, build a protocol along the lines of your subject area. Always return 200 if your server did not fail or reject the request, use internal status signaling for details. Limit yourself to GET and POST. Use HTTP as a mere transport.
+1 and I'll bump it up a notch... not only should you ignore REST you should ignore URLs. You want to write protocols, not APIs. Redis, for example, has a better "API" than any web API I've used. Easy to use, easy to wrap, easy to extend and version. HTTP is the other obvious example that I shouldn't have to go into.
This article defines REST incorrectly, and doesn't seem to understand the concept of HTTP methods, calling them verbs (arguably fine) and types (huh?) seemingly arbitrarily. Methods are a core part of HTTP -- just because you can't specify them explicitly in a browser as a user doesn't mean they're "cryptic curl arguments" or worth ignoring. I'm not sure I'd put too much stock into this perspective.
I want to emphasize that I was not thinking about JSON RPC as a specific protocol, but more as a JSON format to transfer data, similar to how REST APIs usually do, and some kind of "HTTP method agnostic remote procedure call", it does not have to be JSON RPC standard.
Personally, I am a fan of just having API Class-es + methods that automatically map to API calls with automatic api interface and doc builders. I find that it would be super strange if I had to prefix my internal methods with DELETE or PUT based on do they remove or add to some Array. Using that logic, why do that in APIs.
I just find it super strange that people want to mirror their app logic + error response codes to some protocol like HTTP – ridiculous :) Why not go even lower as TCP and use some of that spec for our client <> server API conn. Many people will laugh, but if you think about it, where is the difference?
I've been a REST API developer for a few years now. For whatever reason, I've never bothered dipping my toes in the RPC realm. This article resonated with me. Looks like I'll be building an RPC API in the near future.
People are complimenting great technical writing here, but the first definition they provide is this:
> Technically, an API is just a set of rules (interface) that the two sides agree to follow. The company publishing the API then implements their side by writing a program and putting it on a server. In practice, lumping the interface in with the implementation is an easier way to think about it.
which is neither technically correct, nor easy to understand for a layperson. Compare to Wikipedia:
> An application programming interface (API) is a way for two or more computer programs to communicate with each other. It is a type of software interface, offering a service to other pieces of software.
This is the most difficult topic for me. I struggle to discover, understand and implement in my code highly linked resources. How an API is organized or designed should be its own chapter IMHO
“We'll skip the details…
[…] REST practitioners are split on how to solve the problem of associating resources.”
I think JSON [tree] data [with no fixed field for unique identifier, and no fkey referencing] is wrong. The lack of a proper type system+schema for data is wrong. The need for server-side query management makes any API supremely rigid.
Still some concerns to solve, for me, with REST APIs.
JSON covers syntax not semantics. This means you can build the formats you want on top of JSON by only describing the semantics without having to make decisions about syntax or write parsers.
This article advocates for a traditional REST API design. At Seam, we use an API design that is like a RESTful RPC API, inspired by the API at Slack. I think that HTTP RPC and Slack-like APIs are much better than traditional REST because most consumers of an API use an SDK, and RPC-style HTTP APIs optimize for the SDK usage.
We also built a framework like trpc but for Next REST APIs[1] to get all the nice benefits of shared types but also the nice benefits of OpenAPI generation that typically come with RESTful frameworks https://github.com/seamapi/nextlove
Side point - has anyone got a better way to refer to a non-technical person than "non-technical"? I see they use that term in the intro and I use it to but seems a bit condescending.
Very well written. However, I have never thought of the word 'endpoint' as used in API documentation in the way they describe it. I have no idea what the true origin is but I've always thought of it as the end of the journey the api request makes over the network.
Basic REST and JSON RPC are very simple to start with, but have common problems when application gets bigger. How do you represent relations, pagination, filtering etc? My go-to specification for structuring JSON documents is https://jsonapi.org/ It covers most basic needs of a standard API.
> PUT - Asks the server to edit/update an existing resource
Maybe I've been doing it wrong all these years but it seems to me that the guides flip-flops the responsibility of POST and PUT. My understanding is that POST should edit/modify while PUT creates/replaces a resource.
[+] [-] shortrounddev2|2 years ago|reply
[+] [-] irishloop|2 years ago|reply
For most shit you wanna do, its view, edit, delete, its really not that complicated.
[+] [-] delta_p_delta_x|2 years ago|reply
Desktop, embedded, video games, HPC suddenly cried out in terror and were suddenly silenced.
[+] [-] 3cats-in-a-coat|2 years ago|reply
[+] [-] pdntspa|2 years ago|reply
Like, this is a fundamental aspect of how I interact with my job and business has taken the term and elevated it into its own distinct thing
[+] [-] rewmie|2 years ago|reply
What leads you to believe that a HTTP API does not meet the definition of a API?
[+] [-] lazyasciiart|2 years ago|reply
[+] [-] dinoreic|2 years ago|reply
Make all requests POST and enjoy easy life without useless debates on should creation of resource be on POST or PUT or should you return HTTP status 404 or 200 if resource/document on server is not found (of course if should be 200 because request was a success, 404 should only be used it api method is not found).
I 100% agree with Troy Griffitts beautiful take https://vmrcre.org/web/scribe/home/-/blogs/why-rest-sucks
[+] [-] atsjie|2 years ago|reply
- Everything is a POST, so normal HTTP caching is out of the question.
- JSON RPC code generators are non-existent or badly maintained depending on the language. Same with doc generators.
- Batching is redundant with HTTP2, just complicates things.
- Because everything is a POST normal logging isn't effective (i.e. see the url in logs, easy to filter etc). You'll have to write something yourself.
- Not binary like Protobufs or similar
But yeah, "the silent pro's choice"... Let's keep it silent.
JSON RPC is pretty much dead at this point and superseded by better alternatives if you're designing an RPC service.
[+] [-] cle|2 years ago|reply
I mostly dislike REST because nobody can agree on what it is and there are too many zealots who love to bikeshed. If you stick with the simple parts of REST and ignore the zealots, it's decent enough for many scenarios.
I've yet to find an RPC protocol that fills all requirements I've encountered, they all have tradeoffs and at this point you're better off learning the tradeoffs and how to deal with them (REST, JSON RPC, gRPC, WebSockets, etc.) and how they interact with their transports (HTTP/1.1, H2, QUIC, etc.), and then play the unfortunate game of balancing tradeoffs.
[+] [-] nine_k|2 years ago|reply
Most of the time (like 99.9%) what you happen to need is JSON RPC. Even if some parts of your API surface look like they would fit the ReST model, the bulk does not. Ignore that, build a protocol along the lines of your subject area. Always return 200 if your server did not fail or reject the request, use internal status signaling for details. Limit yourself to GET and POST. Use HTTP as a mere transport.
[+] [-] eikenberry|2 years ago|reply
If you'd like a good back and forth on the idea the classic c2 page is a great resource. http://wiki.c2.com/?ApiVsProtocol
[+] [-] lenkite|2 years ago|reply
[+] [-] kiitos|2 years ago|reply
[+] [-] dinoreic|2 years ago|reply
I want to emphasize that I was not thinking about JSON RPC as a specific protocol, but more as a JSON format to transfer data, similar to how REST APIs usually do, and some kind of "HTTP method agnostic remote procedure call", it does not have to be JSON RPC standard.
Personally, I am a fan of just having API Class-es + methods that automatically map to API calls with automatic api interface and doc builders. I find that it would be super strange if I had to prefix my internal methods with DELETE or PUT based on do they remove or add to some Array. Using that logic, why do that in APIs.
I just find it super strange that people want to mirror their app logic + error response codes to some protocol like HTTP – ridiculous :) Why not go even lower as TCP and use some of that spec for our client <> server API conn. Many people will laugh, but if you think about it, where is the difference?
[+] [-] parentheses|2 years ago|reply
[+] [-] unknown|2 years ago|reply
[deleted]
[+] [-] lprd|2 years ago|reply
[+] [-] eska|2 years ago|reply
> Technically, an API is just a set of rules (interface) that the two sides agree to follow. The company publishing the API then implements their side by writing a program and putting it on a server. In practice, lumping the interface in with the implementation is an easier way to think about it.
which is neither technically correct, nor easy to understand for a layperson. Compare to Wikipedia:
> An application programming interface (API) is a way for two or more computer programs to communicate with each other. It is a type of software interface, offering a service to other pieces of software.
[+] [-] xtiansimon|2 years ago|reply
This is the most difficult topic for me. I struggle to discover, understand and implement in my code highly linked resources. How an API is organized or designed should be its own chapter IMHO
“We'll skip the details… […] REST practitioners are split on how to solve the problem of associating resources.”
UUUG
[+] [-] lolive|2 years ago|reply
Still some concerns to solve, for me, with REST APIs.
[+] [-] JimDabell|2 years ago|reply
[+] [-] seveibar|2 years ago|reply
We also built a framework like trpc but for Next REST APIs[1] to get all the nice benefits of shared types but also the nice benefits of OpenAPI generation that typically come with RESTful frameworks https://github.com/seamapi/nextlove
[+] [-] danjc|2 years ago|reply
[+] [-] gabereiser|2 years ago|reply
This avoids classification of the reader. To refer to someone who lacks the knowledge of a domain, they are a “layman”.
[+] [-] mellosouls|2 years ago|reply
https://dictionary.cambridge.org/dictionary/english/layperso...
someone who is not an expert in or does not have a detailed knowledge of a particular subject
"bluffer" would be a humorous alternative.
[+] [-] ch1234|2 years ago|reply
Non-technical = not technical = does not have technical expertise.
Seems pretty logical to me
[+] [-] macintux|2 years ago|reply
[+] [-] vitorbaptistaa|2 years ago|reply
I find it hard to call a data analyst (for example), who can be highly technical, as a non-technical person.
[+] [-] unknown|2 years ago|reply
[deleted]
[+] [-] FractalHQ|2 years ago|reply
[+] [-] pranavpiyush|2 years ago|reply
[+] [-] unknown|2 years ago|reply
[deleted]
[+] [-] gibb0n|2 years ago|reply
[+] [-] vorpalhex|2 years ago|reply
[+] [-] foundart|2 years ago|reply
> These are called endpoints simply because they go at the end of the URL, as in http://example.com/<endpoint_goes_here>.
[+] [-] aggrrrh|2 years ago|reply
[+] [-] sibit|2 years ago|reply
> PUT - Asks the server to edit/update an existing resource
Maybe I've been doing it wrong all these years but it seems to me that the guides flip-flops the responsibility of POST and PUT. My understanding is that POST should edit/modify while PUT creates/replaces a resource.
[+] [-] aridiculous|2 years ago|reply
[+] [-] gumby|2 years ago|reply
[+] [-] distantsounds|2 years ago|reply
[+] [-] unknown|2 years ago|reply
[deleted]
[+] [-] ninja-ninja|2 years ago|reply
[+] [-] ChrisArchitect|2 years ago|reply
[+] [-] synergy20|2 years ago|reply
It was written in 2014, not sure if it's still 'up to date' but the articles seem well written, concise, to the point.