# Sunrise, sunset and golden hour times (`mangudai/sunrise-sunset-golden-hour`) Actor

Calculate sunrise, sunset, solar noon, day length, golden hour, blue hour, and civil, nautical and astronomical twilight for any coordinates and date. Timezone is detected from each location. Pure offline computation, no API key, no sign up.

- **URL**: https://apify.com/mangudai/sunrise-sunset-golden-hour.md
- **Developed by:** [Mangudäi](https://apify.com/mangudai) (community)
- **Categories:** Developer tools, Travel, Open source
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per usage

This Actor is paid per platform usage. The Actor is free to use, and you only pay for the Apify platform usage, which gets cheaper the higher subscription plan you have.

Learn more: https://docs.apify.com/platform/actors/running/actors-in-store#pay-per-usage

## What's an Apify Actor?

Actors are a software tools running on the Apify platform, for all kinds of web data extraction and automation use cases.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

In JavaScript/TypeScript projects, use official [JavaScript/TypeScript client](https://docs.apify.com/api/client/js/docs.md):

```bash
npm install apify-client
```

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python/docs.md):

```bash
pip install apify-client
```

In shell scripts, use [Apify CLI](https://docs.apify.com/cli/docs.md):

````bash
# MacOS / Linux
curl -fsSL https://apify.com/install-cli.sh | bash
# Windows
irm https://apify.com/install-cli.ps1 | iex
```bash

In AI frameworks, you might use the [Apify MCP server](https://docs.apify.com/integrations/mcp.md).

If your project is in a different language, use the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).


# README

## Sunrise, sunset and golden hour times

Work out sunrise, sunset, solar noon, day length, twilight, golden hour and blue hour for any point on Earth and any date. Give a latitude and a longitude, and the actor returns a clean table of solar times with the local timezone already applied.

Everything is computed offline. There is no web API behind it, no key to get, no sign up, and no rate limit to trip over. The times come from the standard NOAA solar position algorithm through the astral library, and the timezone for each place is read from an offline boundary map. Nothing calls out to the internet at run time, so the actor has no moving parts to break and needs no upkeep.

### What it does

For each location and each date it returns:

- Sunrise and sunset.
- Solar noon, the moment the sun sits highest.
- Day length, as a clock value and as decimal hours.
- Civil, nautical and astronomical twilight, both the dawn and the dusk side.
- Morning and evening golden hour, the warm low-sun window photographers plan around.
- Morning and evening blue hour, the cooler window just outside golden hour.

The timezone is detected from the coordinates, so the times you get back are already local to the place you asked about. You can override it by naming an IANA zone such as Europe/Paris.

### Who it is for

Photographers and film crews scheduling around the light, solar and outdoor planners, event and travel planning, and anyone building a calendar or app that needs daylight windows for a list of places.

### Input

Set these in the input form or pass them as JSON.

- Locations. One object per place, each with a name, a latitude, a longitude, and an optional timezone. Leave the timezone out and it is worked out from the coordinates.
- Start date. The first day to calculate, as YYYY-MM-DD. Leave it empty to use today.
- Number of days. How many days from the start date to cover. You get one row per location per day.
- Time format. 24 hour like 05:56, 12 hour like 5:56 AM, or a full ISO datetime with the local offset.
- Include golden hour and blue hour. On by default.
- Include nautical and astronomical twilight. On by default. Civil twilight is always included.

Example input:

```json
{
  "locations": [
    {"name": "San Francisco", "latitude": 37.7749, "longitude": -122.4194},
    {"name": "Reykjavik", "latitude": 64.1466, "longitude": -21.9426, "timezone": "Atlantic/Reykjavik"}
  ],
  "startDate": "2026-06-21",
  "days": 1,
  "timeFormat": "24h"
}
````

### Output

One dataset row per location per date. Each row carries the location name, coordinates, timezone and date, then the solar times: sunrise, solar noon, sunset, day length and decimal day length, civil dawn and dusk, nautical and astronomical dawn and dusk, and the golden and blue hour windows.

Example row:

```json
{
  "name": "San Francisco",
  "date": "2026-06-21",
  "latitude": 37.7749,
  "longitude": -122.4194,
  "timezone": "America/Los_Angeles",
  "sunrise": "05:47",
  "solar_noon": "13:12",
  "sunset": "20:35",
  "day_length": "14:48:07",
  "day_length_hours": 14.802,
  "civil_dawn": "05:16",
  "civil_dusk": "21:07",
  "golden_hour_evening_start": "19:56",
  "golden_hour_evening_end": "20:55",
  "blue_hour_evening_start": "20:55",
  "blue_hour_evening_end": "21:07",
  "nautical_dawn": "04:37",
  "astronomical_dawn": "03:54",
  "note": ""
}
```

### Polar days and nights

Above the Arctic and below the Antarctic circles there are dates when the sun never sets or never rises. On those days the affected times come back empty and the note explains which case it is, so a run over a long list of places still finishes cleanly.

### How the times are worked out

Solar positions use the NOAA algorithm as implemented in astral. Golden hour is the span while the sun sits between 4 degrees below and 6 degrees above the horizon. Blue hour runs from 6 to 4 degrees below. Civil, nautical and astronomical twilight use the usual 6, 12 and 18 degree sun depressions. Timezones come from the timezonefinder boundary data. All of it runs from local computation, which is why the actor stays at zero maintenance.

# Actor input Schema

## `locations` (type: `array`):

One object per place: name, latitude, longitude, and an optional IANA timezone such as Europe/Paris. Leave timezone out to have it detected from the coordinates.

## `startDate` (type: `string`):

First day to calculate. Leave empty to use today in UTC.

## `days` (type: `integer`):

How many days from the start date to calculate, one row per location per day. Up to 366.

## `timeFormat` (type: `string`):

How each time is written. iso keeps the full local datetime with offset, 24h and 12h give a short clock time.

## `includeGoldenBlueHour` (type: `boolean`):

Add the morning and evening golden hour and blue hour windows.

## `includeTwilight` (type: `boolean`):

Add nautical and astronomical dawn and dusk on top of the civil twilight that is always included.

## Actor input object example

```json
{
  "locations": [
    {
      "name": "San Francisco",
      "latitude": 37.7749,
      "longitude": -122.4194
    },
    {
      "name": "London",
      "latitude": 51.5074,
      "longitude": -0.1278
    },
    {
      "name": "Tokyo",
      "latitude": 35.6762,
      "longitude": 139.6503
    }
  ],
  "startDate": "2026-06-21",
  "days": 1,
  "timeFormat": "24h",
  "includeGoldenBlueHour": true,
  "includeTwilight": true
}
```

# Actor output Schema

## `results` (type: `string`):

Each dataset item is one location on one date, with sunrise, sunset, solar noon, day length, twilight, golden hour and blue hour.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "locations": [
        {
            "name": "San Francisco",
            "latitude": 37.7749,
            "longitude": -122.4194
        },
        {
            "name": "London",
            "latitude": 51.5074,
            "longitude": -0.1278
        },
        {
            "name": "Tokyo",
            "latitude": 35.6762,
            "longitude": 139.6503
        }
    ],
    "startDate": "2026-06-21"
};

// Run the Actor and wait for it to finish
const run = await client.actor("mangudai/sunrise-sunset-golden-hour").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "locations": [
        {
            "name": "San Francisco",
            "latitude": 37.7749,
            "longitude": -122.4194,
        },
        {
            "name": "London",
            "latitude": 51.5074,
            "longitude": -0.1278,
        },
        {
            "name": "Tokyo",
            "latitude": 35.6762,
            "longitude": 139.6503,
        },
    ],
    "startDate": "2026-06-21",
}

# Run the Actor and wait for it to finish
run = client.actor("mangudai/sunrise-sunset-golden-hour").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "locations": [
    {
      "name": "San Francisco",
      "latitude": 37.7749,
      "longitude": -122.4194
    },
    {
      "name": "London",
      "latitude": 51.5074,
      "longitude": -0.1278
    },
    {
      "name": "Tokyo",
      "latitude": 35.6762,
      "longitude": 139.6503
    }
  ],
  "startDate": "2026-06-21"
}' |
apify call mangudai/sunrise-sunset-golden-hour --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=mangudai/sunrise-sunset-golden-hour",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "Sunrise, sunset and golden hour times",
        "description": "Calculate sunrise, sunset, solar noon, day length, golden hour, blue hour, and civil, nautical and astronomical twilight for any coordinates and date. Timezone is detected from each location. Pure offline computation, no API key, no sign up.",
        "version": "0.0",
        "x-build-id": "0OFnxjbsD6QkozecZ"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/mangudai~sunrise-sunset-golden-hour/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-mangudai-sunrise-sunset-golden-hour",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/acts/mangudai~sunrise-sunset-golden-hour/runs": {
            "post": {
                "operationId": "runs-sync-mangudai-sunrise-sunset-golden-hour",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor and returns information about the initiated run in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/runsResponseSchema"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/acts/mangudai~sunrise-sunset-golden-hour/run-sync": {
            "post": {
                "operationId": "run-sync-mangudai-sunrise-sunset-golden-hour",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "inputSchema": {
                "type": "object",
                "properties": {
                    "locations": {
                        "title": "Locations",
                        "type": "array",
                        "description": "One object per place: name, latitude, longitude, and an optional IANA timezone such as Europe/Paris. Leave timezone out to have it detected from the coordinates."
                    },
                    "startDate": {
                        "title": "Start date (YYYY-MM-DD)",
                        "type": "string",
                        "description": "First day to calculate. Leave empty to use today in UTC."
                    },
                    "days": {
                        "title": "Number of days",
                        "minimum": 1,
                        "maximum": 366,
                        "type": "integer",
                        "description": "How many days from the start date to calculate, one row per location per day. Up to 366.",
                        "default": 1
                    },
                    "timeFormat": {
                        "title": "Time format",
                        "enum": [
                            "24h",
                            "12h",
                            "iso"
                        ],
                        "type": "string",
                        "description": "How each time is written. iso keeps the full local datetime with offset, 24h and 12h give a short clock time.",
                        "default": "24h"
                    },
                    "includeGoldenBlueHour": {
                        "title": "Include golden hour and blue hour",
                        "type": "boolean",
                        "description": "Add the morning and evening golden hour and blue hour windows.",
                        "default": true
                    },
                    "includeTwilight": {
                        "title": "Include nautical and astronomical twilight",
                        "type": "boolean",
                        "description": "Add nautical and astronomical dawn and dusk on top of the civil twilight that is always included.",
                        "default": true
                    }
                }
            },
            "runsResponseSchema": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "actId": {
                                "type": "string"
                            },
                            "userId": {
                                "type": "string"
                            },
                            "startedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "finishedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "status": {
                                "type": "string",
                                "example": "READY"
                            },
                            "meta": {
                                "type": "object",
                                "properties": {
                                    "origin": {
                                        "type": "string",
                                        "example": "API"
                                    },
                                    "userAgent": {
                                        "type": "string"
                                    }
                                }
                            },
                            "stats": {
                                "type": "object",
                                "properties": {
                                    "inputBodyLen": {
                                        "type": "integer",
                                        "example": 2000
                                    },
                                    "rebootCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "restartCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "resurrectCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "computeUnits": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "options": {
                                "type": "object",
                                "properties": {
                                    "build": {
                                        "type": "string",
                                        "example": "latest"
                                    },
                                    "timeoutSecs": {
                                        "type": "integer",
                                        "example": 300
                                    },
                                    "memoryMbytes": {
                                        "type": "integer",
                                        "example": 1024
                                    },
                                    "diskMbytes": {
                                        "type": "integer",
                                        "example": 2048
                                    }
                                }
                            },
                            "buildId": {
                                "type": "string"
                            },
                            "defaultKeyValueStoreId": {
                                "type": "string"
                            },
                            "defaultDatasetId": {
                                "type": "string"
                            },
                            "defaultRequestQueueId": {
                                "type": "string"
                            },
                            "buildNumber": {
                                "type": "string",
                                "example": "1.0.0"
                            },
                            "containerUrl": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "usageTotalUsd": {
                                "type": "number",
                                "example": 0.00005
                            },
                            "usageUsd": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "number",
                                        "example": 0.00005
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
