The Counter API provides a integer counter service for your application. The counters are stored in our database and can be accessed via IDs unique to the provided API key.
For free users, counters are kept for 14 days.
For premium users, counters are retained indefinitely until it becomes inactive for 180 days, at which point it gets deleted.
https://api.api-ninjas.com/v1/counter
Fetch and possibly update a counter.
id
requiredID to specify the counter. Use a new id
to create a new counter.
hit
optionalWhether to increase the count by 1. If used, must be set to true
.
value
optionalSet the count to a specific integer value. Setting the value to 0 resets the counter.
X-Api-Key
requiredAPI Key associated with your account.
https://api.api-ninjas.com/v1/counter?id=test_id&hit=true
1
2
3
4
{
"id": "test_id",
"value": 38
}
1
2
3
4
5
6
7
import requests
api_url = 'https://api.api-ninjas.com/v1/counter?id=test_id&hit=true'
response = requests.get(api_url, headers={'X-Api-Key': 'YOUR_API_KEY'})
if response.status_code == requests.codes.ok:
print(response.text)
else:
print("Error:", response.status_code, response.text)
If your programming language is not listed in the Code Example above, you can still make API calls by using a HTTP request library written in your programming language and following the above documentation.