LetsCount API Documentation

This API allows clients to create, retrieve, update, increment, and decrement counters identified by namespace and key. It's completely free to use.

Questions, bugs or feature requests: [email protected]

Let's Count API - Easily create and manage counters. | Product Hunt

Introduction

This API uses the combination of a namespace and a key to identify a counter. The namespace is a string that identifies the application or service that is using it. This should be something like your domain or company name. The key is a string that identifies the counter within the namespace. This should be something memorable.

Remember that anyone can access a counter if they know the namespace and key, so these should be kept secret.

Base URL

The base URL for all API calls is https://letscountapi.com. All requests should be made to this URL followed by the specific endpoint paths as described in the documentation.

Request Format

All API calls should be made using the JSON format. Ensure that your request headers include Content-Type: application/json to correctly format the request body as JSON.

Create Counter

POST /<namespace>/<key>

Creates a new counter or resets an existing counter. If current_value is provided in the request body, the counter is set to that value; otherwise, it defaults to 0. current_value must be an interger. Negative values are permitted.

{
  "current_value": 10
}

If you try to create a counter that already exists, it will instead return the existing counter.

Get Counter Value

GET /<namespace>/<key>

Returns the current value of the specified counter.

Increment Counter

POST /<namespace>/<key>/increment

Increments the counter by 1.

Decrement Counter

POST /<namespace>/<key>/decrement

Decrements the counter by 1.

Update Counter Value

POST /<namespace>/<key>/update

Updates the counter to a new specified value. Requires current_value in the request body.

{
  "current_value": 5
}