Skip to content

API Documentation

Integrate Notch counters into your site with a few lines of code.

Every endpoint on this page is public. There is no API key or login, and requests work from any website, server, or script. All requests go to https://api.trynotch.cc and return JSON.

Get a public key

  1. Create an account, or log in.
  2. Create a counter from the dashboard.
  3. Copy the counter's public key. It starts with notch_pub_.

A public key is meant to be shipped in your site's code, so anyone who finds it can read or increment that counter. Creating, renaming, resetting, and deleting counters only happens in the dashboard.

Fetch current count

Retrieve the current count for a counter. Use this for read-only displays.

GET https://api.trynotch.cc/api/counters/public/:public_key

Request example

fetch("https://api.trynotch.cc/api/counters/public/notch_pub_b6sUE5TnWYTKMJJnt4cQRtZYXk4NjQtW")
  .then(res => res.json())

Expected response

{
  "count": 120328
}

Increment count

Add one to a counter. This endpoint returns the new updated total. It takes no request body.

POST https://api.trynotch.cc/api/counters/public/:public_key

Request example

fetch("https://api.trynotch.cc/api/counters/public/notch_pub_b6sUE5TnWYTKMJJnt4cQRtZYXk4NjQtW", {
  method: "POST"
})

Expected response

{
  "message": "Success",
  "count": 120329
}

Global statistics

Totals across every Notch counter and account. Each endpoint returns a single number.

  • GET https://api.trynotch.cc/api/global/clicks returns global_clicks.
  • GET https://api.trynotch.cc/api/global/users returns global_users.
  • GET https://api.trynotch.cc/api/global/counters returns global_counters.

Request example

fetch("https://api.trynotch.cc/api/global/clicks")
  .then(res => res.json())

Expected response

{
  "global_clicks": 1415
}

Rate limits

Limits are counted per IP address.

  • Fetch current count: 60 requests per minute.
  • Increment count: 30 requests per 10 seconds.
  • Global statistics: 10 requests per 5 minutes.

Every response includes RateLimit-Limit, RateLimit-Remaining, andRateLimit-Reset headers. Reset is the number of seconds until the window clears.

Errors

Errors come back as JSON with a message field.

  • 404: no counter has that public key. Fetching the count of a missing counter also returns "count": 0.
  • 429: you hit a rate limit. The message depends on the endpoint. Wait for the reset and try again.
  • 500: something went wrong on our end. Try again later.

Counter not found

{
  "message": "Counter not found",
  "count": 0
}

Rate limited (increment)

{
  "message": "Too fast! Please slow down."
}

Quick integration tip

Using React? Here is a simple way to fetch and display your live count. This example usesuseEffect to load the data when your component mounts.

React component example

import { useEffect, useState } from "react";

const CounterDisplay = () => {
    const [count, setCount] = useState(0);

    useEffect(() => {
        fetch("https://api.trynotch.cc/api/counters/public/notch_pub_b6sUE5TnWYTKMJJnt4cQRtZYXk4NjQtW")
            .then((res) => res.json())
            .then((data) => {

                if (data && typeof data.count === 'number') {
                    setCount(data.count);
                }
            })
            .catch((err) => console.error("Error fetching data:", err));
    }, []);

    return (
        <span>
            {count}
        </span>
    );
};

export default CounterDisplay