Skip to content
GET /v1/margin

Margin of error for a sample size

Try it live

10 free calls per day — no sign-up, no API key. Goes through the oanor gateway.

Custom headers (optional)
api.oanor.com/samplesize-api

It works. Grab an API key and use it in your project.

Get an API key

Code snippets

curl "https://api.oanor.com/samplesize-api/v1/margin" \
  -H "x-oanor-key: oanor_test_..."
await fetch("https://api.oanor.com/samplesize-api/v1/margin", {
  headers: { "x-oanor-key": "oanor_test_..." }
});
$ch = curl_init("https://api.oanor.com/samplesize-api/v1/margin");
curl_setopt($ch, CURLOPT_HTTPHEADER, ["x-oanor-key: oanor_test_..."]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$out = curl_exec($ch);
import requests
requests.get(
    "https://api.oanor.com/samplesize-api/v1/margin",
    headers={"x-oanor-key": "oanor_test_..."}
)

Example response

A real response from this endpoint, captured by the latest health check.

{
    "data": {
        "kind": "proportion",
        "note": "Proportion margin of error E = z·√(p(1−p)/n). A sample of 385 gives about ±5 % at 95 %.",
        "inputs": {
            "confidence": 0.95,
            "proportion": 0.5,
            "sample_size": 385
        },
        "z_score": 1.959964,
        "margin_of_error": 0.04994451,
        "margin_of_error_percent": 4.994451
    },
    "meta": {
        "timestamp": "2026-06-05T19:50:22.175Z",
        "request_id": "da6c5007-d870-4981-acd8-e8d04727955e"
    },
    "status": "ok",
    "message": "Margin of error",
    "success": true
}