The moon phases endpoint is an extension of the sunmoon endpoint and provides easy access to moon phase calendar information, such as the next full, new, and quarter moon phases. This endpoint allows the receipt of up to one month of information per request.
The following actions are supported with the sunmoon/moonphases 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. |
search | The search action is used as a more general query method and expects the query to be defined with the custom query for the request. Unlike the closest action, results will not be returned in any particular order. |
contains | The contains action returns data that a specified location is contained within. This action is normally associated with endpoints that contain polygon data, allowing to return only the polygons a point / geometry is contained in. This action can be considered the opposite of the within endpoint. |
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 |
The following filters can be passed to the filter parameter to reduce the results that are returned:
new | Filter on new moons. |
first | Filter on first quarter moons. |
full | Filter on full moons. |
third | Filter on third-quarter moons. |
Use the following supported property keys when creating custom queries for your requests:
type | Query based on the type of moon phase abbreviated name. |
code | Query based on the numeric representation of the moon phase. |
You can use the following fields to sort data. Review the sorting docs page for more information on the sort functionality.
dt | The date/time of the moon phase. |
code | Sort based on the numeric moon phase code. |
type | Sort based on the moon phase abbreviated name. |
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]
Fetch the next four moon phases, with times in UTC./sunmoon/moonphases?limit=4&
Fetch the next four moon phases, with times localized to Minneapolis, MN./sunmoon/moonphases/minneapolis,mn?limit=4&
Fetch the moon phases for the all of 2012, with times localized to Minneapolis, MN./sunmoon/moonphases/minneapolis,mn?from=2012-01-01&to=2012-12-31&limit=100&
Fetch the next four new moons, with times in UTC./sunmoon/moonphases/search?query=type:new&limit=4&
Fetch the next four new or full moons, with times in UTC./sunmoon/moonphases/search?query=type:new;type:full&limit=4&
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": 1528919104,
"dateTimeISO": "2018-06-13T14:45:04-05:00",
"code": 0,
"name": "new moon"
}]
}
The following properties will be provided in every response object:
Last modified: September 14, 2023