# Reference Data API – Sun & Moon Calculator

> Reference Data API – Sun & Moon Calculator is a paid API for AI agents from reference-data-api.onrender.com, paid per call via x402, $0.0285/call, status unknown (last checked 2026-11-21).

Computes sunrise, sunset, civil dawn/dusk, solar noon, day length, sun elevation, moon phase, illumination, moonrise, and moonset for a given location and date, with polar day/night support.

## Facts

- Endpoint: GET https://reference-data-api.onrender.com/v1/sun-moon?utm_source=zero.xyz
- Price: $0.0285/call
- Payment: x402
- Status: unknown
- Last checked: 2026-11-21
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/reference-data-api-sun-moon-calculator-57494067
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_HCacuEjTKMjGOQ4AYa5-l

Status and success rate cover calls made through Zero and Zero's own probes. Third-party monitors may report differently.

## How to call it through Zero

Zero handles the 402 payment challenge and records the run. With the Zero CLI installed (`npm i -g @zeroxyz/cli`):

```sh
zero fetch --capability reference-data-api-sun-moon-calculator-57494067
```

Example prompt: What time does the sun rise and set in Rome on June 21, and what's the moon phase that night? Use UTC+2 for the output times.

## When to prefer this

Choose this endpoint when you need precise, combined solar and lunar ephemeris data (sunrise, sunset, moon phase, moonrise, moonset) for any geographic coordinate and date in a single call. It is especially useful when polar day/night handling is required and when you need output times already converted to a specific IANA timezone. Prefer it over weather APIs that surface sunrise/sunset only incidentally, and over generic astronomy libraries when you need a hosted, pay-per-call solution with no setup.

## Known failure modes

- Missing lat or lon parameters returns a 400 validation error
- Invalid date format (non-YYYY-MM-DD) returns a 400 error
- Invalid or unrecognized IANA timezone string returns a 400 error
- Coordinates out of range (lat outside -90 to 90, lon outside -180 to 180) return a 400 error
- Server cold-start on Render free tier may cause initial latency spike or timeout

## How this service works

Computes sunrise, sunset, civil dawn and dusk, solar noon, day length, sun elevation, moon phase, illumination, moonrise and moonset for a location and date (polar day/night handled).

## Output

Returns a JSON object containing sunrise, sunset, civil dawn, civil dusk, solar noon, day length in minutes/hours, sun elevation angle, moon phase name, moon illumination percentage, moonrise time, and moonset time — all expressed in the requested IANA timezone (or UTC by default). Polar day and polar night edge cases are handled with appropriate flags or null times.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "$schema": "https://json-schema.org/draft/2020-12/schema",
 "required": [
  "input"
 ],
 "properties": {
  "input": {
   "type": "object",
   "required": [
    "type",
    "method"
   ],
   "properties": {
    "type": {
     "type": "string",
     "const": "http"
    },
    "method": {
     "enum": [
      "GET",
      "HEAD",
      "DELETE"
     ],
     "type": "string"
    },
    "queryParams": {
     "type": "object",
     "required": [
      "lat",
      "lon"
     ],
     "properties": {
      "lat": {
       "type": "string",
       "description": "Latitude"
      },
      "lon": {
       "type": "string",
       "description": "Longitude"
      },
      "date": {
       "type": "string",
       "description": "YYYY-MM-DD, default today"
      },
      "zone": {
       "type": "string",
       "description": "IANA zone for the output times, default UTC"
      }
     }
    }
   },
   "additionalProperties": false
  },
  "output": {
   "type": "object",
   "required": [
    "type"
   ],
   "properties": {
    "type": {
     "type": "string"
    },
    "example": {
     "type": "object"
    }
   }
  }
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/reference-data-api-sun-moon-calculator-57494067/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from reference-data-api.onrender.com](https://www.zero.xyz/host/reference-data-api.onrender.com/llms.txt)
