{
"lat": 40.4168,
"lon": -3.7038,
"timezone": "Europe/Madrid",
"date": "2026-06-21",
"sunrise": "2026-06-21T06:45:59+02:00",
"sunset": "2026-06-21T21:49:38+02:00",
"solarNoon": "2026-06-21T14:17:48+02:00",
"nadir": "2026-06-21T02:17:48+02:00",
"dayLength": "15h 3m 39s",
"dayLengthSeconds": 54219,
"civilTwilight": {
"dawn": "2026-06-21T06:12:47+02:00",
"dusk": "2026-06-21T22:22:49+02:00"
},
"nauticalTwilight": {
"dawn": "2026-06-21T05:30:30+02:00",
"dusk": "2026-06-21T23:05:06+02:00"
},
"astronomicalTwilight": {
"dawn": "2026-06-21T04:40:48+02:00",
"dusk": "2026-06-21T23:54:49+02:00"
},
"goldenHour": {
"morningEnds": "2026-06-21T07:27:04+02:00",
"eveningStarts": "2026-06-21T21:08:32+02:00"
},
"sunAltitudeAtNoonDeg": 73.02
}
curl --location --request GET 'https://zylalabs.com/api/14209/sunrise+sunset+and+moon+phase+api/35275/sun+times?lat=40.4168&lon=-3.7038&date=2026-06-21&tz=auto' --header 'Authorization: Bearer YOUR_API_KEY'
{
"lat": 40.4168,
"lon": -3.7038,
"timezone": "Europe/Madrid",
"at": "2026-06-21T14:14:48+02:00",
"phase": "First Quarter",
"emoji": "🌓",
"phaseValue": 0.2349,
"illuminationPercent": 45.3,
"ageDays": 6.9,
"waxing": true,
"moonrise": "2026-06-21T13:48:26+02:00",
"moonset": null,
"alwaysUp": false,
"alwaysDown": false,
"position": {
"altitudeDeg": 4.77,
"azimuthDeg": 92.44,
"distanceKm": 384071
},
"nextNewMoon": "2026-07-14T09:18:30+02:00",
"nextFullMoon": "2026-06-30T01:37:23+02:00"
}
curl --location --request GET 'https://zylalabs.com/api/14209/sunrise+sunset+and+moon+phase+api/35276/moon+phase+and+times?lat=40.4168&lon=-3.7038&date=2026-06-21&tz=auto' --header 'Authorization: Bearer YOUR_API_KEY'
After signing up, every developer is assigned a personal API access key, a unique combination of letters and digits provided to access to our API endpoint. To authenticate with the Sunrise Sunset and Moon Phase API simply include your bearer token in the Authorization header.
| Header | Description |
|---|---|
Authorization
|
Required
Should be Bearer access_key. See "Your API Access Key" above when you are subscribed.
|
No long-term commitment. Upgrade, downgrade, or cancel anytime. Free Trial includes up to 50 requests.
The "GET Sun times" endpoint returns data on sunrise, sunset, solar noon, day length, twilight phases, golden hour, and moon information including phase and moonrise/moonset times. The "GET Moon phase and times" endpoint provides moon phase details, illumination, moonrise/moonset times, and the next new and full moon dates.
Key fields include latitude (lat), longitude (lon), timezone, date, sunrise, sunset, solar noon, day length, twilight times, golden hour, moon phase, illumination percentage, moonrise, and moonset times. Each field provides specific information relevant to the sun and moon's position and phases.
Users can specify coordinates (latitude and longitude) and a date for their requests. This allows customization of the data returned based on specific locations and times, enabling tailored results for any desired geographic area and date.
The response data is structured in JSON format, with nested objects for twilight and golden hour times. Each key-value pair provides specific information, making it easy to parse and utilize the data programmatically for applications like astronomy or photography.
The API sources its data from astronomical calculations based on established algorithms for solar and lunar positions. This ensures high accuracy in the timing of sunrise, sunset, moon phases, and other related phenomena.
Typical use cases include planning outdoor activities, photography, gardening, and astronomical observations. Users can leverage the data to optimize timing for events based on sunlight and moonlight availability.
Users can utilize the returned data by integrating it into applications for scheduling events, creating alerts for specific sun or moon phases, or generating visualizations of solar and lunar cycles based on the provided times and phases.
If results are partial or empty, users should check the input parameters for accuracy, such as valid coordinates and dates. Implementing error handling in applications can help manage these scenarios gracefully, ensuring a smooth user experience.
To obtain your API key, first sign in to your account and navigate to the API you want to use. From the API's Pricing section, choose a plan and complete the subscription process. Once subscribed, return to the API page and you will see your API Access Key displayed at the top of the documentation page. You can use this key to authenticate your requests.
You can’t switch APIs during the free trial. If you subscribe to a different API, your trial will end and the new subscription will start as a paid plan.
The free trial lasts for 7 days and allows you to make up to 50 API requests.
No, the free trial is available only once, so we recommend using it on the API that interests you the most. Most of our APIs offer a free trial, but some may not include this option.
Yes. If the API offers a free trial, you will see a "Free 7-Day Trial" option in its Pricing section. The trial lasts for 7 days and allows up to 50 API requests, enabling you to evaluate the API before subscribing to a paid plan.
Zyla API Hub is like a big store for APIs, where you can find thousands of them all in one place. We also offer dedicated support and real-time monitoring of all APIs. Once you sign up, you can pick and choose which APIs you want to use. Just remember, each API needs its own subscription. But if you subscribe to multiple ones, you'll use the same key for all of them, making things easier for you.
You can monitor your API usage through the response headers included with every request:
x-zyla-api-calls-monthly-used: Shows the total number of API requests you have used during the current billing period.
x-zyla-api-calls-monthly-remaining: Shows the number of API requests you have remaining for the current billing period.
Yes, you can cancel your subscription at any time. Simply go to the Pricing section of the API you're subscribed to and click the "Unsubscribe" button.
Please note that upgrades, downgrades, and cancellations take effect immediately. Once your subscription is canceled, access to the service will end immediately, regardless of any remaining API calls in your quota.
Please have a look at our Refund Policy: https://zylalabs.com/terms#refund