Access sunrise, sunset, and solar position data from Ambee Astronomy

Retrieve local sunrise, sunset, azimuth, and elevation data for any location, ready for fast integration.

Trusted Across Industries
GSK Logo
Bayer Logo
Sanofi Logo
Lilly Logo
HALEON Logo
Kimberly-Clark Logo
3M Logo
Electrolux logo
WPP Logo
Publicis Groupe Logo
Teads logo
The Weather Channel Logo
EDF Logo
At a glance

Ambee Astronomy

Comprehensive astronomy data

Comprehensive astronomy data

Sunrise, sunset, solar azimuth, and solar elevation for any location and hour.

Astronomy global coverage

Global coverage

Available for any latitude and longitude on Earth, with automatic timezone detection.

Astronomy Hyperlocal Granularity

Hyperlocal granularity

Resolve sunrise, sunset, and solar position to exact lat/lng coordinates or a named place, for any point on Earth.

Astronomy local time, ready to use

Local time, ready to use

Sunrise and sunset returned as ISO 8601 timestamps with local timezone offsets applied, no manual conversion needed.

Astronomy gap-free time series

Gap-free time series

Access past, present, and forward-looking astronomy data in a consistent schema.

Astronomy lightweight JSON response

Lightweight JSON response

Six core fields returned in a compact structure, ready to integrate without manual conversion.

Industry leaders use Ambee’s astronomy for

Solar energy and renewables

Use solar azimuth and elevation to support solar panel orientation, generation modeling, and daylight forecasting.

Astronomy data for solar energy and renewables

Smart home and IoT

Trigger lighting, blinds, and automation systems based on actual sunrise and sunset for each user’s location.

Astronomy data for smart homes and IoT

Agriculture and precision farming

Align field operations with real daylight hours and changing seasonal light exposure.

Astronomy data for agriculture and precision farming

Construction and architecture

Model daylight exposure and shadow movement across structures and outdoor spaces.

Astronomy data for construction and architecture

Logistics and fleet operations

Plan routes and outdoor work schedules around changing daylight conditions.

Astronomy data for logistics and fleet operations

Enterprise-grade astronomy data delivered your way

Instantly integrate Ambee astronomy data into any workflow, available in any format

Astronomy API documentation

APIs

Access, present, and forecast endpoints via a RESTful API with response format of JSON or GeoJSON.

Astronomy map tiles

Flat files & bulk data

CSV and parquet formats for analytical workflows and modeling pipelines.

Getting started with Ambee’s Astronomy API

Content copy iconCheck icon
const http = require("https");

const options = {
	"method": "GET",
	"hostname": "api.ambeedata.com",
	"port": null,
	"path": "/astronomical/solar-parameters/latest?lat=37.78229&lng=-122.39117",
	"headers": {
		"x-api-key": "API_KEY",
		"Content-type": "application/json"
	}
};

const req = http.request(options, function (res) {
	const chunks = [];

	res.on("data", function (chunk) {
		chunks.push(chunk);
	});

	res.on("end", function () {
		const body = Buffer.concat(chunks);
		console.log(body.toString());
	});
});

req.end();
Content copy iconCheck icon
const http = require('https');

const options = {
	method: 'GET',
	hostname: 'api.ambeedata.com',
	port: null,
	path: '/astronomical/solar-parameters/latest?lat=37.78229&lng=-122.39117',
	headers: {
		'x-api-key': 'API_KEY',
		'Content-type': 'application/json'
	}
};

const req = http.request(options, function (res) {
	const chunks = [];

	res.on('data', function (chunk) {
		chunks.push(chunk);
	});

	res.on('end', function () {
		const body = Buffer.concat(chunks);
		console.log(body.toString());
	});
});

req.end();
Content copy iconCheck icon
OkHttpClient client = new OkHttpClient();

Request request = new Request.Builder()
	.url("/astronomical/solar-parameters/latest?lat=37.78229&lng=-122.39117")
	.get()
	.addHeader("x-api-key", "API_KEY")
	.addHeader("Content-type", "application/json")
	.build();

Response response = client.newCall(request).execute();
Content copy iconCheck icon
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
	Method = HttpMethod.Get,
	RequestUri = new Uri("https://api.ambeedata.com/astronomical/solar-parameters/latest?lat=37.78229&lng=-122.39117"),
	Headers =
	{
		{ "x-api-key", "API_KEY" },
	},
};
using (var response = await client.SendAsync(request))
{
	response.EnsureSuccessStatusCode();
	var body = await response.Content.ReadAsStringAsync();
	Console.WriteLine(body);
}
Content copy iconCheck icon
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "https://api.ambeedata.com/astronomical/solar-parameters/latest?lat=37.78229&lng=-122.39117"

	req, _ := http.NewRequest("GET", url, nil)

	req.Header.Add("x-api-key", "API_KEY")
	req.Header.Add("Content-type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
Content copy iconCheck icon
<?php

$curl = curl_init();

curl_setopt_array($curl, [
	CURLOPT_URL => "https://api.ambeedata.com/astronomical/solar-parameters/latest?lat=37.78229&lng=-122.39117",
	CURLOPT_RETURNTRANSFER => true,
	CURLOPT_ENCODING => "",
	CURLOPT_MAXREDIRS => 10,
	CURLOPT_TIMEOUT => 30,
	CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
	CURLOPT_CUSTOMREQUEST => "GET",
	CURLOPT_HTTPHEADER => [
		"Content-type: application/json",
		"x-api-key: API_KEY"
	],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
	echo "cURL Error #:" . $err;
} else {
	echo $response;
}
Content copy iconCheck icon
curl --request GET \
	--url 'https://api.ambeedata.com/astronomical/solar-parameters/latest?lat=37.78229&lng=-122.39117' \
	--header 'Content-type: application/json' \
	--header 'x-api-key: API_KEY'
Content copy iconCheck icon
require 'uri'
require 'net/http'

url = URI("https://api.ambeedata.com/astronomical/solar-parameters/latest?lat=37.78229&lng=-122.3911789055&lng=77.574044")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)
request["x-api-key"] = 'API_KEY'
request["Content-type"] = 'application/json'

response = http.request(request)
puts response.read_body
Content copy iconCheck icon
import http.client

conn = http.client.HTTPSConnection("api.ambeedata.com")

headers = {
    'x-api-key': "API_KEY",
    'Content-type': "application/json"
}

conn.request("GET", "/astronomical/lunar-parameters/latest?lat=37.78229&lng=-122.39117", headers=headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
Content copy iconCheck icon
const http = require('https');

const options = {
	method: 'GET',
	hostname: 'api.ambeedata.com',
	port: null,
	path: '/astronomical/lunar-parameters/latest?lat=37.78229&lng=-122.39117',
	headers: {
		'x-api-key': 'API_KEY',
		'Content-type': 'application/json'
	}
};

const req = http.request(options, function (res) {
	const chunks = [];

	res.on('data', function (chunk) {
		chunks.push(chunk);
	});

	res.on('end', function () {
		const body = Buffer.concat(chunks);
		console.log(body.toString());
	});
});

req.end();
Content copy iconCheck icon
OkHttpClient client = new OkHttpClient();

Request request = new Request.Builder()
	.url("https://api.ambeedata.com/astronomical/lunar-parameters/latest?lat=37.78229&lng=-122.39117")
	.get()
	.addHeader("x-api-key", "API_KEY")
	.addHeader("Content-type", "application/json")
	.build();

Response response = client.newCall(request).execute();
Content copy iconCheck icon
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
	Method = HttpMethod.Get,
	RequestUri = new Uri("https://api.ambeedata.com/astronomical/lunar-parameters/latest?lat=37.78229&lng=-122.39117"),
	Headers =
	{
		{ "x-api-key", "API_KEY" },
	},
};
using (var response = await client.SendAsync(request))
{
	response.EnsureSuccessStatusCode();
	var body = await response.Content.ReadAsStringAsync();
	Console.WriteLine(body);
}
Content copy iconCheck icon
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "https://api.ambeedata.com/astronomical/lunar-parameters/latest?lat=37.78229&lng=-122.39117"

	req, _ := http.NewRequest("GET", url, nil)

	req.Header.Add("x-api-key", "API_KEY")
	req.Header.Add("Content-type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
Content copy iconCheck icon
<?php

$curl = curl_init();

curl_setopt_array($curl, [
	CURLOPT_URL => "https://api.ambeedata.com/astronomical/lunar-parameters/latest?lat=37.78229&lng=-122.39117",
	CURLOPT_RETURNTRANSFER => true,
	CURLOPT_ENCODING => "",
	CURLOPT_MAXREDIRS => 10,
	CURLOPT_TIMEOUT => 30,
	CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
	CURLOPT_CUSTOMREQUEST => "GET",
	CURLOPT_HTTPHEADER => [
		"Content-type: application/json",
		"x-api-key: API_KEY"
	],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
	echo "cURL Error #:" . $err;
} else {
	echo $response;
}
Content copy iconCheck icon
curl --request GET \
	--url 'https://api.ambeedata.com/astronomical/lunar-parameters/latest?lat=37.78229&lng=-122.39117' \
	--header 'Content-type: application/json' \
	--header 'x-api-key: API_KEY'
Content copy iconCheck icon
require 'uri'
require 'net/http'

url = URI("https://api.ambeedata.com/astronomical/lunar-parameters/latest?lat=37.78229&lng=-122.39117")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)
request["x-api-key"] = 'API_KEY'
request["Content-type"] = 'application/json'

response = http.request(request)
puts response.read_body
Content copy iconCheck icon
{
    "message": "success",
    "data": [
        {
            "lat": 37.75,
            "lng": -122.4,
            "timezone": "America/Los_Angeles",
            "timestamp": "2026-06-05T05:00:00.000Z",
            "solar_azimuth": 315.56,
            "solar_elevation": -15.41,
            "sunrise": "2026-06-05T05:48:09-07:00",
            "sunset": "2026-06-05T20:27:11-07:00"
        }
    ]
}
Content copy iconCheck icon
{
    "message": "success",
    "data": [
        {
            "lat": 37.75,
            "lng": -122.4,
            "timezone": "America/Los_Angeles",
            "timestamp": "2026-06-05T00:00:00.000Z",
            "moonrise": "2026-06-05T00:07:36-07:00",
            "moonset": "2026-06-05T10:21:03-07:00",
            "moon_illumination": 75.97,
            "moon_phase": "Waning Gibbous"
        }
    ]
}
01

Get your API key

Sign up for an Ambee account and generate your API key from the dashboard.

02

Choose your endpoint

Select the endpoint based on what you need: present conditions, historical data, or forecasts

03

Add your location

Specify the location using latitude and longitude coordinates, ZIP codes, or custom boundaries.

04

Make your request

Include your API key in the request header. Receive a structured JSON response.

Insights

Stay informed with research, case studies, and product deep-dives on astronomy.

BLOG

Ambee launches Astronomy API for sun and daylight intelligence

Ambee Astronomy API launch

Enhance your project with more from Ambee’s Climate Data Suite

Pollen

30+ pollen allergens categorized into trees, grasses, and weeds

Pollen API

Weather

All core meteorological and atmospheric parameters, including many derived fields

Ambee Weather API

Air Quality

Track all major pollutants and AQI, anywhere and anytime in the world

Ambee Air Quality API

Influenza-like Illness

30-day risk forecasts for respiratory illness, including cold and cough

Ambee ILI API

Natural disasters

All major disasters in a geospatial format with severity levels and event metadata

Ambee natural disaster API

Wildfire

Wildfire activity and behavior with forward-looking risk forecasts

Ambee Wildfire API

Why leading teams build with Ambee

Real feedback from real innovators

Innovid Testimonial
Delivering personalized, relevant experiences is critical for advertisers trying to increase the performance of their messaging. The beauty of DCO is when you have a high-quality API like Ambee’s pollen count - you can turn that into creative experiences directly tuned to the real-world circumstances of your audience.
Simeon Powers
Product Marketing, Ad Management, Innovid
navia life care testimonial
We tried out Ambee’s Weather and Pollen API for our healthcare app. I must say our users were certainly pleased with the results. The data was comprehensive, accurate, and valuable, which helped with the user's decision-making process. Ambee’s team was really supportive during integration and for regular maintenance as well. Would definitely recommend working with them.
Kunal Kishore Dhawan
Co-founder and CEO of Navia Life Care
WPP Testimonial
In an ever-changing world, it’s imperative that we understand the environmental changes and act upon these in the right way. Ambee keeps us in tune with our environment and is key to creating better outcomes for people.
Vipul Parmar
Global Head of Data Management
VitalFlo Testimonial
We monitor the impacts of AQ on the health outcomes of asthma and COPD patients. Ambee gives great access to hyperlocal data to help us monitor acute respiratory health events.
Luke Marshall
CEO and Founder of VitalFlo
ADYLIC Testimonial
It has helped Adylic showcase the power of utilizing API in personalizing ads. In this case, we were able to target users' needs at the right time based on the user's location.
Stefanie Wong
DCO Specialist, Adylic
Razor Testimonial
Solving climate change requires collaboration across industries. Hence, Razor partnered with Ambee to make reliable, real-time, and accurate data available to the blockchain.
Hrishikesh Huilgolkar
CEO
NASA Testimonial
The PACE Science and Applications Team is thrilled to be working with partners like Ambee, who bring a fresh perspective to our work and ensure that the PACE mission will provide societal benefit.
Lorraine Remer
Atmospheric Scientist, University of Maryland, Baltimore County
Allegra Testimonial
Ambee has been a tremendous partner for Allegra. The quality of their air quality data, combined with their end-to-end development solutions and customer-oriented mindset, has made them the right partner for us.
Jordana Barish
North America Zone Head for Allegra
Datarade Testimonial
We’re happy to have Ambee’s AI-ready datasets listed on Datarade…Ambee is meeting increased global demand for environmental intelligence with its suite of data products. Now that these data products are available on Datarade, organizations worldwide will be able to access, sample, and ingest them for a range of crucial use cases.
Richard Hoffmann
Co-founder of Datarade
Seek Testimonial
Ambee's proprietary climate data, brought to life through apps on Insight Cloud, makes forecasting faster, smarter, and simpler than ever. Teams can now instantly access Ambee's world-class climate expertise in minutes on Insight Cloud...answering tomorrow's questions, today.
Erik Mitchell
CEO of Seek

Frequently asked questions

Common questions about Ambee's astronomy data

  • What is an astronomy API?

    An astronomy API is a programmatic interface that returns solar event data, such as sunrise and sunset times, and solar position data, such as azimuth and elevation, for any geographic coordinate. Developers use astronomy APIs to power solar energy systems, smart lighting, agricultural planning tools, and photography apps.

  • What data does Ambee's astronomy API return?

    The API returns eight fields: latitude, longitude, IANA timezone, UTC timestamp, solar azimuth (the sun's compass direction in degrees), solar elevation (the sun's angle above the horizon in degrees), sunrise time, and sunset time. Sunrise and sunset are returned in the location's local timezone with offset.

  • Does the API return sunrise and sunset in local time or UTC?

    Local time. Sunrise and sunset are returned as ISO 8601 timestamps with the location's timezone offset (e.g., +05:30 for India Standard Time). Most competing astronomy APIs return UTC by default, which shifts conversion effort to the developer. Ambee handles that for you.

  • Does the API account for atmospheric refraction?

    Yes. Sunrise and sunset calculations include standard atmospheric refraction corrections (accounting for solar radius and refraction effects) so that the returned times reflect the sun's apparent position on the horizon, not just its geometric position. Under standard atmospheric conditions, rise and set times are accurate to within 1-2 minutes.

  • What is solar azimuth?

    Solar azimuth is the sun's compass direction, measured in degrees clockwise from true north. 0° is north, 90° is east, 180° is south, and 270° is west. This tells you which direction the sun is shining from at a given location and time. It is the standard reference used in solar tracking systems, building design, and navigation.

  • What is solar elevation?

    Solar elevation is the sun's angle above the horizon, measured in degrees. A value of 0° means the sun is on the horizon (sunrise or sunset). 90° means directly overhead. Negative values mean the sun is below the horizon. This is critical for solar energy yield calculations, shadow analysis, and daylight modeling.

  • Does the API support global coverage?

    Yes. The API returns data for any latitude-longitude pair on Earth. No regional restrictions. No coverage gaps. The timezone is auto-detected from the coordinates you provide.

  • Is there a free tier?

    Yes. Sign up for Ambee's API dashboard to get a free evaluation trial: 100 API records per day for 15 days. No credit card required.

  • Can I combine astronomy data with other Ambee APIs?

    Yes. Ambee offers weather, air quality, pollen, wildfire, natural disaster, and ILI (influenza-like illness) APIs. Combine sunrise and sunset data with weather forecasts for solar irradiance modeling. Pair solar position with air quality data for UV exposure estimates. All through a single API key.

  • How is Ambee's astronomy API different from other sunrise/sunset APIs?

    Three things set it apart. First, it returns solar azimuth and solar elevation alongside sunrise and sunset, not just event times. Second, it is part of Ambee's broader environmental intelligence platform, so you can layer in weather, AQ, and pollen data without managing separate providers. Third, every response is timezone-aware with local timestamps and refraction-corrected timing out of the box.

  • What format does the API response use?

    JSON. Timestamps use ISO 8601 format. Sunrise and sunset include the local timezone offset. Solar azimuth and elevation are returned as floating-point degree values.

  • How do I authenticate?

    Pass your API key in the x-api-key request header. This is consistent across all Ambee APIs. Generate your key from the API dashboard after signing up.

Turn climate from a risk to an opportunity