AliveFor API

Powerful life calculation and countdown APIs for building applications that help people visualize their time.

Overview

The AliveFor API provides programmatic access to life calculation data, real-time countdowns, and sharing capabilities. Perfect for building Mac apps, mobile applications, hardware integrations, and web services.

Base URL

https://alivefor.com/api/v1

Response Format

All API responses are in JSON format with a consistent structure:

{
  "success": true|false,
  "data": { ... },     // Present on success
  "error": "message"   // Present on failure
}

Authentication

Currently, all API endpoints are publicly accessible without authentication. For user-specific data, you'll need to know the username or share ID.

Coming Soon: API keys for rate limiting and advanced features.

API Endpoints

POST Calculate Life Stats

/api/v1/calculate

Calculate life statistics including time lived, remaining time, and percentage of life completed.

Request Body
{
  "birthdate": "1981-04-02",
  "lifespan": 80
}
Response
{
  "success": true,
  "data": {
    "birthdate": "1981-04-02",
    "lifespan": 80,
    "lived": {
      "years": 43,
      "months": 4,
      "days_in_month": 27,
      "hours_in_day": 14,
      "minutes_in_hour": 23,
      "seconds_in_minute": 42
    },
    "remaining": {
      "years": 36,
      "months": 7,
      "days_in_month": 3,
      "hours_in_day": 9,
      "minutes_in_hour": 36,
      "seconds_in_minute": 18
    },
    "percentage": 54.17,
    "death_date": "2061-04-02"
  }
}
Try It Out

GET Get User Profile

/api/v1/user/{username}

Retrieve public user profile with real-time life statistics.

Response
{
  "success": true,
  "data": {
    "username": "michelini",
    "birthdate": "1981-04-02",
    "lifespan": 80,
    "created_at": "2024-12-20T10:30:00",
    "life_stats": {
      "lived": { ... },
      "remaining": { ... },
      "percentage": 54.17
    }
  }
}
Try It Out

GET Real-time Countdown

/api/v1/countdown/{calculation_id}

Get live countdown data for continuous updates. Use user-{username} for user profiles or share IDs for public calculations.

Response
{
  "success": true,
  "data": {
    "countdown_id": "user-michelini",
    "birthdate": "1981-04-02",
    "lifespan": 80,
    "live_stats": { ... },
    "last_updated": "2024-12-20T15:23:45.123Z"
  }
}
Try It Out

POST Create Share

/api/v1/share

Create a shareable public calculation that can be accessed via URL or API.

Request Body
{
  "birthdate": "1990-06-15",
  "lifespan": 85
}
Response
{
  "success": true,
  "data": {
    "share_id": "a1b2c3d4-e5f6-7g8h-9i0j-k1l2m3n4o5p6",
    "share_url": "https://alivefor.com/public/a1b2c3d4-e5f6-7g8h-9i0j-k1l2m3n4o5p6",
    "api_countdown_url": "https://alivefor.com/api/v1/countdown/a1b2c3d4-e5f6-7g8h-9i0j-k1l2m3n4o5p6"
  }
}
Try It Out

GET Directory Users

/api/v1/directory

Get list of users who opted into the public directory. Returns users who have set include_in_directory = true in their profile settings.

Response
{
  "success": true,
  "users": [
    {
      "username": "michelini",
      "birthdate": "1981-04-02",
      "lifespan": 80,
      "created_at": "2025-08-26T15:45:52.405899",
      "stats": {
        "lived": { "days": 16220, "years": 44, ... },
        "remaining": { "days": 13000, "years": 35, ... },
        "percent": 55.51,
        "birthdate": "1981-04-02",
        "lifespan": 80
      }
    }
  ],
  "total": 1
}
Try It Out

Code Examples

JavaScript (Fetch API)

// Calculate life stats
const response = await fetch('/api/v1/calculate', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    birthdate: '1990-01-01',
    lifespan: 80
  })
});

const data = await response.json();
if (data.success) {
  console.log('Life percentage:', data.data.percentage);
}

cURL

curl -X POST https://alivefor.com/api/v1/calculate \
  -H "Content-Type: application/json" \
  -d '{
    "birthdate": "1990-01-01",
    "lifespan": 80
  }'

Swift (for Mac App)

struct LifeStats: Codable {
    let birthdate: String
    let lifespan: Int
    let percentage: Double
}

func getLifeStats(username: String) async {
    let url = URL(string: "https://alivefor.com/api/v1/user/\(username)")!
    let (data, _) = try await URLSession.shared.data(from: url)
    let response = try JSONDecoder().decode(APIResponse.self, from: data)
    
    if response.success {
        updateUI(with: response.data.life_stats)
    }
}

Rate Limits

Current rate limits per IP address:

  • Calculate API: 100 requests per minute
  • User/Countdown APIs: 1000 requests per minute
  • Share API: 10 requests per minute
For higher rate limits, contact us about API key access.