Wareki Conversion: Japanese Era Date API for AI Agents

Building an AI agent that handles Japanese dates? Japanese government documents, invoices, and legacy systems still use wareki (元号) era years — Reiwa, Heisei, Showa, Taisho, Meiji. Converting between wareki and ISO 8601 requires hardcoded era tables and careful handling of era boundary dates. Torify handles this with a single API call.

Endpoint

GET https://torify.dev/v1/wareki/convert

Parameters

NameTypeRequiredDescriptionExample
direction string Yes Conversion direction: g2w (Gregorian → wareki) or w2g (wareki → Gregorian) g2w
date string No YYYY-MM-DD (required for direction=g2w) 2024-05-01
era string No Era name (令和/平成/昭和/大正/明治 or Reiwa/Heisei/...) for direction=w2g reiwa
eraYear integer No Era year (>= 1) for direction=w2g 6
month integer No Month 1-12 for direction=w2g 5
day integer No Day 1-31 for direction=w2g 1

Response example

{
  "ok": true,
  "data": {
    "era": "令和",
    "eraRomaji": "Reiwa",
    "eraYear": 6,
    "eraYearLabel": "6年",
    "formatted": "令和6年5月1日"
  }
}

Code examples

curl

curl "https://torify.dev/v1/wareki/convert?direction=g2w"

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/wareki/convert?direction=g2w'
);
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/wareki/convert?direction=g2w",
    headers={"X-API-Key": "your_torify_pro_key"}
)
print(res.json())

Use cases

LangChain agent processing Japanese government documents

When an AI agent extracts dates from NTA filings, invoice PDFs, or legacy ERP systems, the wareki era format ("令和6年5月1日") cannot be parsed by Date.parse(). Torify converts it in one call.

HR system migrating Japanese personnel records

Birth dates and hire dates in legacy Japanese HR systems are stored as wareki. When syncing to a global HRIS (Workday, HiBob), wareki → ISO 8601 conversion is required.

Invoice processing with date verification

Japanese B2B invoices reference dates in wareki. Verifying invoice issuance dates against fiscal year boundaries requires accurate era boundary handling (e.g., Showa 64 vs Heisei 1 on January 8, 1989).

Edge cases & gotchas

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).