Japan Age & School Year Calculation API

Japanese school years run April-March, and the April 1 birthday is the edge case that breaks naive age calculations. Torify handles it correctly per the standard Japanese convention.

Endpoint

GET https://torify.dev/v1/age/calculate

Parameters

NameTypeRequiredDescriptionExample
birthDate string Yes YYYY-MM-DD 2000-04-01
referenceDate string No YYYY-MM-DD (default: today) 2024-04-01

Response example

{ "ok": true, "data": { "age": 24, "schoolYear": 19, "fiscalYear": 2024 } }

Code examples

curl

curl "https://torify.dev/v1/age/calculate?birthDate=2000-04-01"

TypeScript (x402-fetch)

import { wrapFetchWithPayment } from 'x402-fetch';
import { privateKeyToAccount } from 'viem/accounts';

const account = privateKeyToAccount(process.env.PRIVATE_KEY as `0x${string}`);
const fetchWithPayment = wrapFetchWithPayment(fetch, account);

const res = await fetchWithPayment(
  'https://torify.dev/v1/age/calculate?birthDate=2000-04-01'
);
const data = await res.json();
console.log(data); // { ok: true, data: { ... } }

Python (requests)

import requests

# Free MCP tier (no auth) or API key (X-API-Key header)
res = requests.get(
    "https://torify.dev/v1/age/calculate?birthDate=2000-04-01",
    headers={"X-API-Key": "your_torify_pro_key"}
)
print(res.json())

Related endpoints

← All 36 endpoints

Pricing

$0.02 per call via x402 (USDC on Base). Or use a Pro API key ($49/mo, 10,000 calls/month).