V2 Endpoints (Recommended)
Counter API V2 endpoints provide an enhanced experience with user authentication, private counters, and a significantly higher rate limit of 600 requests per minute per URL path. These endpoints are designed for production applications and scenarios requiring data privacy.
The API base URL is https://api.counterapi.dev/v2
Public vs Private Counters
In V2, counters can be either public or private:
- Public counters (default): Accessible by anyone who knows the counter's namespace and name
- Private counters: Only accessible with your API key
Counter Freshness
CounterAPI V2 uses cache buffering to optimize performance and scalability. When you perform a count up or down operation, your request is buffered and the actual transaction is executed at regular intervals. This means that after incrementing or decrementing a counter, you may temporarily see an outdated (stale) counter value until the buffer is flushed and the latest value is refreshed. This approach allows for higher throughput and lower latency, but introduces a short delay in counter updates being reflected in the API responses.
Authentication
To use V2 endpoints:
- Create an account at https://counterapi.dev/signup
- Generate an API key from your dashboard
- Include your API key in all requests:
curl -X GET https://api.counterapi.dev/v2/my-workspace/my-counter/up \
-H "Authorization: Bearer YOUR_API_KEY"
Below you'll find all available V2 endpoints with examples that demonstrate their functionality.
Counter Up
Increments a counter by 1. Perfect for tracking user interactions, page views, feature usage, or any scenario where you need to count occurrences.
Endpoint: https://api.counterapi.dev/v2/:workspace/:name/up
Parameters
name | required | description |
---|---|---|
:workspace |
yes | Your personal or organizational workspace (secure and isolated from other users) |
:name |
yes | Unique identifier for this specific counter within your workspace |
Test
{{result}}
Counter Down
Decrements a counter by 1. Ideal for tracking resource consumption, available inventory, or situations where you need to decrease a count.
Endpoint: https://api.counterapi.dev/v2/:namespace/:name/down
Parameters
name | required | description |
---|---|---|
:workspace |
yes | Your personal or organizational workspace |
:name |
yes | Unique identifier for this specific counter |
Test
{{result}}
Counter Get
Retrieves the current value of a counter without modifying it. Essential for displaying metrics in dashboards, applications, or reports.
Endpoint: https://api.counterapi.dev/v2/:namespace/:name/
Parameters
name | required | description |
---|---|---|
:workspace |
yes | Your personal or organizational workspace |
:name |
yes | Unique identifier for this specific counter |
Test
{{result}}
Counter Stats
Fetches detailed statistics for a counter, including its current value, total increments, decrements, and timestamps of the last update. Useful for analytics, reporting, or monitoring purposes.
Endpoint: https://api.counterapi.dev/v2/:namespace/:name/stats
Parameters
name | required | description |
---|---|---|
:workspace |
yes | Your personal or organizational workspace |
:name |
yes | Unique identifier for this specific counter |
Test
{{result}}
Reset Counter
Sets a counter to a specific value. Use this to initialize counters, reset values, or set baselines for your tracking needs.
Endpoint: https://api.counterapi.dev/v2/:namespace/:name/reset
Parameters
name | required | description |
---|---|---|
:workspace |
yes | Your personal or organizational workspace |
:name |
yes | Unique identifier for this specific counter |
Test
{{result}}