Counters

The Counters API allows you to manage and retrieve counter values.


GET/counters

List all counters

Retrieves a list of all counters

Request

GET
/counters
curl http://localhost:7472/api/v1/counters

Response

[
  {
    "id": "counter1",
    "name": "Counter 1",
    "value": 10
  },
  {
    "id": "counter2",
    "name": "Counter 2",
    "value": 15
  }
]

GET/counters/:counterId

Retrieve a counter

Fetches a specific counter by its counterId.

URL Parameters

  • Name
    counterId
    Type
    string
    Description

    The unique identifier of the counter

Request

GET
/counters/counter1
curl http://localhost:7472/api/v1/counters/counter1

Response

{
  "id": "counter1",
  "name": "Counter 1",
  "value": 10
}

POST/counters/:counterId

Update a counter

Updates the value of an existing counter. Optionally, you can override the current value.

Request Parameters

  • Name
    counterId
    Type
    string
    Description

    The unique identifier of the counter to be updated

Request Body

  • Name
    value
    Type
    number
    Description

    The new value to set for the counter

  • Name
    override
    Type
    boolean
    Description

    A boolean indicating whether to override the counter's current value. If false, the new value will be added to the current value (optional, defaults to false)

Request

POST
/counters/counter1
curl -X POST http://localhost:7472/api/v1/counters/counter1 \
  -H "Content-Type: application/json" \
  -d '{"value": 20, "override": true}'

Response

{
  "oldValue": 10,
  "newValue": 20
}