Skip to main content
API Reference

Documentation

Everything you need to start tracking metrics with StatFlow. Compatible with the StatHat API — change one URL and your existing code just works.

Getting Started

New to StatFlow? Follow these 5 steps to go from zero to tracking metrics in minutes.

  1. 1

    Create a free account

    Sign up at StatFlow — free tier includes 10 stats and 10K data points per month, no credit card required.

  2. 2

    Send your first metric

    Grab your API key from Dashboard → Settings → API Keys and send a data point with a single curl command.

    terminal
    curl -X POST https://api.statflow.dev/v1/stat \
      -H "Authorization: Bearer sk_live_YOUR_KEY" \
      -H "Content-Type: application/json" \
      -d '{"stat": "my_first_metric", "count": 1}'
  3. 3

    View your dashboard

    Your stat appears instantly in the Stats dashboard with auto-generated charts. No configuration needed — data flows in and charts render automatically.

  4. 4

    Set an alert

    Go to Dashboard → Alerts to get notified when a metric crosses a threshold — email and webhook supported.

  5. 5

    Create a dashboard

    Combine multiple stats into a custom Dashboard to see everything at a glance. Share it with your team or embed it anywhere.

Quick Start

1. Get your API key

Sign up and grab an API key from your dashboard settings.

2. Send your first metric

terminal
curl -X POST https://api.statflow.dev/v1/stat \
  -H "Authorization: Bearer sk_live_your_key_here" \
  -H "Content-Type: application/json" \
  -d '{"stat": "my_first_metric", "count": 1}'

3. See it in your dashboard

That's it. Your stat appears instantly with auto-generated charts. No configuration needed.

StatHat shuts down April 4, 2026. Export your data before then or it's gone forever.

StatFlow can pull all your stats and historical data automatically — follow the steps below.

Import Your StatHat Data

Bring your existing stats, data points, and history into StatFlow with a one-click import. The entire process takes about ~1 minute per 100 stats.

1

Get your StatHat access token

Log in to StatHat and go to stathat.com/access to find your access token. This is different from your EZ key — it grants read access to export your data.

2

Navigate to Dashboard → Import

In your StatFlow account, go to Dashboard → Import.

3

Paste your access token and click Import

Paste the StatHat access token from step 1 into the input field and hit Import. StatFlow connects to the StatHat API and starts pulling your data.

4

All your stats and history appear automatically

StatFlow pulls all your stats and historical data points automatically. Once complete, your dashboard will have all your metrics with full history, ready to go.

What gets imported
Stat names
Stat types (counter & value)
All historical data points
Timestamps
Estimated import time: ~1 minute per 100 stats

Authentication

All API requests require authentication via a Bearer token in the Authorization header.

Authorization: Bearer sk_live_your_api_key

Live keys (sk_live_) — use in production. Data counts toward your plan limits.

Test keys (sk_test_) — use in development. Data is stored but doesn't count toward limits.

API Endpoints

Base URL: https://api.statflow.dev

POST/v1/stat

Send a single data point (EZ API)

{"stat": "my_metric", "count": 1}
POST/v1/stat/value

Send a value data point (Classic API)

{"stat": "response_time", "value": 142.5}
POST/v1/stat/count

Increment a counter (Classic API)

{"stat": "page_views", "count": 1}
POST/v1/stats

Send multiple data points in one request (JSON batch)

{"stats": [{"stat": "signups", "count": 1}, {"stat": "latency", "value": 42}]}
GET/v1/stat/:name

Retrieve stat metadata and recent data points

GET/v1/stats

List all stats in your account

Pixel Tracking

Use invisible 1×1 pixel images to track events where JavaScript can't run — email opens, static HTML pages, RSS readers, and more.

GET/c
Count via tracking pixel — returns a 1×1 transparent GIF

Query Parameters

ParamRequiredDescription
ukeyYesYour API key (sk_live_...)
keyYesStat name to increment
countNoAmount to increment (default: 1)

HTML Example

<img src="https://api.statflow.dev/c?ukey=YOUR_API_KEY&key=email_opened&count=1" width="1" height="1" alt="" />

Use Cases

  • Email open tracking — embed the pixel in HTML emails to count opens
  • Static page views — track visits on pages where you can't add JavaScript
  • RSS reader tracking — count how many people view your feed items
  • AMP pages — works anywhere an <img> tag is allowed
Migration: StatHat → StatFlow
Change the domain — everything else stays the same

Before (StatHat)

<img src="https://api.stathat.com/c?ukey=USER_KEY&key=STAT_KEY&count=1" width="1" height="1" alt="" />

After (StatFlow)

<img src="https://api.statflow.dev/c?ukey=YOUR_API_KEY&key=STAT_KEY&count=1" width="1" height="1" alt="" />

StatHat Compatibility

StatFlow is a drop-in replacement for the StatHat API. If you have existing StatHat integrations, migration is as simple as changing the base URL:

https://api.stathat.com
https://api.statflow.dev

The EZ API, Classic API, and JSON batch endpoints are all supported. Replace your StatHat EZ key or access token with your StatFlow API key.

Migration from StatHat

Switching from StatHat takes about 2 minutes per service. For each language below: get your API key, change one line, and verify.

1. Get your API key

Sign up at StatFlow and copy your sk_live_ key from Dashboard → Settings → API Keys.

2. Change one line

Replace the StatHat URL/key with your StatFlow URL/key (see language guides below).

3. Verify

Send a test metric and check your dashboard. That's it.

Go
Replace the stathat package with a simple HTTP POST.

Before (StatHat)

import "github.com/stathat/go"

stathat.PostEZCount("page views", "your_ezkey@email.com", 1)
stathat.PostEZValue("response time", "your_ezkey@email.com", 42.5)

After (StatFlow)

import (
    "bytes"
    "encoding/json"
    "net/http"
)

func postMetric(stat string, count int, value float64) error {
    body, _ := json.Marshal(map[string]any{
        "stat": stat, "count": count, "value": value,
    })
    req, _ := http.NewRequest("POST",
        "https://api.statflow.dev/v1/stat", bytes.NewReader(body))
    req.Header.Set("Authorization", "Bearer sk_live_YOUR_KEY")
    req.Header.Set("Content-Type", "application/json")
    _, err := http.DefaultClient.Do(req)
    return err
}

postMetric("page views", 1, 0)
postMetric("response time", 0, 42.5)

Test your migration

After updating your code, verify everything works with a quick curl test:

terminal
curl -X POST https://api.statflow.dev/v1/stat \
  -H "Authorization: Bearer sk_live_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{"stat": "migration_test", "count": 1}'

# Expected response:
{"msg": "ok"}

If you get {"msg": "ok"}, your migration is complete. Check your dashboard to see the new metric.

StatHat API Compatibility

StatFlow supports the full StatHat API surface. Your existing client libraries, scripts, and integrations work with zero code changes — just swap the base URL.

EZ API

POST/ez

The simplest way to send data. Uses your EZ key (email-based API key from StatHat) or StatFlow API key.

ParameterTypeDescription
ezkeystringYour EZ key (StatHat) or API key (StatFlow)
statstringStat name (auto-created if it doesn't exist)
countnumberCounter increment (use for counts, events)
valuenumberValue data point (use for latency, measurements)
tnumberUnix timestamp (optional, defaults to now)
curl -X POST https://api.statflow.dev/ez \
  -d "ezkey=sk_live_YOUR_KEY" \
  -d "stat=page views" \
  -d "count=1"

Classic API

POST/cCounter

Increment a counter stat using the Classic API with key (stat key) and ukey (user key) params.

curl -X POST https://api.statflow.dev/c \
  -d "key=STAT_KEY" \
  -d "ukey=USER_KEY" \
  -d "count=1"
POST/vValue

Send a value data point using the Classic API with key and ukey params.

curl -X POST https://api.statflow.dev/v \
  -d "key=STAT_KEY" \
  -d "ukey=USER_KEY" \
  -d "value=42.5"

Tilde (~) Multi-Stat Syntax

Send data to multiple stats in a single call by separating stat names with a tilde (~). Each stat receives the same count or value.

Example: one request, three stats

curl -X POST https://api.statflow.dev/ez \
  -d "ezkey=sk_live_YOUR_KEY" \
  -d "stat=messages sent~total,female,europe" \
  -d "count=1"

This sends count=1 to three stats: messages sent~total, messages sent~female, and messages sent~europe. Useful for tracking the same event across multiple dimensions.

JSON Batch Mode

Send multiple data points in one request by POSTing JSON with Content-Type: application/json.

curl -X POST https://api.statflow.dev/ez \
  -H "Content-Type: application/json" \
  -d '{
    "ezkey": "sk_live_YOUR_KEY",
    "data": [
      {"stat": "page views", "count": 1},
      {"stat": "response time", "value": 42.5},
      {"stat": "signups", "count": 1, "t": 1711929600}
    ]
  }'

Each item in the data array can include stat, count or value, and an optional t timestamp.

Feature Compatibility

StatHat FeatureStatFlow Status
EZ API✅ Supported
Classic API✅ Supported
Batch JSON✅ Supported
Tilde (~) syntax✅ Supported
Export API✅ Supported
HTML pixel tracking✅ Supported
Auto-create stats✅ Supported
Automatic alerts🔜 Coming
Trend forecasts🔜 Coming
Status Board integration❌ Not planned

Client Libraries

Ready to start tracking?

Free tier includes 10 stats and 10K data points/month.