Time and Date API: Get sunrise and sunset
Gets daily sunrise, sunset, solar noon, day length and civil twilight for a place from Time and Date, for one or more consecutive days. Times are local with UTC offset; days without sunrise or sunset are marked.
Unofficial. Not affiliated with or endorsed by Time and Date.
Inputs
Values from the run on Oct 31, 2026, shown under Output.
- Date optional
date First local calendar date (YYYY-MM-DD), for example 2026-06-20. Defaults to today in the matched place.
2026-11-25
- Days optional
days Number of consecutive days, for example 3. Defaults to 1.
31
Whole number from 1 to 31. Default
1.- Location, required
location City or place to look up, for example Reykjavik. A Time and Date /sun/ page URL or place id also works.
New Delhi
Input as JSON
{ "date": "2026-11-25", "days": 31, "location": "New Delhi"}Output
{ "days": [ { "date": "2026-11-25", "note": null, "sunset": "2026-11-25T17:24+05:30", "sunrise": "2026-11-25T06:51+05:30", "page_url": "https://www.timeanddate.com/sun/india/new-delhi?month=11&year=2026" , "day_length": "10 h 32 min", "solar_noon": "2026-11-25T12:08+05:30", "civil_twilight_end": "2026-11-25T17:49+05:30", "civil_twilight_start": "2026-11-25T06:26+05:30" }, { "date": "2026-11-26", "note": null, "sunset": "2026-11-26T17:24+05:30", "sunrise": "2026-11-26T06:52+05:30", "page_url": "https://www.timeanddate.com/sun/india/new-delhi?month=11&year=2026" , "day_length": "10 h 32 min", "solar_noon": "2026-11-26T12:08+05:30", "civil_twilight_end": "2026-11-26T17:49+05:30", "civil_twilight_start": "2026-11-26T06:26+05:30" }, { "date": "2026-11-27", "note": null, "sunset": "2026-11-27T17:24+05:30", "sunrise": "2026-11-27T06:53+05:30", "page_url": "https://www.timeanddate.com/sun/india/new-delhi?month=11&year=2026" , "day_length": "10 h 31 min", "solar_noon": "2026-11-27T12:08+05:30", "civil_twilight_end": "2026-11-27T17:49+05:30", "civil_twilight_start": "2026-11-27T06:27+05:30" } ], "place": "New Delhi, Delhi, India"}Code
curl https://api.fous.com/v1/runs \ -H "Authorization: Bearer $FOUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{"method":"timeanddate.com/get_sunrise_and_sunset","input":{"date":"2026-11-25","days":31,"location":"New Delhi"}}' # Save as fous.py, then run: python3 fous.pyimport json, os, timefrom urllib.error import HTTPErrorfrom urllib.request import Request, urlopenAPI = "https://api.fous.com/v1/runs" KEY = os.environ["FOUS_API_KEY"]HEADERS = { "Authorization": f"Bearer {KEY}", "Content-Type": "application/json" ,}def call(url, body=None): data = json.dumps(body).encode() if body else None request = Request(url, data, HEADERS) try: with urlopen(request, timeout=120) as r: return r.status, json.load(r) except HTTPError as error: message = json.load(error)["error"]["message"] raise RuntimeError(message) from errorstatus, run = call(API, { "method": "timeanddate.com/get_sunrise_and_sunset" , "input": { "date": "2026-11-25", "days": 31, "location": "New Delhi" }})# 202: still going after 30 s. Ask again until it ends.while status == 202: time.sleep(2) status, run = call(f"{API}/{run['id']}")print(json.dumps(run["data"], indent=2))// Save as fous.mjs, then run: node fous.mjsconst api = "https://api.fous.com/v1/runs" ;const headers = { Authorization: `Bearer ${process.env.FOUS_API_KEY}`, "Content-Type": "application/json" ,};let response = await fetch(api, { method: "POST", headers, body: JSON.stringify({ "method": "timeanddate.com/get_sunrise_and_sunset" , "input": { "date": "2026-11-25", "days": 31, "location": "New Delhi" } }), signal: AbortSignal.timeout(120_000),});let run = await response.json();// 202: still going after 30 s. Ask again until it ends.while (response.status === 202) { await new Promise((done) => setTimeout(done, 2_000)); response = await fetch(`${api}/${run.id}`, { headers }); run = await response.json();}if (!response.ok) throw new Error(run.error.message);console.log(run.data);# Connect your agent to Fous once, over MCP (Streamable HTTP):# https://api.fous.com/mcp# Set FOUS_API_KEY first: create a key at https://app.fous.com/keys.# Claude Codeclaude mcp add \ --scope user \ --transport http fous https://api.fous.com/mcp \ --header "Authorization: Bearer ${FOUS_API_KEY:?Set FOUS_API_KEY to your Fous API key}"# Codexcodex mcp add fous \ --url https://api.fous.com/mcp \ --bearer-token-env-var FOUS_API_KEY# Cursor, VS Code, Windsurf, Cline and morenpx -y add-mcp https://api.fous.com/mcp -g -n fous \ --header "Authorization: Bearer ${FOUS_API_KEY:?Set FOUS_API_KEY to your Fous API key}"# Then ask your agent:# "Use Fous to run timeanddate.com/get_sunrise_and_sunset# with {"date":"2026-11-25","days":31,"location":"New Delhi"}"Over HTTP, the answer’s data holds the output. A run still going after 30 seconds answers 202 with its id: ask GET /v1/runs/{id} until it ends.
Schema
Input schema
{ "type": "object", "required": [ "location" ], "properties": { "date": { "type": "string", "description": "First local calendar date (YYYY-MM-DD), for example 2026-06-20. Defaults to today in the matched place." }, "days": { "type": "integer", "default": 1, "maximum": 31, "minimum": 1, "description": "Number of consecutive days, for example 3. Defaults to 1." }, "location": { "type": "string", "minLength": 1, "description": "City or place to look up, for example Reykjavik. A Time and Date /sun/ page URL or place id also works." } }}Output schema
{ "type": "object", "required": [ "place", "days" ], "properties": { "days": { "type": "array", "items": { "type": "object", "required": [ "date", "sunrise", "sunset", "solar_noon", "day_length", "civil_twilight_start", "civil_twilight_end", "note", "page_url" ], "properties": { "date": { "type": "string" }, "note": { "type": [ "string", "null" ], "description": "Reason a sun or twilight time is unavailable." }, "sunset": { "type": [ "string", "null" ], "description": "Sunset in local ISO 8601 time with UTC offset." }, "sunrise": { "type": [ "string", "null" ], "description": "Sunrise in local ISO 8601 time with UTC offset." }, "page_url": { "type": "string", "description": "Place sunrise and sunset page for this date." }, "day_length": { "type": [ "string", "null" ], "description": "Length of daylight in hours and minutes." }, "solar_noon": { "type": [ "string", "null" ], "description": "Solar noon in local ISO 8601 time with UTC offset." }, "civil_twilight_end": { "type": [ "string", "null" ], "description": "End of civil twilight in local ISO 8601 time with UTC offset." }, "civil_twilight_start": { "type": [ "string", "null" ], "description": "Start of civil twilight in local ISO 8601 time with UTC offset." } }, "additionalProperties": false } }, "place": { "type": "string", "description": "Matched place name." } }, "additionalProperties": false}- Price
- 1 credit per completed run (1¢ with pay as you go); failed runs are free.
- Method
timeanddate.com/get_sunrise_and_sunset- Returns
- place, per day: sunrise, sunset, solar noon, day length, civil twilight start/end, note, page URL
Use it from your agent
Give your agent this line. It reads SKILL.md, gets a Fous API key and connects the Fous MCP server. Its run then takes the method timeanddate.com/get_sunrise_and_sunset with the inputs above.
Ask your agent
- What time does the sun rise and set in Reykjavik on 2026-06-20?
- I need sunrise, sunset and civil twilight times for Tromsø for the 7 days starting December 15, 2025 — flag any days where the sun doesn't rise at all.
- Pull the day length and solar noon for Cape Town for each day from March 1 to March 10, 2026 using timeanddate.com.
- Planning a golden-hour photo shoot in Santorini next week — when is sunset on 2026-05-12 and 2026-05-13, and when does civil twilight end?
- Check Time and Date for today's sunrise and sunset in Anchorage, Alaska, with the UTC offset included.
See more
All Time and Date methodsGets the current local time, time zone, and next daylight saving change for a city listed on Time and Date. Add a state or country to distinguish cities with the same name.
timeanddate.com/get_time_in_cityConverts a meeting time in one city to local times in other cities, with time zones and 09:00-17:00 working-hours status. Supports dates from 1970 to 2030; ambiguous clock-change times use the first occurrence.
timeanddate.com/convert_time_between_citiesCounts weekdays between two dates, excluding nationwide public holidays or, optionally, public holidays in a state or province, from Time and Date's published holiday calendar.
timeanddate.com/count_business_daysGets The Weather Channel's daily forecast for a city, address, ZIP code or postcode: up to 15 upcoming days with highs, lows, conditions, rain chance, wind, humidity, UV and sun times.
weather.com/get_daily_forecastFinds the nearest NOAA tide prediction station to a US coastal place (within 30 miles) and returns its high and low tide times in local time with predicted heights above MLLW.
tidesandcurrents.noaa.gov/get_tide_timesGets daily weather and time-ordered airport observations for a past date near a city, airport, or ZIP code. Summary averages use the available observations; missing measurements are null.
wunderground.com/get_historical_weatherGets up to 10 days of MSN Weather forecasts for a city, address, or ZIP code, with optional hourly forecasts for the next 24 hours.
msn.com/get_forecastFinds upcoming International Space Station sightings for a city in NASA's city list, with local start times, visibility and sky directions. Cities without scheduled passes return an empty list.
nasa.gov/get_iss_sightings