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.

Show HN: I made a simple persistent counting API

54 pointsby dustyreaganalmost 12 years ago

7 comments

dragonwriteralmost 12 years ago
Incrementing or decrementing a counter is neither side-effect-free nor idempotent, and GET should generally be both, so you really shouldn&#x27;t use GET for those operations. [1]<p>POST would probably be the usual choice for these operations. (Though, since you aren&#x27;t really creating a subresource but are instead performing a defined transformation on an existing resource, you could probably make a case for PATCH.)<p>Web APIs are protocols implemented on top of HTTP, and should respect the semantics of HTTP unless there is a clearly-identified compelling reason not to.<p>[1] <a href="http://tools.ietf.org/html/rfc2616#section-9.1" rel="nofollow">http:&#x2F;&#x2F;tools.ietf.org&#x2F;html&#x2F;rfc2616#section-9.1</a>
评论 #6049277 未加载
评论 #6049557 未加载
评论 #6049332 未加载
评论 #6049064 未加载
dustyreaganalmost 12 years ago
I was doing some usability testing in one of my webapps and needed a simple way to count conversions. There are lots of A&#x2F;B testing solutions out there, but I just wanted a persistent count I could increment on specific user actions. So I created the ArbitraryCounter.com.<p>I find it useful, but I&#x27;m wondering if anyone else might. What do y&#x27;all think?<p>PS. This is WAY beta, and mainly a proof-of-concept. But I&#x27;ll continue developing it if there&#x27;s an interest it.
评论 #6048975 未加载
评论 #6049005 未加载
Jake232almost 12 years ago
I think you should be able to incr&#x2F;decr by more than 1. Maybe allow <a href="http://arbitrarycounter.com/vb/fruit/apples+N" rel="nofollow">http:&#x2F;&#x2F;arbitrarycounter.com&#x2F;vb&#x2F;fruit&#x2F;apples+N</a> where N can be any integer &gt; 0
评论 #6049385 未加载
评论 #6049120 未加载
评论 #6049047 未加载
pwfalmost 12 years ago
GET should never modify data. I would recommend changing that to a POST before something indexes it and decides to crawl it every 5 minutes. See here for more reasons: <a href="http://stackoverflow.com/questions/705782/why-shouldnt-data-be-modified-on-an-http-get-request" rel="nofollow">http:&#x2F;&#x2F;stackoverflow.com&#x2F;questions&#x2F;705782&#x2F;why-shouldnt-data-...</a><p>I realize this isn&#x27;t supposed to be highly accurate, but it&#x27;s something to keep in mind if it continues to grow.
评论 #6049281 未加载
geuisalmost 12 years ago
I love simple api&#x27;s like this. Its kind of the same mental model I keep around <a href="http://jsonip.com" rel="nofollow">http:&#x2F;&#x2F;jsonip.com</a>. A simple service that does one thing really well. Its been working well and has grown to millions of requests a day.<p>Keep working on this, I can see several uses already.
评论 #6049034 未加载
评论 #6049512 未加载
egonschielealmost 12 years ago
&gt; All URLs are public. We recommend using a unique group name to avoid collisions with other users.<p>So anyone can increment your counter without you knowing? Seems like this means you can never rely on the count being right.<p>As a side note, the link on the bottom is broken.
评论 #6049202 未加载
评论 #6049065 未加载
评论 #6050398 未加载
frankcaronalmost 12 years ago
&quot;There&#x27;s an API for that&quot; is the new &quot;there&#x27;s an app for that&quot;.
评论 #6049149 未加载