TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Ask HN: Do you like to use REST verbs

2 点作者 eskibars超过 1 年前
Interested in thoughts here: we&#x27;re considering rolling out a new REST API, and curious about your preferred way of interacting with REST APIs: in particular, HTTP verbs (mostly interested in POST vs PUT vs PATCH). I’m familiar with the descriptions for the verbs but curious if you have preferences for when to use these or which to throw away. For example<p>- I’ve noticed Stripe only has POST operations, even for idempotent actions; no PUT or PATCH. I&#x27;ve never understood why except either for consistency purposes on some &quot;legacy&quot; API they built or because there&#x27;s a good reason for never using these that I&#x27;ve never considered<p>- Elasticsearch&#x2F;OpenSearch have POST and PUT on some operations and on occasion it indicates idempotency, but some POST operations are actually idempotent while some need to use PUT. I&#x27;m familiar that Elasticsearch implemented GET with HTTP bodies but that&#x27;s not historically well supported by Javascript, so POST actions were added even for some of those GET actions<p>- I’ve heard some developers argue that having PUT and POST makes it more difficult to use because now you need to know the verb for each API and others argue on the flip side that it makes it easier because REST semantics follow for those that are familiar<p>- PATCH operations are relatively new, and I&#x27;ve heard they aren&#x27;t always well supported by e.g. some corporate firewalls<p>Do you prefer the unique &quot;right&quot; verbs or do you find it easier to assume POST is for all &quot;creation&quot;&#x2F;&quot;update&quot; actions?

1 comment

breckenedge超过 1 年前
I use GET, POST and DELETE. Generally that, plus the URL, is enough extra context to figure out what the expected operation should be. PUT&#x2F;PATCH semantics are neat but I can’t say I find them particularly necessary.