Health Utilities

Sleep Cycles

Calculate optimal bedtimes and wake times using 90-minute sleep cycles to avoid grogginess. Access via MCP in Cursor or Windsurf for sleep scheduling in health apps, or use GET /v1/health/sleep REST endpoint. Input your desired wake time, get multiple sleep options. Based on REM cycle science — waking between cycles feels more refreshing than mid-cycle interruptions.

API Endpoint

GET /v1/health/sleep

Code Examples

curl "https://tinyfn.io/v1/health/sleep" \
  -H "X-API-Key: YOUR_API_KEY"
const response = await fetch('https://tinyfn.io/v1/health/sleep', {
  headers: { 'X-API-Key': 'YOUR_API_KEY' }
});
const data = await response.json();
console.log(data);
import requests

response = requests.get('https://tinyfn.io/v1/health/sleep',
    headers={'X-API-Key': 'YOUR_API_KEY'})
data = response.json()
print(data)

Use via MCP

Add to your AI agent

Connect your AI agent (Claude, Cursor, Windsurf, etc.) to TinyFn's health tools:

{
  "mcpServers": {
    "tinyfn-health": {
      "url": "https://tinyfn.io/mcp/health",
      "headers": {
        "X-API-Key": "YOUR_API_KEY"
      }
    }
  }
}

Learn more about MCP setup →

FAQ

How do 90-minute sleep cycles work for wake time optimization?

Sleep cycles average 90 minutes from light sleep through deep sleep to REM. Waking at cycle boundaries (after 3, 4.5, 6, 7.5, or 9 hours) typically feels more refreshing than waking mid-cycle during deep sleep phases.

What parameters does the sleep cycles API accept?

Send your target wake time, and optionally specify how many cycle options to return. The API calculates backwards in 90-minute intervals, accounting for average 10-15 minute fall-asleep time.

Can I use this MCP tool to build sleep tracking features in Claude Code?

Yes, the MCP tool integrates directly into Claude Code and other AI coding assistants. Perfect for building sleep schedule features in health apps or personal productivity tools.

Does this account for individual sleep cycle variations?

The tool uses the standard 90-minute average. Individual cycles range 70-120 minutes, so treat results as guidelines rather than rigid schedules for optimal sleep timing.

How does this compare to generic sleep calculators online?

Unlike basic calculators, this API provides programmatic access for integration into apps and workflows. Same core science, but deterministic output format suitable for AI agents and development projects.

Try Sleep Cycles Now

Get your free API key and start using Sleep Cycles in seconds.

Get Free API Key