Introduction
CountAPI is a lightweight, open-source API for tracking hits and custom counts. It serves as a modern, reliable alternative to the classic countapi.xyz.
Our goal is to provide a seamless, free-to-use counting service for everyone—no API keys or registrations required. Whether you're tracking website visits, button clicks, or application events, CountAPI makes it effortless.
This project is open source. Feel free to check it out on GitHub.
TL;DR
Each "counter" is simply defined by a unique key. No registration, no API keys, no headers required.
Since namespaces don't exist, use a very unique key (e.g.,
my_super_unique_counter) to avoid overwriting someone else's counter.
Warning: All keys and their values are public. Never store any confidential contents.
To increment a counter by +1, simply visit or fetch this URL:
https://countapi.mileshilliard.com/api/v1/hit/your_unique_key
{
"key": "your_unique_key",
"message": "Key updated successfully",
"value": "3"
}
Quick Javascript Example:
fetch('https://countapi.mileshilliard.com/api/v1/hit/mysite_visits')
.then(response => response.json())
.then(data => console.log('This page has ' + data.value + ' visits!'));
Tracking Pixel Example (No JS required):
<img src="https://countapi.mileshilliard.com/api/v1/hit/mysite_visits" style="display:none;" alt="" />
Endpoints
/api/v1/get/your_key
Get the current value of the key without increasing it. Great for just displaying the current count.
/api/v1/get/your_key - 200
{
"key": "your_key",
"message": "Key requested successfully",
"value": "3"
}
/api/v1/get/your_key - 404
{
"error": "Key not found"
}
/api/v1/set/your_key
Set the value of the key to a specific number using the ?value= query
parameter. Useful for resetting counters or syncing them with another database.
/api/v1/set/your_key?value=100 - 200
{
"key": "your_key",
"message": "Key set successfully",
"old_value": "4",
"value": "100"
}
/api/v1/set/your_key - 400
{
"error": "No value provided"
}
/api/v1/hit/your_key
Increase the value of your key by exactly +1. This is the most common endpoint for tracking page views, clicks, or events.
/api/v1/hit/your_key - 200
{
"key": "your_key",
"message": "Key updated successfully",
"value": "101"
}
/api/v1/hit/your_key - 400
{
"error": "No value provided"
}
/api/v1/{get,hit}/your_key/shield
Generate a custom SVG shield showing your count! Use /get/ if you just want
to display the number, or /hit/ if you want it to increase by +1 every time
it's loaded.
Customization Options (Query Parameters):
text: The label on the left side of the shield (e.g., "visits").bgcolor: The background color of the right side, as a hex code (e.g., "ff0000").textcolor: The color of the text, as a hex code (e.g., "ffffff").style: The aesthetic style. Options areflatorplastic.
Scroll down to the Playground to easily create and copy your customized shield!
/api/v1/status
Get the current status of the API.
/api/v1/status - 200
{
"message": "API is running",
"uptime": "0:00:00"
}
/health
General ping-able endpoint. Good for monitoring uptime.
/health - 200
{
"message": "API is healthy"
}
/health - 500
N/A
Playground
Try out the shield generator live. Customize your badge and copy the exact code you need.
Settings
Live Preview
Markdown Embed (Read-only)
HTML Embed (Incrementing)
Overview
This API is hosted similarly to the OG countapi, optimized for extreme speed and minimal overhead.
-
Ubuntu VPS
-
Python Uvicorn App
- Limiter (Rate Limiting)
-
Core Endpoints (get, set,
hit, shield)
- Redis Server (In-Memory K/V Store)
-
Python Uvicorn App
FAQ
fetch() inside a script tag, or even embed it as a tracking pixel
by putting the URL in an image source like
<img src="https://countapi.mileshilliard.com/api/v1/hit/my_tracker" style="display:none;" />.