Best Astronomy APIs for Sunrise, Sunset, and Moon Data — 2026

Whether you're building a photography app that needs golden hour calculations, a smart home system that adjusts lighting at dusk, or a fishing app that tracks moon phases, you need reliable astronomy data. The challenge is finding an API that balances accuracy, features, and cost for your specific use case.

We tested five astronomy APIs across multiple scenarios—from standard sunrise/sunset queries in New York to edge cases like midnight sun in Tromsø, Norway. Here's what we found.

Quick Comparison Table#

FeatureSunrise-Sunset.ioSunrise-Sunset.orgipgeolocation.ioTimeAndDateWorld Data API
PricingFreeFreeFree tier + $9/mo$99-499/year$79-1,349/year
API Key RequiredNoNoYesYesYes
Sunrise/SunsetYesYesYesYesYes
Solar NoonYesYesYesYesYes
Civil TwilightYesYesYesYesYes
Nautical TwilightYesYesYesYesYes
Astronomical TwilightYesYesYesYesYes
Golden HourYesNoYesYesYes
Blue HourYesNoYesYesYes
Moon PhasesNoNoYesYesYes
Moon IlluminationNoNoYesYesYes
Moonrise/MoonsetNoNoYesYesYes
Polar Region HandlingGoodBasicGoodExcellentGood
Solstice/Equinox DataNoNoNoYesNo
Rate LimitsReasonableStrictTier-basedContract-based15K-500K/month

The Contenders#

1. Sunrise-Sunset.io#

Best for: Developers who need reliable sun data without the hassle of API keys

Sunrise-Sunset.io has become the go-to free API for basic solar calculations, and for good reason. It delivers accurate sunrise/sunset times, all three twilight types, and—crucially for photographers—golden hour and blue hour windows.

Sample Request:

GET https://api.sunrisesunset.io/json?lat=40.7128&lng=-74.0060&date=2026-01-19

Sample Response:

json
{
	"results": {
		"sunrise": "7:11:23 AM",
		"sunset": "5:02:47 PM",
		"solar_noon": "12:07:05 PM",
		"day_length": "9:51:24",
		"civil_twilight_begin": "6:43:18 AM",
		"civil_twilight_end": "5:30:52 PM",
		"nautical_twilight_begin": "6:11:02 AM",
		"nautical_twilight_end": "6:03:08 PM",
		"astronomical_twilight_begin": "5:39:15 AM",
		"astronomical_twilight_end": "6:34:55 PM",
		"golden_hour_begin": "4:22:31 PM",
		"golden_hour_end": "5:02:47 PM"
	},
	"status": "OK"
}

Strengths:

  • No API key, no signup, no friction

  • Golden hour and blue hour included (rare for free APIs)

  • Clean, predictable JSON responses

  • Handles polar regions reasonably well with clear status codes

Limitations:

  • Sun data only—no moon phases or lunar calculations

  • No batch requests for multiple dates

  • Times returned in local format, not ISO 8601

Verdict: If you only need sun times and twilight data, Sunrise-Sunset.io is hard to beat. The golden hour inclusion makes it particularly valuable for photography apps.

2. Sunrise-Sunset.org#

Best for: Simple projects where you want a fallback option

Sunrise-Sunset.org offers a similar free service but with a more basic feature set. It's been around longer and has a stable track record, though development appears slower than its .io counterpart.

Sample Request:

GET https://api.sunrise-sunset.org/json?lat=40.7128&lng=-74.0060&date=2026-01-19&formatted=0

Sample Response:

json
{
	"results": {
		"sunrise": "2026-01-19T12:11:23+00:00",
		"sunset": "2026-01-19T22:02:47+00:00",
		"solar_noon": "2026-01-19T17:07:05+00:00",
		"day_length": 35484,
		"civil_twilight_begin": "2026-01-19T11:43:18+00:00",
		"civil_twilight_end": "2026-01-19T22:30:52+00:00",
		"nautical_twilight_begin": "2026-01-19T11:11:02+00:00",
		"nautical_twilight_end": "2026-01-19T23:03:08+00:00",
		"astronomical_twilight_begin": "2026-01-19T10:39:15+00:00",
		"astronomical_twilight_end": "2026-01-19T23:34:55+00:00"
	},
	"status": "OK"
}

Strengths:

  • No API key required

  • Option for ISO 8601 timestamps (better for processing)

  • Day length returned in seconds (easier calculations)

  • Proven reliability over many years

Limitations:

  • No golden hour or blue hour

  • No moon data

  • Stricter rate limits than Sunrise-Sunset.io

  • Less graceful polar region handling

Verdict: A solid backup option, but Sunrise-Sunset.io offers more features at the same price (free). The ISO 8601 timestamps are a nice touch if you prefer working with standardized formats.

3. ipgeolocation.io Astronomy API#

Best for: Teams already using ipgeolocation.io for other services

The ipgeolocation.io Astronomy API is part of a broader geolocation platform, which makes it convenient if you're already using their IP geolocation or timezone services. It's the first option in our list that includes moon data.

Sample Request:

GET https://api.ipgeolocation.io/astronomy?apiKey=YOUR_KEY&lat=40.7128&long=-74.0060

Sample Response:

json
{
	"location": {
		"latitude": 40.7128,
		"longitude": -74.006
	},
	"date": "2026-01-19",
	"sunrise": "07:11",
	"sunset": "17:02",
	"solar_noon": "12:07",
	"day_length": "09:51",
	"sun_altitude": 28.45,
	"sun_azimuth": 165.32,
	"moonrise": "21:45",
	"moonset": "09:32",
	"moon_altitude": -15.23,
	"moon_azimuth": 285.67,
	"moon_parallactic_angle": -42.15,
	"moon_phase": "Waning Crescent",
	"moon_illumination": 12
}

Strengths:

  • Moon phases and illumination included

  • Current sun/moon altitude and azimuth (useful for real-time apps)

  • Integrates with their other geolocation services

  • Free tier available (1,000 requests/day)

Limitations:

  • API key required

  • Twilight data less detailed than dedicated sun APIs

  • Pricing can add up if you need multiple ipgeolocation services

Pricing:

  • Free: 1,000 requests/day

  • Bronze: $15/month for 150K requests

  • Silver: $35/month for 500K requests

  • Gold: $75/month for 2M requests

Verdict: A good middle-ground option, especially if you need moon data but don't want to pay TimeAndDate prices. The real-time altitude/azimuth data is useful for apps that need to know where celestial bodies are right now, not just when they rise and set.

4. TimeAndDate Astronomy API#

Best for: Applications requiring the most comprehensive astronomy data available

TimeAndDate is the heavyweight champion of astronomy APIs. If you need solstice dates, eclipse predictions, detailed moon phase calendars, or rock-solid polar region handling, this is your answer. The depth of data is unmatched.

Strengths:

  • Most comprehensive astronomy data available

  • Excellent polar region handling with detailed midnight sun/polar night info

  • Eclipse predictions and astronomical events

  • Solstice, equinox, and season data

  • Moon age and precise illumination percentages

  • Batch requests for multiple locations and date ranges

  • Proven accuracy used by major organizations

Limitations:

  • Most expensive option

  • Requires contract/subscription

  • XML-centric (JSON available but feels secondary)

  • Overkill for simple sunrise/sunset needs

Pricing:

  • Starter: $99/year (limited requests)

  • Professional: $249/year

  • Business: $499/year

  • Enterprise: Custom pricing

Verdict: If astronomy data is core to your product—whether you're building a professional photography planning tool, a marine navigation app, or an astronomical observation platform—TimeAndDate is worth the investment. The depth of features and edge case handling justifies the premium pricing. For simpler needs, it's overkill.

5. World Data API#

Best for: Teams that need astronomy data alongside country info, holidays, and other reference data

World Data API approaches astronomy as one component of a comprehensive reference data platform. You get sun times, moon phases, and twilight calculations bundled with country data, public holidays, currency information, and more—all for a single annual fee.

Strengths:

  • Astronomy bundled with other useful data categories (holidays, business days, timezones)

  • Single API key for multiple data types

  • Predictable annual pricing

  • Golden hour and blue hour included

  • Moon phases and illumination

  • Good documentation

Limitations:

  • Astronomy features less deep than TimeAndDate

  • No eclipse or astronomical event predictions

  • No solstice/equinox data

Pricing:

TierPriceRequests
Free$060/day
Starter$9/month or $79/year15,000/month
Pro$49/month or $449/year100,000/month
Growth$149/month or $1,349/year500,000/month

Verdict: World Data API makes sense if you need astronomy data plus other reference data like holidays, country information, or business day calculations. The bundled approach offers good value, though the astronomy features don't match TimeAndDate's depth. If astronomy is your only need, the free options serve you better.

Edge Case: Polar Region Handling#

We tested each API with coordinates for Tromsø, Norway (69.6°N) during the polar night period. Here's how they handled it:

APIPolar Night ResponseQuality
Sunrise-Sunset.ioReturns status "POLAR_NIGHT" with twilight times still providedGood
Sunrise-Sunset.orgReturns sunrise/sunset as "null"Basic
ipgeolocation.ioReturns "--:--" for missing events with explanationGood
TimeAndDateDetailed response including civil twilight duration, when sun is closest to horizonExcellent
World Data APIReturns null values with "polar_night": true flagGood

TimeAndDate stands out here with genuinely useful data even when the sun doesn't rise—you still learn how close the sun gets to the horizon and exactly how much civil twilight you'll have.

Recommendations by Use Case#

Building a photography app? Start with Sunrise-Sunset.io for the free golden hour data. Upgrade to TimeAndDate if you need moon phases or more precise calculations for professional photographers.

Smart home automation? Sunrise-Sunset.io handles basic dawn/dusk triggers perfectly. No reason to pay for more.

Marine or aviation application? TimeAndDate is worth the investment. Accurate twilight calculations and polar region handling matter when safety is involved.

Building a fishing or hunting app? ipgeolocation.io offers a good balance of sun and moon data at a reasonable price. Moon phases affect wildlife behavior, so you need both.

Need astronomy plus other reference data? World Data API makes sense if you're already using (or planning to use) our holiday, country, or timezone endpoints. One subscription, one API key, consistent documentation.

Just need basic sun times? Sunrise-Sunset.io. It's free, it works, and it requires no setup.

Final Thoughts#

The astronomy API space has a clear hierarchy: free options work great for basic sun calculations, mid-tier options add moon data, and TimeAndDate dominates the premium segment with unmatched depth.

For most developers, Sunrise-Sunset.io is the right starting point. It's free, requires no API key, and includes golden hour—a feature that many paid APIs lack. Only upgrade when you hit a specific limitation.

If your application genuinely needs comprehensive astronomy data, TimeAndDate is the gold standard. The pricing is higher, but the accuracy, edge case handling, and feature depth justify it for professional applications.

World Data API occupies a practical middle ground: solid astronomy features bundled with other reference data at a predictable annual cost. It's not the deepest astronomy API, but if you need multiple data categories, the bundled approach simplifies your stack and your billing.