Sunrise & Sunset Times API
Sunrise, sunset, solar noon, day length, twilights, golden hour and moon phase for any Vietnamese province or coordinates, for up to 31 days.
The sun times API computes, for a date, the sunrise and sunset, solar noon and the sun’s elevation at noon, the day length, civil, nautical and astronomical twilight, and the golden hour (sun between −4° and +6°, the soft light photographers look for), plus the moon phase in Vietnamese and English, its illumination and the next new and full moon.
Give a province (province=hn, a name such as Đà Nẵng, a 2-digit code, or in the path /v1/sun-times/hcm) or any lat and lon. Times are local, UTC+7 by default (tz changes it), and days (up to 31) returns a series starting at date (default: today in Vietnam).
Everything is calculated with the NOAA solar equations, accurate to about a minute, without any external service, so answers are instant. Near the poles the sunrise is null when the sun does not rise.
Parameters
| Name | In | Type | Required | Default | |
|---|---|---|---|---|---|
province | path|query | string | no | Province code or name (hn, hcm, Đà Nẵng, 48), as ?province= or in the path. Required unless lat / lon. | |
lat | query | number | no | Latitude (with lon). | |
lon | query | number | no | Longitude. | |
date | query | string | no | YYYY-MM-DD (default: today in Vietnam). | |
days | query | number | no | 1 | Number of days (1–31); more than 1 returns a days array. |
tz | query | number | no | 7 | UTC offset of the returned times, in hours. |
Example
curl "https://apibox.io.vn/v1/sun-times?province=Hà Nội&date=2026-11-11" \
-H "Authorization: Bearer YOUR_API_KEY"const res = await fetch('https://apibox.io.vn/v1/sun-times?province=Hà Nội&date=2026-11-11', {
method: 'GET',
headers: {
Authorization: 'Bearer YOUR_API_KEY',
},
});
const data = await res.json();
console.log(data);import requests
res = requests.get(
"https://apibox.io.vn/v1/sun-times?province=Hà Nội&date=2026-11-11",
headers={"Authorization": "Bearer YOUR_API_KEY"},
timeout=30,
)
print(res.json())<?php
$ch = curl_init('https://apibox.io.vn/v1/sun-times?province=Hà Nội&date=2026-11-11');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Authorization: Bearer YOUR_API_KEY'],
]);
$response = curl_exec($ch);
print_r(json_decode($response, true));Response
{
"location": {
"lat": 21.0285,
"lon": 105.8542,
"province_code": "01",
"province": "Thành phố Hà Nội",
"location": "Hà Nội"
},
"timezone_offset": 7,
"date": "2026-11-11",
"sunrise": "06:04",
"sunset": "17:17",
"solar_noon": "11:40",
"day_length": "11h13",
"day_length_hours": 11.21,
"solar_noon_elevation": 51.7,
"civil_twilight": {
"dawn": "05:41",
"dusk": "17:40"
},
"nautical_twilight": {
"dawn": "05:14",
"dusk": "18:07"
},
"astronomical_twilight": {
"dawn": "04:48",
"dusk": "18:33"
},
"golden_hour": {
"morning": [
"05:50",
"06:35"
],
"evening": [
"16:46",
"17:31"
]
},
"moon": {
"phase_vi": "Trăng mới (sóc)",
"phase_en": "New moon",
"age_days": 1.5,
"illumination": 0.024,
"next_new_moon": "2026-12-09",
"next_full_moon": "2026-11-24"
},
"note": "Times in local time (UTC+7 by default), accurate to about one minute; golden hour = sun between −4° and +6°."
}
Use cases
- Plan photo and video shoots at golden hour
- Smart lighting and solar schedules
- Prayer, festival and outdoor event planning
- Show sunrise and sunset in weather and travel apps
FAQ
How accurate is it?
About one minute; local relief (mountains, buildings) is not taken into account.
Which point of a province is used?
The province’s administrative centre; send lat and lon for an exact place.
Can I get a whole month?
Yes, days=31 returns 31 days starting at date.
Related APIs
JSON Validator
Check JSON syntax with exact line and column of errors, and validate data against a JSON Schema (draft 4, 7, 2019-09 or 2020-12).
{ }JSON Formatter
Pretty print JSON with 0-8 spaces or tabs, minify it, or sort object keys recursively. Syntax errors are reported with line and column.
CSVCSV to JSON
Convert CSV into an array of JSON objects using the header row, with delimiter auto-detection, number and boolean typing, and row-level errors.