Endpoint: sunmoon

The sunmoon endpoint provides sunrise/set, twilight, moon rise/set, and moon phase information for requested locations and timeframes. This endpoint allows the receipt of up to one month of information per request.

Helpful Hints: The moon details in this endpoint are an approximation based on calculated illumination. For the exact time in which each major moon phase occurs (first quarter, full, last quarter, new) please visit the sunmoon/moonphases endpoint.

Use our wizard to try out this endpoint

Supported Actions

The following actions are supported with the sunmoon endpoint:

:id Requesting data by using the :id action is used for returning data for a particular item that has an ID associated with it. This is the primary method for requesting general weather information for a single location (observations, forecasts, advisories, etc.) as the location's name or a zip code serves as the id. Other endpoints may expect a certain value for the ID, such as storm cells whose ID value is a combination of the radar site identifier and unique identifier assigned to every storm cell. Refer to an endpoint's detailed documentation for specific information regarding how to use the :id action.

Supported Parameters

The following parameters are optional unless otherwise noted:

p p=:place Defines the location to query data for. Refer to the list of supported place value formats.
limit limit=:total The total number of results to return as an integer. Each endpoint may have a set maximum for this value depending on usage.

The default limit is 1 if not specified. The maximum limit for this endpoint is 31.
filter filter=:string Predefined filters for limiting the results. The filter value can be a single, comma-delimited or a semicolon delimited string of filter names.
from from=:string Returns the results starting from the value specified. For best practices we recommend using the to parameter as well to define a specific time frame.

Supports a UNIX timestamp or a specific date string. Alternatively, common date formats supported by the PHP strtotime() function will be accepted; however, commas are not accepted.

Examples:
from=tomorrow
from=friday
from=1302883980
from=MM/DD/YYYY
from=YYYY/MM/DD
from=+2hours
from=2017-02-27 5:00 PM

to to=:string Returns the results between now and the value specified. For best practices we recommend using the from parameter as well to define a specific time frame. When used in conjunction with the from parameter, the value of to will be relative to the value of from, not relative to the current time.

Supports a UNIX timestamp or a specific date string. Alternatively, common date formats supported by the PHP strtotime() function will be accepted; however, commas are not accepted.

Examples:
to=+6hours
to=+5days
to=1302883980
to=MM/DD/YYYY
to=YYYY/MM/DD
to=2017-02-27 5:00 PM

fields fields=:string Provides a comma separated list of values for the API to return. This parameter is often used to limit the amount of data returned. See Reducing Output.
skip skip=:number Used to skip over a specific number of results in the data set.
sort sort=:string Used to sort results based on certain fields in the data set. See Sorting for more details.

Supported Filters

The following filters can be passed to the filter parameter to reduce the results that are returned:

sun Provides sunrise/sunset information.
twilight Provides sun and twilight information.
moon Provides moonrise/moonset information.
moonphase Provides moon phase information for a specific time.

Examples

The /[:endpoint]/[:action]? portion within the query template below can be exchanged with any of the examples. Also, please note you will need to input your client credentials in the [ID] and [SECRET] fields which can be found under the Apps section of the members area.

https://api.aerisapi.com/[:endpoint]/[:action]?client_id=[ID]&client_secret=[SECRET]

Obtain the sun/moon information for today for Minneapolis, MN.
/sunmoon/minneapolis,mn?

Obtain the next weeks information for Minneapolis, MN.
/sunmoon/minneapolis,mn?from=now&to=+1week&limit=7&

Obtain the sun/moon information for Minneapolis, MN for the month of January, 2012.
/sunmoon/minneapolis,mn?from=2012-01-01&to=2012-01-31&limit=31&

Obtain only the sunrise/set and moon rise/set information for New York. Excludes the twilight and moon phase information.
/sunmoon/10001?filter=sun,moon&

Response

The following is an example of what each object in the response will consist of. Depending on your requested action, the response may contain multiple instances of this object within an array.

Default
GeoJSON

{
    "success": true,
    "error": null,
    "response": [{
        "timestamp": 1528310856,
        "dateTimeISO": "2018-06-06T21:47:36+03:00",
        "loc": {
            "lat": 2.03711,
            "long": 45.34375
        },
        "place": {
            "name": "mogadishu",
            "state": "",
            "country": "so"
        },
        "profile": {
            "tz": "Africa\/Mogadishu"
        },
        "sun": {
            "rise": 1528253416,
            "riseISO": "2018-06-06T05:50:16+03:00",
            "set": 1528297466,
            "setISO": "2018-06-06T18:04:26+03:00",
            "transit": 1528275441,
            "transitISO": "2018-06-06T11:57:21+03:00",
            "midnightSun": false,
            "polarNight": false,
            "twilight": {
                "civilBegin": 1528252072,
                "civilBeginISO": "2018-06-06T05:27:52+03:00",
                "civilEnd": 1528298809,
                "civilEndISO": "2018-06-06T18:26:49+03:00",
                "nauticalBegin": 1528250503,
                "nauticalBeginISO": "2018-06-06T05:01:43+03:00",
                "nauticalEnd": 1528300379,
                "nauticalEndISO": "2018-06-06T18:52:59+03:00",
                "astronomicalBegin": 1528248923,
                "astronomicalBeginISO": "2018-06-06T04:35:23+03:00",
                "astronomicalEnd": 1528301959,
                "astronomicalEndISO": "2018-06-06T19:19:19+03:00"
            }
        },
        "moon": {
            "riseISO": null,
            "rise": null,
            "set": 1528275120,
            "setISO": "2018-06-06T11:52:00+03:00",
            "transit": 1528252980,
            "transitISO": "2018-06-06T05:43:00+03:00",
            "underfoot": 1528297500,
            "underfootISO": "2018-06-06T18:05:00+03:00",
            "phase": {
                "phase": 0.7506,
                "name": "last quarter",
                "illum": 50,
                "age": 22.17,
                "angle": 0.5
            }
        }
    }]
}
								

{
    "type": "FeatureCollection",
    "features": [{
        "type": "Feature",
        "geometry": {
            "type": "Point",
            "coordinates": [45.34375, 2.03711]
        },
        "properties": {
            "timestamp": 1528310894,
            "dateTimeISO": "2018-06-06T21:48:14+03:00",
            "loc": {
                "lat": 2.03711,
                "long": 45.34375
            },
            "place": {
                "name": "mogadishu",
                "state": "",
                "country": "so"
            },
            "profile": {
                "tz": "Africa\/Mogadishu"
            },
            "sun": {
                "rise": 1528253416,
                "riseISO": "2018-06-06T05:50:16+03:00",
                "set": 1528297466,
                "setISO": "2018-06-06T18:04:26+03:00",
                "transit": 1528275441,
                "transitISO": "2018-06-06T11:57:21+03:00",
                "midnightSun": false,
                "polarNight": false,
                "twilight": {
                    "civilBegin": 1528252072,
                    "civilBeginISO": "2018-06-06T05:27:52+03:00",
                    "civilEnd": 1528298809,
                    "civilEndISO": "2018-06-06T18:26:49+03:00",
                    "nauticalBegin": 1528250503,
                    "nauticalBeginISO": "2018-06-06T05:01:43+03:00",
                    "nauticalEnd": 1528300379,
                    "nauticalEndISO": "2018-06-06T18:52:59+03:00",
                    "astronomicalBegin": 1528248923,
                    "astronomicalBeginISO": "2018-06-06T04:35:23+03:00",
                    "astronomicalEnd": 1528301959,
                    "astronomicalEndISO": "2018-06-06T19:19:19+03:00"
                }
            },
            "moon": {
                "riseISO": null,
                "rise": null,
                "set": 1528275120,
                "setISO": "2018-06-06T11:52:00+03:00",
                "transit": 1528252980,
                "transitISO": "2018-06-06T05:43:00+03:00",
                "underfoot": 1528297500,
                "underfootISO": "2018-06-06T18:05:00+03:00",
                "phase": {
                    "phase": 0.7506,
                    "name": "last quarter",
                    "illum": 50,
                    "age": 22.17,
                    "angle": 0.5
                }
            }
        }
    }]
}
								

Response Properties

The following properties will be provided in every response object:

timestamp (number) UNIX timestamp of the time used for calculating info.
dateTimeISO (string) ISO 8601 date of the time used for calculating info.
sun.rise (number) UNIX timestamp of the sunrise. Null if no sunrise.
sun.riseISO (string) ISO 8601 date of the sunrise. Null if no sunrise.
sun.set (number) UNIX timestamp of the sunset. Null if no sunset.
sun.setISO (string) ISO 8601 date of the sunset. Null if no sunset.
sun.transit (number) UNIX timestamp of the point the sun is "overhead". Null if no transit.
sun.transitISO (string) ISO 8601 date of the point the moon is "overhead". Null if no transit.
sun.midnightSun (boolean) Set to true if midnight sun (sun not setting), false otherwise
sun.polarNight (boolean) Set to true if polar night (the sun is not rising), false otherwise
sun.twilight.civilBegin (number) UNIX timestamp of the first civil twilight. Null if no civil twilight.
sun.twilight.civilBeginISO (string) ISO 8601 date of first civil twilight. Null if no civil twilight.
sun.twilight.civilEnd (number) UNIX timestamp of the second civil twilight. Null if no civil twilight.
sun.twilight.civilEndISO (string) ISO 8601 date of second civil twilight. Null if no civil twilight.
sun.twilight.nauticalBegin (number) UNIX timestamp of the first nautical twilight. Null if no nautical twilight.
sun.twilight.nauticalBeginISO (string) ISO 8601 date of first nautical twilight. Null if no nautical twilight.
sun.twilight.nauticalEnd (number) UNIX timestamp of the second nautical twilight. Null if no nautical twilight.
sun.twilight.nauticalEndISO (string) ISO 8601 date of second nautical twilight. Null if no nautical twilight.
sun.twilight.astronomicalBegin (number) UNIX timestamp of the first astronomical twilight. Null if no astronomical twilight.
sun.twilight.astronomicalBeginISO (string) ISO 8601 date of first astronomical twilight. Null if no astronomical twilight.
sun.twilight.astronomicalEnd (number) UNIX timestamp of the second astronomical twilight. Null if no astronomical twilight.
sun.twilight.astronomicalEndISO (string) ISO 8601 date of second astronomical twilight. Null if no astronomical twilight.
moon.rise (number) UNIX timestamp of the moon rise. Null if no moon rise, maybe occurring shortly after midnight the next morning.
moon.riseISO (string) ISO 8601 date of the moon rise. Null if no moon rise, possibly occurring shortly after midnight the next morning.
moon.set (number) UNIX timestamp of the moon set. Null if no moon set, possibly occurring shortly after midnight the next morning.
moon.setISO (string) ISO 8601 date of the moon set. Null if no moon set, possibly occurring shortly after midnight the next morning.
moon.transit (number) UNIX timestamp of the point the moon is "overhead". Null if no transit, possibly occurring shortly after midnight the next morning.
moon.transitISO (string) ISO 8601 date of the point the moon is "overhead". Null if no transit, possibly occurring shortly after midnight the next morning.
moon.underfoot (number) UNIX timestamp of the point the moon is "underfoot". Null if no underfoot, possibly occurring shortly after midnight the next morning.
moon.underfootISO (string) ISO 8601 date of the point the moon is "underfoot". Null if no underfoot, possibly occurring shortly after midnight the next morning.
moon.phase.phase (number) The moon phase percentage.
moon.phase.name (string) The moon phase name.
moon.phase.illum (number) The percentage of the moon that is illuminated.
moon.phase.age (number) The age of the moon phase in days.
moon.phase.angle (number) The moon phase angle.
loc.long (number) The longitude coordinate of the record.
loc.lat (number) The latitude coordinate of the record.
place.name (string) The place or nearest place to the record.
place.state (string) The state abbreviation in which the record is located. This may be null depending on the country.
place.country (string) The country abbreviation in which the record is located.
profile.tz (string) The timezone name association with the record's location.

Last modified: August 18, 2022