Trust Badges Stats API

A simple API to count banner views and manage counters for shops.

POST /views

Adds a given number of views to a shop’s counter. Automatically resets every 30 days.

POST /views
    Content-Type: application/json
    
    {
      "shop": "example.myshopify.com",
      "views": 3
    }

Response: true

GET /views

Retrieves the current counter and how many seconds remain in the current 30-day window.

GET /views?shop=example.myshopify.com

Example response:

{
      "shop": "example.myshopify.com",
      "total": 12,
      "period_start": 1728312345,
      "seconds_left_in_window": 220
    }

POST /reset

Resets the counter for a shop (useful when upgrading a plan). Requires an admin key.

POST /reset
    Content-Type: application/json
    x-admin-key: YOUR_ADMIN_KEY
    
    {
      "shop": "example.myshopify.com"
    }

Response: true


Time window: 30 days (can be changed in the code). Powered by Cloudflare Workers + D1.