Endpoint: sunmoon/moonphases

The moonphases endpoint is an extension of the sunmoon endpoint and provides easy access to the moon phase calendar information. Such as the next full, new and quarter moon phases. This endpoint allows receiving up to 1 month of information per request.

Supported Actions

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 enpoint'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.

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 form 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=7/10/2011
from=2011/07/10
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=7/10/2011
to=2011/07/10
to=2017-02-27 5:00 PM
callback callback=:functionName Used with JSONP implementation.

Defines the callback function to use for the response. The response will be enclosed as C(response), where C is the callback function provided.

Supported Filters

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.

Supported Query Properties

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.

Sortable Fields

You can use the following fields to sort the data returned in your response:

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.

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]

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&

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.


{
    "success": true,
    "error": null,
    "response": [{
        "timestamp": 1528919104,
        "dateTimeISO": "2018-06-13T14:45:04-05:00",
        "code": 0,
        "name": "new moon"
    }]
}
								

Response Properties

The following properties will be provided in every response object:

timestamp (number) UNIX timestamp of the exact time of the moon phase.
dateTimeISO (string) ISO 8601 date of the exact time of the moon phase.
code (string) Numeric representation of the moon phase:
- 0 = new moon
- 1 = first quarter moon
- 2 = full moon
- 3 = third quarter moon
name (string) The moon phase full name. Possibly phrases include:
- new moon
- first quarter
- full moon
- third quarter