TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Let's stop building APIs around a network hack (2017)

103 pointsby pcr910303about 4 years ago

16 comments

skrebbelabout 4 years ago
Is the author somehow implicitly assuming that APIs are only to be used between microservices in the same data center or something?<p>As far as I can see, the argument is &quot;http2 removes handshake overhead and therefore you don&#x27;t need to combine multiple things in a single response anymore&quot;.<p>If my request takes a second to go around the world and back, how does http2 help me? It&#x27;s very weird to me to read an article about API design, written in an expert tone, that does not address this.
评论 #26931054 未加载
评论 #26930863 未加载
评论 #26930969 未加载
评论 #26930709 未加载
评论 #26994946 未加载
watermelon0about 4 years ago
I think there is still latency to consider, especially if you have users around the world.<p>If you fetch invoices, and after receiving them you fetch ids of order items, and only after that you fetch actual order items, it will take 3x longer, than if you fetch everything in a single request. This can mean it could take 3 seconds to get the result, instead of 1 second with GraphQL.
评论 #26930692 未加载
评论 #26930618 未加载
评论 #26931041 未加载
评论 #26933989 未加载
skhamenehabout 4 years ago
Relating to the article, there is an (unfortunate) ongoing discussion around removing server push from Chrome&#x2F;Blink&#x2F;Chromium: <a href="https:&#x2F;&#x2F;groups.google.com&#x2F;a&#x2F;chromium.org&#x2F;g&#x2F;blink-dev&#x2F;c&#x2F;K3rYLvmQUBY&#x2F;m&#x2F;vOWBKZGoAQAJ?pli=1" rel="nofollow">https:&#x2F;&#x2F;groups.google.com&#x2F;a&#x2F;chromium.org&#x2F;g&#x2F;blink-dev&#x2F;c&#x2F;K3rYL...</a>
评论 #26934674 未加载
评论 #26930776 未加载
sfvisserabout 4 years ago
Lots of talk why you don’t really need to have compound documents anymore, but no real arguments why compound documents are bad. If your server and client architectures are somewhat sane adding a compound on-load resource is cheap and I don’t see many downsides. Maybe even pack them into your initial HTML.
评论 #27000705 未加载
bullenabout 4 years ago
This article is a bit misguided, and contains multiple fundamental missunderstandings, first no history:<p>You need to know the mess that was SOAP before you go into REST, like you need to know about XML before you criticize JSON.<p>JSON is not a good place to put anything but data, to specify an API with a meta language has been disproven by SOAP already.<p>My approach to end all API fragmentation is to simply use JSON over HTTP with minimalism!<p>I do not conform to REST, but instead exclusively use GET and POST and return 200 everywhere and handle everything manually from there.<p>I also make HTML forms to all API entrypoints so you can test and learn how the API works by browsing and viewing source.<p><a href="http:&#x2F;&#x2F;root.rupy.se" rel="nofollow">http:&#x2F;&#x2F;root.rupy.se</a>
评论 #26932017 未加载
andreiabout 4 years ago
Should add the date to the title: (2017)
Animatsabout 4 years ago
<i>&quot;HTTP&#x2F;1.1 actually solved this with Connection: keep-alive, but not many people seem to use that.</i><p>They don&#x27;t? I&#x27;d assumed that was essential to anything that did a lot of back and forth transactions. And you certainly don&#x27;t have to do a DNS lookup for each call.
评论 #26930921 未加载
slverabout 4 years ago
The author assumes serving documents (i.e. compound data) is not RESTful and a &quot;hack&quot;.<p>In the original Fielding paper, REST is explicitly defined as an architecture for &quot;large-grained resources&quot; aka &quot;documents&quot;. So this &quot;hack&quot; the author perceives is inherent to REST.<p>If your API is small-grained (like most HTTP&#x2F;web&#x2F;JSON APIs are), then Fielding explicitly states you shouldn&#x27;t be using REST.<p>Quite interestingly and not well-known to many it seems, HTTP&#x2F;1.1 had many HTTP&#x2F;2-like proposals like MULTIHEAD and MULTIGET methods. Fielding rejected them on the basis they&#x27;re not RESTful.<p>The current praise of HTTP&#x2F;2 as a major win for REST APIs shows how differently &quot;REST&quot; is understood by its proponents today compared to its original meaning. If doing REST today is about doing the opposite of what it was intended to do, it also raises the question why do we believe we get the same benefits REST did for its original definition? A quick read shows we don&#x27;t, but the cultural ingraining in favor of &quot;believing&quot; is huge.<p>TLDR; Nothing to see here, keep doing what works.<p>P.S.: Server push has been deprecated, it&#x27;s basically dead.
评论 #26930859 未加载
评论 #27000764 未加载
评论 #26935922 未加载
评论 #26931050 未加载
评论 #26931457 未加载
评论 #27019735 未加载
1cvmaskabout 4 years ago
The forum link on the site is broken. Assume everything is on their Slack channel now.<p>The link:<p><a href="https:&#x2F;&#x2F;forum.apisyouwonthate.com&#x2F;" rel="nofollow">https:&#x2F;&#x2F;forum.apisyouwonthate.com&#x2F;</a>
bniabout 4 years ago
Compound documents are not only for reducing network latency. It also about giving your clients a nice single point of entry and not having them call 5 endpoints to get what they need.
评论 #26994780 未加载
doctor_evalabout 4 years ago
Maybe I&#x27;m a bit stupid but I don&#x27;t understand this premise of this article.<p>For example,<p>&gt; Invoices don&#x27;t need payment status, or an array of order items, so we don&#x27;t need to worry about trimming down the response at the field level, they can just be their own related resources, discoverable with hypermedia controls.<p>To me, this misses the mark in two ways.<p>First, invoices <i>might</i> need payment status, if that&#x27;s what your UI is trying to render. So, you can certainly have a payment status endpoint, but that&#x27;s going to add some milliseconds to your UI response times, and if you also have separate API calls for invoice line items, fulfilment status, associated data... well you do have a lot of duplicate I&#x2F;O going on, even with HTTP&#x2F;2 and compression, and the API is not really <i>ergonomic</i> from the perspective of the user of the service. There&#x27;s a lot of client-side LOC in play to make all these calls, and a lot of server-side dependencies end up being exposed by the structure of the APIs.<p>Second, including the payment status for an invoice is <i>useful</i> and almost (but not always) something that an API consumer is going to request alongside the invoice data. So for the consumer&#x27;s convenience, you&#x27;d typically want to include it in the invoice representation. The API is going to be better off for having it.<p>In this case, however, we have the problem that obtaining the payment status (or other seemingly simple data) may in fact be expensive. Depending on the architecture of the system, at a minimum it&#x27;s probably another database query, but the payment status might even be in a completely separate service.<p>Ultimately, the cost of excess round trips is really paid for by the end-user, but the cost of loading unnecessary&#x2F;unwanted data is paid for by the service provider. GraphQL, and presumably other sparse fieldset APIs, provide a way to optimise both sides of the API.<p>This is where GraphQL makes perfect sense to me. It lets you build a discoverable data model that considers the logical structure of the API and the consumer&#x27;s ergonomics, but because the caller only requests the fields they need, and because GraphQL fields are fetched independently, you don&#x27;t have to compute those fields unless you need to. The result is super fast APIs that are easy to discover, consume and debug, and that use the optimal level of resources at both ends of the connection, a solution which IMO is infeasible with pure REST APIs distributed over many servers.
评论 #27019851 未加载
SergeAxabout 4 years ago
I am actually a tad concerned that this article made it past 100 upvotes. It was my own treshold for giving an entry some attention, and I think it is time to give it a bump. I used to regard HN as collaborative filter for a wide stream of tech news, announces, tutorials etc, but recently an average quality of that filtered data became a bit disappointing. Or maybe it&#x27;s just my own standard got higher?
marctremabout 4 years ago
I would have liked the author to have acknowledged dataloader in the context of graphql.
评论 #26930911 未加载
speedgooseabout 4 years ago
Graphql is much nicer to use than the suggested solution to do one billion http requests for the sake of it.
评论 #27000791 未加载
thinkingkongabout 4 years ago
4 years later and Id argue graphql is the clear <i>market</i> winner. Whether or not you really need it is debatable but its fashionable. Schema driven development and types have also been adopted along side that system so they sort of fit well together, too.
评论 #26930655 未加载
peteretepabout 4 years ago
I wish anything built on REST would die. Conflation of the envelope and the payload is idiotic and adds only pain, no value.
评论 #26930808 未加载
评论 #26930640 未加载
评论 #27000802 未加载
评论 #26930779 未加载