Need to calculate pregnancy due dates in your health application? This guide covers everything you need to know about due date calculation via API, including different methods, pregnancy milestones, and implementation examples.
What is Estimated Due Date?
The Estimated Due Date (EDD) is the predicted date when a baby is expected to be born. It's calculated based on the first day of the last menstrual period (LMP) or conception date. A typical pregnancy lasts about 280 days (40 weeks) from the LMP.
Only about 5% of babies are born on their exact due date, with most arriving within two weeks before or after.
Calculation Methods
Several methods can determine the due date:
Naegele's Rule (LMP-based)
Add 280 days (40 weeks) to the first day of the last menstrual period. This is the most common method used by healthcare providers.
Conception Date
Add 266 days (38 weeks) from the known conception or IVF transfer date. More accurate when the exact date is known.
Ultrasound Dating
First-trimester ultrasound measurements can provide accurate dating, especially when LMP is uncertain.
Using the Due Date API
TinyFn provides a simple endpoint to calculate pregnancy due date:
GET https://api.tinyfn.io/v1/health/due-date?lmp=2024-01-15
Headers: X-API-Key: your-api-key
{
"due_date": "2024-10-21",
"conception_date": "2024-01-29",
"current_week": 12,
"current_day": 3,
"gestational_age": "12 weeks, 3 days",
"trimester": 1,
"days_remaining": 194,
"milestones": {
"first_trimester_end": "2024-04-07",
"second_trimester_end": "2024-07-14",
"viability": "2024-05-26",
"full_term": "2024-10-07"
}
}
Parameters
| Parameter | Type | Description |
|---|---|---|
lmp |
date | First day of last menstrual period (YYYY-MM-DD) |
conception |
date | Conception date (alternative to LMP) |
cycle_length |
integer | Average cycle length in days (default: 28) |
current_date |
date | Reference date for calculations (default: today) |
Code Examples
JavaScript / Node.js
const response = await fetch(
'https://api.tinyfn.io/v1/health/due-date?lmp=2024-01-15',
{ headers: { 'X-API-Key': 'your-api-key' } }
);
const data = await response.json();
console.log(`Due date: ${data.due_date}`); // Due date: 2024-10-21
Python
import requests
response = requests.get(
'https://api.tinyfn.io/v1/health/due-date',
params={'lmp': '2024-01-15'},
headers={'X-API-Key': 'your-api-key'}
)
data = response.json()
print(f"Due: {data['due_date']}, Currently: {data['gestational_age']}")
cURL
curl "https://api.tinyfn.io/v1/health/due-date?lmp=2024-01-15" \
-H "X-API-Key: your-api-key"
Common Use Cases
- Pregnancy Tracking Apps: Display weekly progress and upcoming milestones
- Healthcare Portals: Calculate due dates for patient records
- Parenting Communities: Connect users by due date month
- E-commerce: Time product recommendations and reminders
- Calendar Apps: Add pregnancy milestones and appointments
Best Practices
- Show as estimate: Clearly communicate that the due date is an estimate
- Display week format: "12 weeks, 3 days" is more meaningful than days count
- Include milestones: Show key dates like viability and full-term
- Support adjustment: Allow updating due date based on ultrasound
Use via MCP
Your AI agent can call this tool directly via Model Context Protocol — no HTTP code needed. Add TinyFn to Claude Desktop, Cursor, or any MCP client:
{
"mcpServers": {
"tinyfn-health": {
"url": "https://api.tinyfn.io/mcp/health/",
"headers": {
"X-API-Key": "your-api-key"
}
}
}
}
See all health tools available via MCP in our Health MCP Tools for AI Agents guide.
Try the Pregnancy Due Date API
Get your free API key and start calculating due dates in seconds.
Get Free API Key