tick.rs
tick.rs is a very simple service that allows you to increment and retrieve numbers. It's mostly useful for static websites where you don't want to make the leap into using a database. Instead you can use tick.rs.
As an example, here is a tracking counter for this site: You're visitor
number...
So far people have generated
Data is persisted to an sqlite database. If you have a database on your server this will be of almost zero use to you, because it's just a column in a database. But if you don't want to set up a database just to store some numbers, then tick.rs can be useful.
While nothing is guaranteed, tick.rs aims to be free and usable forever. There is no aim to monetize this, it won't sprout ads, or accumulate VC money and become "Counters as a Service". No tracking or other shenanigans. The only things recorded are the ID, the counter, the last modified timestamp and the creation timestamp. IPs are never recorded.
Having said that, there is no express or implied warranty while using this service and I reserve the right to delete or block counters or users for any reason.
Counters API
To make a new counter, POST
to /c
. This will
generate a new ID for you.
curl -vX POST tick.rs/c
...
< HTTP/1.1 303 See Other
< content-length: 12
< content-type: \
< text/plain; charset=utf-8
< location: /F5sTldY06kLR
< date: Sun, 06 Oct 2024 13:14:15 GMT
F5sTldY06kLR
With your new ID you can POST
to
/c/ID
to increment the counter. Counters can't be decremented. The return
value will be a redirect to the GET to avoid double posts, but the
content will also have the number to minimize duplicate requests if you
don't intend to follow redirects.
curl -vX POST tick.rs/c/F5sTldY06kLR
...
< HTTP/1.1 303 See Other
< content-length: 1
< content-type: \
< text/plain; charset=utf-8
< location: /F5sTldY06kLR
< date: Sun, 06 Oct 2024 13:14:15 GMT
8
If you're feeling brave you could skip generating a unique ID and make one up. If it doesn't exist it'll be created and the counter will be 1.
curl -vX POST tick.rs/c/my_own_id
...
< HTTP/1.1 303 See Other
< content-length: 1
< content-type: \
< text/plain; charset=utf-8
< location: /c/my_own_id
< date: Sun, 06 Oct 2024 13:14:15 GMT
1
As you might guess, you can GET /c/ID
to
retrieve the current count, as well as the last time it was modified:
curl -vX GET tick.rs/c/F5sTldY06kLR
...
< HTTP/1.1 200 OK
< content-length: 1
< content-type: \
< text/plain; charset=utf-8
< last-modified: \
< Sun, 06 Oct 2024 13:14:15 GMT
< date: Sun, 06 Oct 2024 13:14:15 GMT
1
If you don't like text/plain
you can add an extension to
the path, e.g. /c/ID.json
will respond with
JSON instead. You can also try .png
, .gif
,
.svg
, .txt
. Image formats will give you a
small 1px by 1px image. This is useful to use as a
"tracking pixel",
but of course you're just going to get a count, no advanced analytics
here.
Sometimes you really can't use a POST
request, for example
in the afforementioned tracking pixel case. As a workaround you can
GET
to /c+/ID
. This is obviously an abuse of the protocol because GET requests
should be idempotent.
curl -vX GET tick.rs/c+/F5sTldY06kLR
...
< HTTP/1.1 303 See Other
< content-length: 1
< content-type: \
< text/plain; charset=utf-8
< location: /c/F5sTldY06kLR
< date: Sun, 06 Oct 2024 13:14:15 GMT
1
Sometimes it can be useful to plug these into a dashboard, like
Grafana. To make this a little easier
you can GET /c/ID/metrics
to get an
OpenMetrics
formatted version of the counter, which can be more easily ingested into
OpenMetrics compatible tools such as
Prometheus.
curl -vX GET tick.rs/c/F5sTldY06kLR/metrics
...
< HTTP/1.1 200 OK
< content-length: 1
< content-type: \
< text/plain; version=0.0.4; \
< charset=utf-8
< last-modified: \
< Sun, 06 Oct 2024 13:14:15 GMT
< date: Sun, 06 Oct 2024 13:14:15 GMT
# TYPE F5sTldY06kLR counter
F5sTldY06kLR_count 8
Gauge API
Change the /c
to a /g
and you'll get a gauge.
Gauges can go up as well as down. Gauges can go negative, they're
signed. They're stored in a different table to Counters, so a Counter
and a Gauge might have the same ID, but they're different records. The
API to Gauges is identical to Counters, with some subtle differences:
In addition to all the API above, gauges also have the /g-
endpoint, which decrements them.
curl -vX GET tick.rs/g-/F5sTldY06kLR/metrics
...
< HTTP/1.1 303 See Other
< content-length: 1
< content-type: \
< text/plain; charset=utf-8
< location: /g/F5sTldY06kLR
< date: Sun, 06 Oct 2024 13:14:15 GMT
-1
This endpoint also accepts POST requests, so you can swap the GET for a POST for the theoretical purity of HTTP verbs.
curl -vX POST tick.rs/g-/F5sTldY06kLR/metrics
...
< HTTP/1.1 303 See Other
< content-length: 1
< content-type: \
< text/plain; charset=utf-8
< location: /g/F5sTldY06kLR
< date: Sun, 06 Oct 2024 13:14:15 GMT
-2
Questions and ideas
If you have any questions or want to discuss features, this project is open source, and can be viewed at https://github.com/keithamus/tickrs. Pull Requests are welcome. Issues are closed. If you want to file an issue, consider raising a PR instead.