# OpenAPI description of wt.utc.wtf, written by hand. # This file is the source: wt.json is generated from it ("make openapi", # tools/openapigen) and both are served as they are (docs/spec.md 14.1). Behaviour # and test vectors stay in docs/spec.md section 14. # # Style as in openapi.yaml: quote every string that could look like anything else, # and quote status codes. openapi: "3.1.0" info: title: wt.utc.wtf version: "1.0.0" summary: Current time in any IANA time zone. description: | - Zones are case-sensitive IANA names, such as `Europe/London`. - Append `.txt` to any path for `text/plain`, such as `/api/timezone/Europe/London.txt`. - Responses carry `Access-Control-Allow-Origin: *` and `Cache-Control: no-store`. - Errors are `{"error": "..."}`, or `Error: ...` as text. Unknown paths are 404. Methods other than GET and HEAD are 405. - This document: [openapi.json](https://wt.utc.wtf/api/openapi.json) or [openapi.yaml](https://wt.utc.wtf/api/openapi.yaml). servers: - url: https://wt.utc.wtf/api - url: http://wt.utc.wtf/api tags: - name: timezone description: Zone lists and the time in a zone. - name: ip description: The time in the client's zone. # Operation IDs must not equal another operation's "-" anchor: the docs # page (RapiDoc) then opens that operation instead (getTimezone opened GET /timezone). paths: /timezone: get: tags: [timezone] operationId: listTimezones summary: List every zone responses: "200": $ref: "#/components/responses/ListJson" "400": $ref: "#/components/responses/BadRequest" "405": $ref: "#/components/responses/MethodNotAllowed" /timezone/{area}: get: tags: [timezone] operationId: listArea summary: List the zones of one area parameters: - $ref: "#/components/parameters/area" responses: "200": $ref: "#/components/responses/ListJson" "400": $ref: "#/components/responses/BadRequest" "404": $ref: "#/components/responses/UnknownLocation" "405": $ref: "#/components/responses/MethodNotAllowed" /timezone/{area}/{location}: get: tags: [timezone] operationId: getZoneTime summary: Current time in a zone parameters: - $ref: "#/components/parameters/area" - $ref: "#/components/parameters/location" - $ref: "#/components/parameters/extended" responses: "200": $ref: "#/components/responses/DateTimeJson" "400": $ref: "#/components/responses/BadRequest" "404": $ref: "#/components/responses/UnknownLocation" "405": $ref: "#/components/responses/MethodNotAllowed" /timezone/{area}/{location}/{region}: get: tags: [timezone] operationId: getZoneTimeRegion summary: Current time in a three-part zone parameters: - $ref: "#/components/parameters/regionArea" - $ref: "#/components/parameters/regionLocation" - $ref: "#/components/parameters/region" - $ref: "#/components/parameters/extended" responses: "200": $ref: "#/components/responses/DateTimeJson" "400": $ref: "#/components/responses/BadRequest" "404": $ref: "#/components/responses/UnknownLocation" "405": $ref: "#/components/responses/MethodNotAllowed" /ip: get: tags: [ip] operationId: getClientTime summary: Current time in the client's zone description: The zone is geolocated from the client's IP address, or `Etc/UTC` when that fails. parameters: - $ref: "#/components/parameters/extended" responses: "200": $ref: "#/components/responses/DateTimeJson" "400": $ref: "#/components/responses/BadRequest" "405": $ref: "#/components/responses/MethodNotAllowed" components: parameters: area: name: area in: path required: true description: First part of an IANA zone name. schema: type: string example: Europe location: name: location in: path required: true description: Second part of an IANA zone name. schema: type: string example: London # The three-part zone's first two parts, with examples that, with region's, name # a real zone (America/Argentina/Buenos_Aires): the docs page fills them in. regionArea: name: area in: path required: true description: First part of an IANA zone name. schema: type: string example: America regionLocation: name: location in: path required: true description: Second part of an IANA zone name. schema: type: string example: Argentina region: name: region in: path required: true description: Third part of an IANA zone name. schema: type: string example: Buenos_Aires extended: name: extended in: query required: false description: "`1` or `true` adds the `extended` object. Any other value is ignored." schema: type: string enum: ["1", "true"] # Response examples are named (examples:), never a bare example: the docs page # (RapiDoc) shows schema placeholders instead of a media type's example, and one # example per item for an array. responses: ListJson: description: Zone names in byte order. content: application/json: schema: $ref: "#/components/schemas/ZoneList" examples: zones: summary: The first zones of the list value: ["Europe/Andorra", "Europe/Astrakhan", "Europe/Athens"] DateTimeJson: description: The current time in the zone. content: application/json: schema: $ref: "#/components/schemas/DateTime" examples: newYork: value: utc_offset: "-04:00" timezone: America/New_York day_of_week: 2 day_of_year: 198 datetime: "2024-07-16T12:58:00.182000-04:00" utc_datetime: "2024-07-16T16:58:00.182000+00:00" unixtime: 1721149080 raw_offset: -18000 week_number: 29 dst: true abbreviation: EDT dst_offset: 3600 dst_from: "2024-03-10T07:00:00+00:00" dst_until: "2024-11-03T06:00:00+00:00" client_ip: 192.0.2.1 UnknownLocation: description: The area has no zones, or the zone is not a valid IANA name. content: application/json: schema: $ref: "#/components/schemas/Error" examples: unknownLocation: value: error: unknown location Africa/nigeria BadRequest: description: The query is longer than 1024 bytes or malformed. content: application/json: schema: $ref: "#/components/schemas/Error" examples: badRequest: value: error: bad request MethodNotAllowed: description: Only GET and HEAD are allowed. headers: Allow: schema: type: string example: GET, HEAD content: application/json: schema: $ref: "#/components/schemas/Error" examples: methodNotAllowed: value: error: method not allowed schemas: ZoneList: type: array items: type: string Error: type: object required: [error] properties: error: type: string additionalProperties: false DateTime: type: object required: [utc_offset, timezone, day_of_week, day_of_year, datetime, utc_datetime, unixtime, raw_offset, week_number, dst, abbreviation, dst_offset, dst_from, dst_until, client_ip] properties: utc_offset: type: string description: Offset from UTC, `±hh:mm`. timezone: type: string description: The zone name as requested. day_of_week: type: integer description: Local day of the week, Sunday 0. day_of_year: type: integer description: Local day of the year, from 1. datetime: type: string description: Local time, ISO 8601 with microseconds and offset. utc_datetime: type: string description: UTC time, ISO 8601 with microseconds and `+00:00`. unixtime: type: integer description: Unix time in seconds. raw_offset: type: integer description: Offset from UTC in seconds, without DST. week_number: type: integer description: ISO week of the local date. dst: type: boolean description: Whether the zone is on DST. abbreviation: type: string description: Zone abbreviation from tzdata, such as `EDT` or `+0545`. dst_offset: type: integer description: DST offset in seconds, 0 off DST. dst_from: type: [string, "null"] description: Start of the current DST period in UTC, null off DST. dst_until: type: [string, "null"] description: End of the current DST period in UTC, null off DST or when tzdata has no end. client_ip: type: string description: The client's IP address, or empty when unknown. extended: $ref: "#/components/schemas/Extended" additionalProperties: false Extended: type: object description: Present only with `?extended=1`. The time, date and clocks of the same instant, in UTC. required: [time, date, clocks] properties: time: type: object required: [utc, unix, rfc2822, http_date] properties: utc: type: string description: ISO 8601 with milliseconds and `Z`. unix: type: object required: [seconds, millis] properties: seconds: type: integer millis: type: integer rfc2822: type: string http_date: type: string date: type: object required: [day_of_week, day_of_year, days_in_month, quarter, is_leap_year, iso_week] properties: day_of_week: type: string description: English day name, such as `Sunday`. day_of_year: type: integer days_in_month: type: integer quarter: type: integer is_leap_year: type: boolean iso_week: type: object required: [year, week, date] properties: year: type: integer week: type: integer date: type: string description: ISO week date, such as `2026-W46-7`. clocks: type: object required: [tai, tai_minus_utc, gps, julian_date, modified_julian_date, swatch_beat, seconds_until_midnight, seconds_until_y2038] properties: tai: type: string description: International Atomic Time, ISO 8601 without an offset. tai_minus_utc: type: integer gps: type: object required: [week, seconds_of_week] properties: week: type: integer seconds_of_week: type: number julian_date: type: number modified_julian_date: type: number swatch_beat: type: string description: Swatch Internet Time, such as `@565.93`. seconds_until_midnight: type: integer description: Seconds until UTC midnight. seconds_until_y2038: type: integer