Daylight Duration Calculator API

GET

Know exact sunrise, sunset, and daylight hours for any location.

Daylight Duration Calculator computes sunrise, sunset times, and total daylight hours for any geographic location and date using astronomical algorithms.

Try it — live request, no key required

Request
GETapi.apiverve.com/v1/daylightduration?latitude=40.7128&longitude=-74.0060
Query parameters
Verification
Format

No key required to try it. Get a key to use it in your app.

Example
{
  "status": "ok",
  "error": null,
  "data": {
    "date": "2024-06-21",
    "location": {
      "latitude": 40.7128,
      "longitude": -74.006
    },
    "condition": "Normal",
    "description": "Standard sunrise and sunset",
    "sunrise": "09:25:09",
    "sunset": "24:30:44",
    "daylight_duration": {
      "total_minutes": 905.58,
      "hours": 15,
      "minutes": 5,
      "formatted": "15:05:00"
    },
    "day_of_year": 173,
    "is_valid": true
  }
}

About the Daylight Duration Calculator API

Returns detailed information including day of year, sunrise/sunset times, and formatted daylight duration, perfect for solar energy, agriculture, and travel applications.

What people use it for

Solar Optimization
Calculate daylight hours for solar panel optimization and energy production forecasting based on geographic location
Activity Planning
Plan outdoor activities and events based on accurate sunset and sunrise times for any location and date
Weather Apps
Build weather and astronomy applications with precise daylight duration calculations and solar position data
Photography Scheduling
Schedule photography sessions based on golden hour timing, blue hour, and optimal natural lighting conditions

Ways to call it

One endpoint, many ways in — REST with JSON, XML, YAML and CSV, plus GraphQL and an MCP interface for AI agents.

JSON
Default REST response
XML
Markup format
YAML
Human-readable
CSV
Tabular export
Beta
GraphQL
Query language
New
MCP
For AI agents

Other ways to use Daylight Duration Calculator

Same data, same APIVerve account, same credit balance — one key works on all of them.

Questions.

Common questions about the Daylight Duration Calculator API.

Read the docs →
Can I calculate daylight hours for any coordinate worldwide?
Yes. Daylight Duration Calculator accepts any valid latitude and longitude pair on Earth. It uses astronomical algorithms to compute sunrise, sunset, total daylight duration, and the Julian day of the year for that location.
Can I query historical or future dates on the Free plan?
No. The date parameter requires a paid plan, so requests on the Free plan default to today. Upgrading to Starter or above also unlocks the condition field, which identifies polar day or night events, and total daylight duration in decimal minutes.
How does the API handle locations experiencing polar day or polar night?
For polar regions where the sun never rises or sets on a given date, the API returns the specific solar status in the condition field on paid plans. The response also provides an is_valid boolean so your application can verify whether standard sunrise and sunset times apply.
Does the API account for leap years?
Yes. The calculation supports 366-day leap years and returns the day of the year from 1 to 366. The underlying astronomical algorithms automatically factor in leap days when computing daylight duration for your requested date.
Is it cheap enough to calculate daylight hours for every location search?
Yes. Starter provides 100,000 calculations each month at 2 credits per call, which works out to about $0.0003 per calculation or $0.30 per 1,000 lookups. You can also test your integration on the Free plan with 100 calls per month.

Ready to build with Daylight Duration Calculator? Start with 200 free credits — one key unlocks all 300+ APIs.

Explore the catalog

300+ APIs on the same key and the same response shape.

Browse all APIs