Home / API docs / Statistics API
Math

Statistics API

POST /api/calc/stats $0.005 per call USDC on Base · x402

Exact descriptive statistics — LLMs cannot reliably sum 200 numbers; this can. POST {values:[…]} for count/sum/mean/median/stddev/percentiles; {x:[],y:[]} for Pearson correlation + linear regression; {rows:[…], field} for object arrays — or {collection, field?} to run stats DIRECTLY ON YOUR DATASTORE collection (the paying wallet is the identity; reading extends its life 30 days). Up to 100k values, Kahan-summed.

Parameters

NameInDescription
valuesbodynumbers to describe
xbodywith y: correlation + regression
ybody
rowsbodyobjects — with field/fields to pick columns
fieldbody
collectionbodyrun stats on YOUR datastore collection instead of posting data

Example request

curl -X POST "https://api.webbersites.com/api/calc/stats" \
  -H "Content-Type: application/json" \
  -d '{"values":[12.5,14.1,11.8,15.2,13.9]}'
# first call returns 402 + payment requirements; an x402 client pays and retries automatically

Example response

{
    "count": 5,
    "sum": 67.5,
    "mean": 13.5,
    "median": 13.9,
    "stddev": 1.41,
    "percentiles": {
        "p25": 12.5,
        "p75": 14.1,
        "p95": 15
    }
}
MCP tool: post_calc_stats — via npx -y webbersites-x402-mcp (local, key stays on your machine) or the remote endpoint https://api.webbersites.com/mcp.

How payment works

There is no signup and no API key. Call the endpoint; it replies 402 Payment Required with machine-readable payment requirements. Your client signs a USDC transfer authorization (EIP-3009, gasless) and retries with the X-PAYMENT header — @x402/fetch does this automatically. See the overview for a working snippet.