# Sunrise, Sunset & Moon Phase API: Any Place, Any Date (`tudorlane/sun-moon-times`) Actor

Sunrise, sunset, dawn, dusk, solar noon, day length, golden and blue hour, moonrise, moonset, moon phase and illumination for any city or coordinates and date range, in local time.

- **URL**: https://apify.com/tudorlane/sun-moon-times.md
- **Developed by:** [Tudor Lane](https://apify.com/tudorlane) (community)
- **Categories:** Developer tools
- **Security:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$1.00 / 1,000 sun & moon lookups

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

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

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
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.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## 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.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Sunrise, Sunset & Moon Phase API: Any Place, Any Date

**Use when:** an AI agent or app needs sunrise, sunset, golden hour, day length or moon phase for a city or coordinates on a given date (photo shoots, outdoor events, travel plans, prayer or fasting times, wedding planning), in the place's local time, without guessing.

**Try this input**

```json
{"requests": ["Reykjavik", {"location": "Sydney, AU", "date": "2026-12-25", "days": 2}, {"lat": 78.22, "lon": 15.65, "date": "2026-12-21"}]}
```

**Sample output** (real run, 30 Oct 2026, trimmed)

```json
{"query": "Sydney, AU", "place": "Sydney, New South Wales, Australia", "lat": -33.86785, "lon": 151.20732, "timezone": "Australia/Sydney", "days": [
  {"date": "2026-12-25", "dawn": "2026-12-25T05:13:15+11:00", "sunrise": "2026-12-25T05:42:58+11:00", "noon": "2026-12-25T12:54:58+11:00",
   "sunset": "2026-12-25T20:07:00+11:00", "dusk": "2026-12-25T20:36:43+11:00", "day_length": "14:24:01",
   "golden_hour_morning": ["2026-12-25T05:24:33+11:00", "2026-12-25T06:18:52+11:00"],
   "golden_hour_evening": ["2026-12-25T19:31:07+11:00", "2026-12-25T20:25:25+11:00"],
   "blue_hour_evening": ["2026-12-25T20:25:25+11:00", "2026-12-25T20:36:43+11:00"],
   "moon_phase_day": 15.5, "moon_phase": "full moon", "moon_illumination_pct": 99,
   "moonrise": "2026-12-25T21:32:00+11:00", "moonset": "2026-12-25T06:25:00+11:00"}, "..."], "error": null}
{"query": "78.22,15.65", "place": null, "timezone": "Arctic/Longyearbyen", "days": [{"date": "2026-12-21", "polar": "polar night (sun never rises)", "moon_phase": "waxing gibbous", "moon_illumination_pct": 86}], "error": null}
```

**Options** (each item in `requests` is a place name string or an object):

- `location`: city or "City, Country" (e.g. `"Paris"`, `"Sydney, AU"`), or `lat` + `lon` in decimal degrees.
- `date`: `YYYY-MM-DD`, default today in the place's time zone.
- `days`: 1-31 consecutive days, default 1.
- `timezone`: IANA name (e.g. `"Europe/London"`) to override the detected zone.

Each day has `dawn`, `sunrise`, `noon`, `sunset`, `dusk` (civil), `day_length`, `golden_hour_morning`/`evening` and `blue_hour_evening` as \[start, end], `moon_phase_day` (0-29.5), `moon_phase`, `moon_illumination_pct`, `moonrise`, `moonset` (null when the moon doesn't rise/set that day), or `polar` on days with midnight sun or polar night. Up to 2000 items per run; no API key needed.

**Pricing:** pay per event, **$0.001 per sun & moon lookup** (one place, up to 31 days). Rows with errors (e.g. place not found) are not charged.

### Limits & failure modes

- Times are for sea level with standard refraction; expect ±1-2 minutes, more in mountains or near the poles.
- Ambiguous names pick the most populous match; add the country or pass lat/lon.
- Moonrise/moonset at high latitudes (e.g. Iceland) can come back null on days the moon does rise; treat as approximate above ~60°.
- Illumination % is an approximation from the phase age, not an ephemeris value.
- Calculated locally with astral (Apache 2.0). Place names: GeoNames (CC BY 4.0). Time zones: timezonefinder (MIT).

Last tested: 30 Oct 2026.

### Use from AI agents (MCP)

- **Apify MCP server:** add `https://mcp.apify.com/?tools=tudorlane/sun-moon-times` to Claude, Cursor, ChatGPT, VS Code or any MCP client.
- **REST:** `POST https://api.apify.com/v2/acts/tudorlane~sun-moon-times/run-sync-get-dataset-items?token=YOUR_TOKEN` with the input JSON.

# Actor input Schema

## `requests` (type: `array`):

Each item: {"location": "Paris"} or {"lat": 51.5, "lon": -0.12}, optional date (YYYY-MM-DD), days (1-31), timezone. Max 2000. Errors are not charged.

## Actor input object example

```json
{
  "requests": [
    {
      "location": "London, UK"
    },
    {
      "lat": 40.7128,
      "lon": -74.006,
      "date": "2026-12-21"
    }
  ]
}
```

# Actor output Schema

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

One item per request.

## `dataset` (type: `string`):

No description

# 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 = {
    "requests": [
        {
            "location": "London, UK"
        },
        {
            "lat": 40.7128,
            "lon": -74.006,
            "date": "2026-12-21"
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("tudorlane/sun-moon-times").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 = { "requests": [
        { "location": "London, UK" },
        {
            "lat": 40.7128,
            "lon": -74.006,
            "date": "2026-12-21",
        },
    ] }

# Run the Actor and wait for it to finish
run = client.actor("tudorlane/sun-moon-times").call(run_input=run_input)

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

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

```

## CLI example

```bash
echo '{
  "requests": [
    {
      "location": "London, UK"
    },
    {
      "lat": 40.7128,
      "lon": -74.006,
      "date": "2026-12-21"
    }
  ]
}' |
apify call tudorlane/sun-moon-times --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,tudorlane/sun-moon-times"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/tSRhENXCnTdYLBP3w/builds/Zed6TawuY9THfSkje/openapi.json
