# Pregnancy Due Date API
> Pregnancy and due-date maths as an API, using the standard Naegele's rule (40 weeks / 280 days from the last menstrual period). The due-date endpoint takes the last menstrual period, the conception date, or a known due date — whichever you have — and returns the due date, the estimated conception date and the fertile window. The gestational-age endpoint reports how far along a pregnancy is as of any reference date: gestational age in weeks and days, the trimester, days remaining, progress percent, and whether it is overdue. The milestones endpoint lists the key dates of a pregnancy — the trimester boundaries, the anatomy-scan window, viability at 24 weeks, full term at 37–40 weeks, the due date and post-term at 42 weeks. All dates are handled in UTC and computed locally and deterministically. Ideal for pregnancy and fertility apps, midwifery and clinical tools, and parenting and family-planning products. Informational only — not medical advice. Pure local computation — no key, no third-party service, instant. Live, nothing stored. 4 endpoints. This is pregnancy date maths; for general date arithmetic use a datetime API.

## Authentication
All requests require your oanor API key in the `x-oanor-key` header. Get one at https://www.oanor.com/developer/keys.

```bash
curl -H "x-oanor-key: oanor_live_…" "https://api.oanor.com/pregnancy-api/..."
```

## Pricing
- **Free** (Free) — 7,035 calls/Mo, 2 req/s
- **Starter** ($9/Mo) — 16,550 calls/Mo, 8 req/s
- **Pro** ($28/Mo) — 216,500 calls/Mo, 20 req/s
- **Mega** ($66/Mo) — 1,125,000 calls/Mo, 50 req/s

## Endpoints

### Pregnancy

#### `GET /v1/due-date` — Due date from LMP / conception / due

**Parameters:**
- `lmp` (query, optional, string) — Last menstrual period YYYY-MM-DD Example: `2025-01-01`
- `conception` (query, optional, string) — Or conception date
- `due_date` (query, optional, string) — Or a known due date

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/pregnancy-api/v1/due-date?lmp=2025-01-01"
```

**Response:**
```json
{
    "data": {
        "lmp": "2025-01-01",
        "basis": "last menstrual period",
        "due_date": "2025-10-08",
        "fertile_window": {
            "end": "2025-01-16",
            "start": "2025-01-10"
        },
        "estimated_conception": "2025-01-15"
    },
    "meta": {
        "timestamp": "2026-06-03T17:42:10.473Z",
        "request_id": "a3df4855-198f-436f-b9ec-e49175cb6a26"
    },
    "status": "ok",
    "message": "Due date",
    "success": true
}
```

#### `GET /v1/gestational-age` — Gestational age + progress

**Parameters:**
- `lmp` (query, optional, string) — LMP (or conception/due_date) Example: `2025-01-01`
- `as_of` (query, optional, string) — Reference date (default today) Example: `2025-04-02`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/pregnancy-api/v1/gestational-age?lmp=2025-01-01&as_of=2025-04-02"
```

**Response:**
```json
{
    "data": {
        "lmp": "2025-01-01",
        "as_of": "2025-04-02",
        "basis": "last menstrual period",
        "overdue": false,
        "due_date": "2025-10-08",
        "trimester": "second",
        "days_remaining": 189,
        "gestational_age": "13w 0d",
        "progress_percent": 32.5,
        "gestational_weeks": 13,
        "gestational_total_days": 91,
        "gestational_days_into_week": 0
    },
    "meta": {
        "timestamp": "2026-06-03T17:42:10.558Z",
        "request_id": "b16c4084-e0c0-4d4a-aefa-9c39b6bc28b0"
    },
    "status": "ok",
    "message": "Gestational age",
    "success": true
}
```

#### `GET /v1/milestones` — Key pregnancy milestones

**Parameters:**
- `lmp` (query, optional, string) — LMP (or conception/due_date) Example: `2025-01-01`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/pregnancy-api/v1/milestones?lmp=2025-01-01"
```

**Response:**
```json
{
    "data": {
        "lmp": "2025-01-01",
        "basis": "last menstrual period",
        "due_date": "2025-10-08",
        "milestones": [
            {
                "date": "2025-04-02",
                "week": 13,
                "milestone": "End of first trimester"
            },
            {
                "date": "2025-07-09",
                "week": 27,
                "milestone": "End of second trimester"
            },
            {
                "date": "2025-06-18",
                "week": 24,
                "milestone": "Viability (24 weeks)"
            },
            {
                "date": "2025-05-07",
                "week": 18,
                "milestone": "Anatomy scan window start (18 weeks)"
            },
            {
                "date": "2025-07-16",
                "week": 28,
                "milestone": "Third trimester begins (28 weeks)"
            },
            {
                "date": "2025-09-17",
                "week": 37,
                "milestone": "Preterm threshold (37 weeks / full term)"
            },
            {
                "date": "2025-09-17",
                "week": 37,
                "milestone": "Early term (37–38 weeks)"
            },
            {
                "date": "2025-10-01",
                "week": 39,
                "milestone": "Full term (39–40 weeks)"
            },
            {
                "date": "2025-10-08",
                "week": 40,
                "milestone": "Due 
…(truncated, see openapi.json for full schema)
```

### Meta

#### `GET /v1/meta` — Spec

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/pregnancy-api/v1/meta"
```

**Response:**
```json
{
    "data": {
        "name": "Pregnancy Due Date API",
        "notes": "Naegele's rule: due date = LMP + 280 days; conception assumed at LMP + 14 days. Informational, not medical advice. Nothing is stored.",
        "version": "v1",
        "endpoints": [
            {
                "path": "/v1/due-date",
                "params": {
                    "lmp": "last menstrual period YYYY-MM-DD",
                    "due_date": "or a known due date",
                    "conception": "or conception date"
                },
                "returns": "due date, conception estimate and fertile window"
            },
            {
                "path": "/v1/gestational-age",
                "params": {
                    "lmp": "or conception / due_date",
                    "as_of": "reference date (default today)"
                },
                "returns": "gestational age, trimester, days remaining and progress"
            },
            {
                "path": "/v1/milestones",
                "params": {
                    "lmp": "or conception / due_date"
                },
                "returns": "the key pregnancy milestone dates"
            },
            {
                "path": "/v1/meta",
                "params": [],
                "returns": "this document"
            }
        ],
        "description": "Pregnancy and due-date maths as an API, using the standard Naegele's rule (40 weeks / 280 days from the last menstrual period). The due-date 
…(truncated, see openapi.json for full schema)
```


---
Marketplace page: https://www.oanor.com/api/pregnancy-api
OpenAPI spec: https://www.oanor.com/api/pregnancy-api/openapi.json
