Loading
Loading
Retrieve sunrise and sunset times, the current position of the moon, and other related information by specifying a location address, coordinates, or IP address.
The Astronomy API provides precise astronomical data for any location worldwide. Get accurate sunrise and sunset times, moon phases, twilight periods, golden hour and blue hour schedules, and current sun and moon positions. Supports address lookup, GPS coordinates, IP address geolocation, and custom dates.
Authorize every request with your API key, passed either as a header or as a query parameter:
X-apiKeyapiKeyThis is version 2.0 of the API.
The following parameters can be used in your API requests. All parameters are passed as query string parameters.
formatoptionalStringdefault: jsonResponse format: 'json' (default) or 'xml'.
locationoptionalStringdefault: New York, USExtract astronomy information using location (preferably city)
latoptionalFloatLatitude to extract astronomy information using location coordinates
longoptionalFloatLongitude to extract astronomy information using location coordinates
ipoptionalStringIPv4 or IPv6 address to extract astronomy information using IP address
langoptionalStringdefault: enResponse language of "location" field in case of lookup through IP address only. Possible values are:
dateoptionalStringSpecific date (format YYYY-MM-DD) for which astronomy data is required
elevationoptionalFloatdefault: 0Elevation above sea level at the location, in meters. The value should be between 0 meter and a maximum value of 10,000 meters. Negative value is set to 0.
time_zoneoptionalStringdefault: Time zone to receive all time-based data in your preferred local time.
A successful request returns a 200 OK response with a JSON object containing the astronomy data. The response includes the top-level fields listed below. See the response preview on the right for the full JSON structure.
ipIPv4 or IPv6 address used for the lookup. Returned only when queried using the ip= parameter.
time_zone (String), date (String), current_time (String), mid_night (String), night_end (String), …
location_string (String), continent_code (String), continent_name (String), country_code2 (String), country_code3 (String), …
Besides the response body, every response carries custom headers you can use to track credit usage, and concurrency usage on endpoints that enforce a concurrency limit. See the Custom Response Headers documentation and the endpoints with concurrency limits for more details.
X-Concurrent-Threadsheaderconcurrency-limited endpointsSpecifies the maximum number of concurrent requests allowed.
X-Concurrent-Threads-Activeheaderconcurrency-limited endpointsIndicates the number of active concurrent requests being processed.
X-AF-Credits-Costheaderall responsesSpecifies the number of credits consumed by the current request.
See the HTTP Status Codes documentation for a complete reference of common API errors and HTTP status codes.
Latitude must be between -90 and 90.
'999.999.999.999' is not an IP string literal.
You must provide date in the 'yyyy-MM-dd' format
We couldn't find the location (ZZZNOTEXIST). Try a city or state level location address only.