City & Location API
Return location, timezone, exact local time, sunrise and sunset for one city.
/api/v1/city/{city}What It Does
Return location, timezone, exact local time, sunrise and sunset for one city.
- HTTP method
- GET
- Authentication
- Public read-only; Bearer keys supported
- Version
- v1
Parameters
Path parameter: city โ required city slug, for example karachi.
| Name | Type | Required | Description |
|---|---|---|---|
country | string | No | Optional country disambiguation. Example: PK |
Request Examples
curl -s 'https://worldclock.to/api/v1/city/karachi?country=PK'const response = await fetch("https:\/\/worldclock.to\/api\/v1\/city\/karachi?country=PK");
const result = await response.json();
console.log(result.data);$response = wp_remote_get('https://worldclock.to/api/v1/city/karachi?country=PK');
= json_decode(wp_remote_retrieve_body(), true);import requests
response = requests.get("https:\/\/worldclock.to\/api\/v1\/city\/karachi?country=PK")
response.raise_for_status()
print(response.json()["data"])Example Response
The values below illustrate the response shape. Live current-time fields are generated dynamically by the endpoint.
{
"success": true,
"data": {
"name": "Karachi",
"slug": "karachi",
"country": "Pakistan",
"country_code": "PK",
"region": "Asia",
"latitude": 24.8599999999999994315658113919198513031005859375,
"longitude": 67.0100000000000051159076974727213382720947265625,
"timezone": "Asia/Karachi",
"utc_offset": "+05:00",
"abbreviation": "PKT",
"dst": false,
"current_time": "2026-09-09T14:30:00+05:00",
"sunrise": "2026-09-09T06:16:04+05:00",
"sunset": "2026-09-09T18:43:31+05:00"
},
"meta": {
"version": "v1",
"timezone": "Asia/Karachi",
"timestamp": 1788946200
}
}Response Properties
Every successful response contains success: true, endpoint-specific data, and a meta object. The table below documents the public fields for this endpoint.
| Property | Meaning |
|---|---|
success | Boolean indicating whether the request completed successfully. |
meta.version | Published API response version. |
meta.timestamp | Unix timestamp for the API response instant. |
meta.timezone | Timezone context used by the response. |
meta.rate_limit | Per-client fair-use limit and remaining-request information on public transports. |
data.name | City display name. |
data.slug | Stable city slug. |
data.country | Country display name. |
data.country_code | Two-letter country code. |
data.region | Bundled state/region value when available. |
data.latitude | Decimal latitude. |
data.longitude | Decimal longitude. |
data.timezone | IANA timezone identifier. |
data.utc_offset | Current UTC offset. |
data.abbreviation | Current timezone abbreviation. |
data.dst | Current daylight-saving state. |
data.current_time | Server-synchronised local ISO 8601 time. |
data.sunrise | Local sunrise time for the current date. |
data.sunset | Local sunset time for the current date. |
Errors use success: false with a stable machine-readable error code and a safe human-readable message.
Errors & HTTP Status Codes
400โ invalid or missing parameter.401โ API key required or invalid when key-only access is enabled.404โ unknown city, country or endpoint.429โ configured rate limit reached.503โ API disabled or maintenance mode.
Rate Limits & Caching
Current fair-use configuration is 60 requests per minute and 5000 requests per day. Cache stable directory/calculation responses where appropriate; treat current-time output as point-in-time data.