Catalog/ref-iso-duration

Reference

ISO 8601 duration parser API

Parse an ISO 8601 duration (e.g. P1Y2M10DT2H30M) into a normalized component breakdown, total seconds/minutes/hours/days (nominal 30-day months, 365-day years), and a human-readable phrase; optionally add or subtract it from a base date. ISO-8601 duration grammar is exactly what LLMs mishandle. Answers 'how many seconds is PT1H30M', 'parse this ISO duration', 'add P1D to this date', 'convert PT90M to hours'.

Price$0.01per request
MethodPOST
Route/v1/ref/iso-duration
StatusLive
MIME typeapplication/json
Rate limit60/minute
CacheNo cache
refiso-durationiso-8601durationtimeparsedate-mathinterval
API URLhttps://x402.hexl.dev/v1/ref/iso-duration
Integration docs
Example request
{
  "duration": "PT1H30M"
}
Example response
{
  "duration": "PT1H30M",
  "sign": "positive",
  "components": {
    "year": 0,
    "month": 0,
    "week": 0,
    "day": 0,
    "hour": 1,
    "minute": 30,
    "second": 0
  },
  "totalSeconds": 5400,
  "totalMinutes": 90,
  "totalHours": 1.5,
  "totalDays": 0.063,
  "human": "1 hour, 30 minutes"
}
Input schema
{
  "type": "object",
  "required": [
    "duration"
  ],
  "properties": {
    "duration": {
      "type": "string",
      "examples": [
        "PT1H30M",
        "P1Y2M10DT2H30M"
      ]
    },
    "baseDate": {
      "type": "string",
      "examples": [
        "2020-01-01T00:00:00Z"
      ]
    }
  }
}
Output schema
{
  "type": "object",
  "additionalProperties": true
}