close
Get the most reliable climate data
Thanks for submitting!
Oops! Something went wrong while submitting the form.

The Astronomy API is Here. The Sun's Position is Now a Data Field.

May 5, 2026
2 min read
Ambee Astronomy API Launch
Ambee Author
VP of Engineering
quotation

Ambee's Astronomy API returns sunrise time, sunset time, solar azimuth, and solar elevation for any latitude-longitude pair on Earth. Every response includes timezone-aware local timestamps in ISO 8601 format. The API supports present, historical, and 30-day forecast queries. It is part of Ambee's climate data suite, which also includes weather, air quality, pollen, wildfire, and natural disaster APIs, all accessible through a single API key. Developers can start for free with 100 API records per day for 15 days.

{{key-insights}}
The sun rises. The sun sets. And between those two moments, every solar panel, smart thermostat, farm irrigation schedule, and logistics route on the planet is making decisions based on where the sun is in the sky.

Most of those decisions are still based on approximations. Static lookup tables and hardcoded clock rules that drift with the seasons. Timezone math breaks at the edges.

That's why we built the Astronomy API.

What is an astronomy API?

An astronomy API is a programmatic interface that returns solar event data and solar position data for any geographic coordinate. Solar event data includes sunrise and sunset times. Solar position data includes solar azimuth (the sun's compass direction) and solar elevation (the sun's angle above the horizon).

Developers use astronomy APIs to power solar energy systems, smart home automations, agricultural planning tools, construction and architecture workflows, photography apps, and logistics scheduling platforms. Basically, any product or operation where the sun's position is a decision-making input.

The sun drives real-world decisions, but most products aren’t using real data

Every product that touches the physical world eventually has to answer a solar question. When does the sun rise at this location? Where is it in the sky right now? How many hours of daylight are left?

Solar energy platforms need azimuth and elevation to optimize panel angles. Smart home systems need real sunrise and sunset times, not rough approximations, to trigger lighting and HVAC schedules that actually match the light hitting the building. 

Even Agricultural tools need daylight hours at the field level. Logistics teams also need to know when darkness falls to adjust delivery windows.

These are core inputs. Until now, getting reliable solar position data meant either writing your own astronomical calculations, pulling from fragmented free APIs with inconsistent formats, or paying for a standalone provider that doesn't connect to the rest of your environmental data stack.

The Astronomy API leaves all that in the past.

Sunrise, sunset, azimuth, and elevation: what you get in a single API call

One call to Ambee's Astronomy API returns everything you need to build solar-aware features:

Sunrise and sunset in local time. Every response includes ISO 8601 timestamps with the location's timezone offset. Query coordinates in Mumbai, you get sunrise in IST. Coordinates in Chicago, you get CST. Your UI, your scheduler, and your control system can use the values directly. 

Solar azimuth and solar elevation for the current hour. Azimuth is the sun's compass direction in degrees: 0° is north, 90° is east, 180° is south, 270° is west. Elevation is the sun's angle above the horizon. Positive values mean the sun is up. Negative values mean it's below the horizon. These two numbers are standard inputs for solar tracking, shadow analysis, and energy modeling.

Global coverage. You have unfiltered access to any latitude-longitude pair on the planet. The API auto-detects the local timezone from the coordinates you provide.

Here is what a response looks like:

{
  "message": "success",
  "data": [
    {
      "lat": 12,
      "lng": 77,
      "timezone": "Asia/Kolkata",
      "timestamp": "2026-03-24T05:00:00.000Z",
      "solar_azimuth": 108.22,
      "solar_elevation": 58.51,
      "sunrise": "2026-03-24T06:24:33+05:30",
      "sunset": "2026-03-24T18:33:16+05:30"
    }
  ]
}

Sunrise at 6:24 AM IST. Sunset at 6:33 PM IST. The sun sitting at 108 degrees azimuth and 58.5 degrees above the horizon. Clean JSON. No nesting. Ready to parse.

Present, historical, and forecast: three endpoints lead to one response structure

The API supports three endpoints, all returning the same response structure:

Present: The sun's current position plus today's sunrise and sunset. This is the endpoint most products will hit in real time.

Historical: Solar data for any past date range. Built for analytics, backtesting energy models, and building historical daylight datasets.

Forecast: A 30-day forward view. Use it for scheduling, operational planning, and ahead-of-time features.

Same fields. Same developer experience. Same authentication across all three.

Free to start, one minute to your first call

Sign up to Ambee's API dashboard to enjoy a free trial: 100 API records per day for 15 days, no credit card required. Your API key goes in the x-api-key header, same pattern as every other Ambee API. 

If you use Ambee's weather, air quality, or pollen data, you already know how it works.

Pair sun data with weather, air quality, pollen, and wildfire in one stack

Usually, you get a sunrise and sunset API from one provider, weather from another, and air quality from a third. Three API keys mean three billing relationships and often three different data formats. 

Ambee's Astronomy API sits inside a larger environmental data stack. Combine solar position with real-time weather forecasts for solar irradiance estimates. Layer in air quality data for UV exposure modeling. Add pollen counts for allergy-aware outdoor scheduling. Pair with wildfire risk data to understand how smoke and haze affect solar output.

From solar farms to smart homes: who uses an astronomy API

Solar energy and renewables. Optimize panel tilt angles using the present azimuth and elevation. Predict energy generation windows by combining sun position with weather forecasts for cloud cover.

Smart home and IoT. Replace fixed clock-based automations with sun-aware triggers tied to the user's exact location. Lighting, blinds, and HVAC that respond to actual conditions instead of static schedules that drift with the seasons.

Agriculture and precision farming. Align irrigation, pest management, and harvest schedules with actual daylight hours at the field level. Solar elevation data helps model crop canopy light interception for growth-stage planning.

Construction and architecture. Model shadow casting and daylight exposure for building design. Solar azimuth at different times of day supports facade orientation, window sizing, and passive solar design.

Photography and outdoor planning. Golden-hour and blue-hour timing tied to the shoot location's exact coordinates. Event planners can use sunset data to schedule lighting transitions.

Logistics and fleet management. Factor daylight availability into route planning and delivery windows. Sunrise and sunset data helps optimize last-mile operations for safety and efficiency.

Get your API key and make your first call

The Astronomy API is live. Get your API key and make your first call right now.

Get your API key

Start with a single coordinate. See the response. Then scale to production.

The sun's position is no longer something your product has to guess at. Now it's a data field.

Ambee provides environmental intelligence APIs covering weather, air quality, pollen, wildfire, natural disaster, and astronomy data for any location on Earth. Teams across energy, pharma, agriculture, insurance, and consumer technology use Ambee's data to build smarter products and make better decisions.

ENVIRONMENTAL DATA
Get pollen, weather, AQ, wildfire & natural disaster data
(150+ countries) (0.5 x 0.5 sq.km)
latest icon
Latest
historical icon
Historical
forecast icon
Forecast
geocoding icon
Geocoding
reverse geocoding icon
Reverse geocoding
GET IN TOUCH
CTA
Related posts
No items found.
Header image
CTA
CTA
Get your exclusive whitepaper
Thank you! Your email has been received.
CTA
Oops! Something went wrong while submitting the form.