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
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. |
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. |
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. |
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&
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.
{
"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
}
}
}
}]
}
The following properties will be provided in every response object:
Last modified: August 18, 2022