Twilight on Earth is the illumination of the lower atmosphere when the Sun is not directly visible because it is below the horizon. Twilight is produced by sunlight scattering in the upper atmosphere, illuminating the lower atmosphere so that Earth's surface is neither completely lit nor completely dark. The word twilight is also used to denote the periods of time when this illumination occurs.[2]
mourner/suncalc: A tiny JavaScript library for calculating sun/moon positions and phases. @GitHub
web services - I need a sunrise/sunset webservice api - Stack Overflow
Sunset and sunrise times API - Sunrise-Sunset.org
since this is a pure mathematical calculation, there is no benefit of calling external web service api
API for sunrise, sunset, moonrise and moonset timing @ip geolocation