Time API

A simple and efficient REST API for fetching current time information with timezone support.

GitHub Repository: https://github.com/petstack/time-api

API Endpoints

Get Current Time

GET /v1/time?timezone={timezone}

Parameters:

Example Response:

{
  "timestamp": 1634567890,
  "time": "10:13:44.323435",
  "date": "2021-10-18",
  "timezone": "UTC",
  "abbr": "GMT",
  "offset": "+00:00",
  "iso8601": "2021-10-18T10:13:44+00:00"
}

List Available Timezones

GET /v1/timezones

Example Response:

{
  "timezones": [
    {
      "name": "Africa/Abidjan",
      "abbr": "GMT"
    },
    {
      "name": "Africa/Accra",
      "abbr": "GMT"
    },
    {
      "name": "Europe/London",
      "abbr": "BST"
    }
    // ... more timezones
  ]
}

OpenAPI Documentation

GET /v1/openapi.json

Returns the OpenAPI specification for the API.

CORS Support

All API endpoints support Cross-Origin Resource Sharing (CORS) for GET requests. The following CORS headers are included in all GET responses:

Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: GET
Access-Control-Allow-Headers: Content-Type

This allows the API to be accessed from any domain using GET requests.