Endpoint: sunmoon

The sunmoon endpoint provides sunrise/set, twilight, moon rise/set and moon phase information for requested locations and time frames. This endpoint allows receiving up to 1 month of information per request.

https://api.aerisapi.com/sunmoon/

Data CoverageGlobal

Included With API Developer,  API Basic,  API Premium

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 enpoint's detailed documentation for specific information regarding how to use the :id action.

Supported Parameters

The following parameters are options 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.
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.

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

{
   "timestamp":1493322115,
   "dateTimeISO":"2017-04-27T14:41:55-05:00",
   "loc":{
      "lat":44.9778,
      "long":-93.265
   },
   "place":{
      "name":"minneapolis",
      "state":"mn",
      "country":"us"
   },
   "profile":{
      "tz":"America\/Chicago"
   },
   "sun":{
      "rise":1493291184,
      "riseISO":"2017-04-27T06:06:24-05:00",
      "set":1493342079,
      "setISO":"2017-04-27T20:14:39-05:00",
      "transit":1493316631,
      "transitISO":"2017-04-27T13:10:31-05:00",
      "midnightSun":false,
      "polarNight":false,
      "twilight":{
         "civilBegin":1493289267,
         "civilBeginISO":"2017-04-27T05:34:27-05:00",
         "civilEnd":1493343996,
         "civilEndISO":"2017-04-27T20:46:36-05:00",
         "nauticalBegin":1493286893,
         "nauticalBeginISO":"2017-04-27T04:54:53-05:00",
         "nauticalEnd":1493346369,
         "nauticalEndISO":"2017-04-27T21:26:09-05:00",
         "astronomicalBegin":1493284265,
         "astronomicalBeginISO":"2017-04-27T04:11:05-05:00",
         "astronomicalEnd":1493348997,
         "astronomicalEndISO":"2017-04-27T22:09:57-05:00"
      }
   },
   "moon":{
      "rise":1493295480,
      "riseISO":"2017-04-27T07:18:00-05:00",
      "set":1493347800,
      "setISO":"2017-04-27T21:50:00-05:00",
      "transit":1493321340,
      "transitISO":"2017-04-27T14:29:00-05:00",
      "underfoot":1493276400,
      "underfootISO":"2017-04-27T02:00:00-05:00",
      "phase":{
         "phase":0.0516,
         "name":"waxing crescent",
         "illum":3,
         "age":1.52,
         "angle":0.55
      }
   }
}
								

{
   "type":"FeatureCollection",
   "features":[
      {
         "type":"Feature",
         "geometry":{
            "type":"Point",
            "coordinates":[
               -93.265,
               44.9778
            ]
         },
         "properties":{
            "timestamp":1493322486,
            "dateTimeISO":"2017-04-27T14:48:06-05:00",
            "loc":{
               "lat":44.9778,
               "long":-93.265
            },
            "place":{
               "name":"minneapolis",
               "state":"mn",
               "country":"us"
            },
            "profile":{
               "tz":"America\/Chicago"
            },
            "sun":{
               "rise":1493291184,
               "riseISO":"2017-04-27T06:06:24-05:00",
               "set":1493342079,
               "setISO":"2017-04-27T20:14:39-05:00",
               "transit":1493316631,
               "transitISO":"2017-04-27T13:10:31-05:00",
               "midnightSun":false,
               "polarNight":false,
               "twilight":{
                  "civilBegin":1493289267,
                  "civilBeginISO":"2017-04-27T05:34:27-05:00",
                  "civilEnd":1493343996,
                  "civilEndISO":"2017-04-27T20:46:36-05:00",
                  "nauticalBegin":1493286893,
                  "nauticalBeginISO":"2017-04-27T04:54:53-05:00",
                  "nauticalEnd":1493346369,
                  "nauticalEndISO":"2017-04-27T21:26:09-05:00",
                  "astronomicalBegin":1493284265,
                  "astronomicalBeginISO":"2017-04-27T04:11:05-05:00",
                  "astronomicalEnd":1493348997,
                  "astronomicalEndISO":"2017-04-27T22:09:57-05:00"
               }
            },
            "moon":{
               "rise":1493295480,
               "riseISO":"2017-04-27T07:18:00-05:00",
               "set":1493347800,
               "setISO":"2017-04-27T21:50:00-05:00",
               "transit":1493321340,
               "transitISO":"2017-04-27T14:29:00-05:00",
               "underfoot":1493276400,
               "underfootISO":"2017-04-27T02:00:00-05:00",
               "phase":{
                  "phase":0.0518,
                  "name":"waxing crescent",
                  "illum":3,
                  "age":1.53,
                  "angle":0.55
               }
            }
         }
      }
   ]
}
								

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.
moon.riseISO (string) ISO 8601 date of the moon rise. Null if no moon rise.
moon.set (number) UNIX timestamp of the moon set. Null if no moon set.
moon.setISO (string) ISO 8601 date of the moon set. Null if no moon set.
moon.transit (number) UNIX timestamp of the point the moon is "overhead". Null if no transit.
moon.transitISO (string) ISO 8601 date of the point the moon is "overhead". Null if no transit.
moon.underfoot (number) UNIX timestamp of the point the moon is "underfoot". Null if no transit.
moon.underfootISO (string) ISO 8601 date of the point the moon is "underfoot". Null if no transit.
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.