# Node for datetime of next full moon and next new moon

**URL:** https://discourse.nodered.org/t/node-for-datetime-of-next-full-moon-and-next-new-moon/77988
**Category:** General
**Created:** [27 April 2023 18:12 UTC](https://discourse.nodered.org/t/node-for-datetime-of-next-full-moon-and-next-new-moon/77988 "2023-04-27T18:12:06Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Jpsy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jpsy/32/22707_2.png) [@Jpsy](https://discourse.nodered.org/u/Jpsy)
#### Post date: [27 April 2023 18:12 UTC](https://discourse.nodered.org/t/node-for-datetime-of-next-full-moon-and-next-new-moon/77988/1 "2023-04-27T18:12:06Z")

</div>

I find many nodes for calculating the current moon phase, but none that gives me the date and time of the next full moon / new moon at a given geo location.

---

<div class="post-metadata">

### Author: ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)
#### Post date: [27 April 2023 18:41 UTC](https://discourse.nodered.org/t/node-for-datetime-of-next-full-moon-and-next-new-moon/77988/2 "2023-04-27T18:41:41Z")

</div>

I know nothing about astronomy (but I do like Space & the film interstellar 😀)

This type of data, is usually harvested from API's.

A quick search yields

> **[Moon Parameters | Meteomatics](https://www.meteomatics.com/en/api/available-parameters/moon/)**
>
> Meteomatics' API gives you access to moon data, such as moon phases, moon age, moon light, moonrise and moonset time, and moon visible area. Click to learn more.

it shouldn't be too difficult to create a set of nodes to grab the data using the `HTTP Request` Node.

not sure if these are paid access services

---

<div class="post-metadata">

### Author: ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)
#### Post date: [27 April 2023 20:01 UTC](https://discourse.nodered.org/t/node-for-datetime-of-next-full-moon-and-next-new-moon/77988/3 "2023-04-27T20:01:06Z")

</div>

Maybe raise a request against this node to see if redmatic would be interested in adding that.

[rdmtc/node-red-contrib-sun-position: This is a ultimate Node-Red Timer, Sun, Moon and Blind flow control. (github.com)](https://github.com/rdmtc/node-red-contrib-sun-position)

---

<div class="post-metadata">

### Author: ![Jpsy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jpsy/32/22707_2.png) [@Jpsy](https://discourse.nodered.org/u/Jpsy)
#### Post date: [28 April 2023 11:26 UTC](https://discourse.nodered.org/t/node-for-datetime-of-next-full-moon-and-next-new-moon/77988/4 "2023-04-28T11:26:19Z")

</div>

Thanks!  
Meteomatics would require a payed subscription. So I will use the following API which is free and also provides the required data: [https://aa.usno.navy.mil/data/MoonPhases](https://aa.usno.navy.mil/data/MoonPhases)

---

<div class="post-metadata">

### Author: ![Jpsy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jpsy/32/22707_2.png) [@Jpsy](https://discourse.nodered.org/u/Jpsy)
#### Post date: [29 April 2023 10:08 UTC](https://discourse.nodered.org/t/node-for-datetime-of-next-full-moon-and-next-new-moon/77988/5 "2023-04-29T10:08:33Z")

</div>

Here is a solution, using the free API that I mentioned above:

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/1/41a9d2ad04509dc91a18bd75e5f590d1115940e9.png)

```auto
[{"id":"b65bc852501c5f8b","type":"function","z":"4c71f9ee.cbd868","name":"Prep request: GET Data","func":"// API explanation:\n// https://aa.usno.navy.mil/data/api#phase\n// Example:\n// https://aa.usno.navy.mil/api/moon/phases/date?date=2009-5-3&nump=48\n\nlet queryDate = msg.date_reverse_dashed; //i.e. \"2023-04-28\"\nlet queryPhaseCnt = 4;\n\nmsg.url = `https://aa.usno.navy.mil/api/moon/phases/date?date=${queryDate}&nump=${queryPhaseCnt}`;\nmsg.method= \"GET\";\n//msg.headers = \"\";\n//msg.cookies= \"\";\n//msg.payload = JSON.stringify(PAYLOAD)\n\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":330,"y":540,"wires":[["c47e893aeb2067ba"]]},{"id":"7f47d0f3f5beb406","type":"switch","z":"4c71f9ee.cbd868","name":"HTTP 200 ?","property":"statusCode","propertyType":"msg","rules":[{"t":"eq","v":"200","vt":"num"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":730,"y":540,"wires":[["6b53804451d09627"],["1926d588ad59e459"]]},{"id":"c47e893aeb2067ba","type":"http request","z":"4c71f9ee.cbd868","name":"","method":"use","ret":"obj","paytoqs":"ignore","url":"","tls":"7b79ba19.4d8194","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"credentials":{},"x":550,"y":540,"wires":[["7f47d0f3f5beb406"]]},{"id":"7b79ba19.4d8194","type":"tls-config","name":"Ignore Invalid Cert","cert":"","key":"","ca":"","certname":"","keyname":"","caname":"","servername":"","verifyservercert":false}]

```

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [28 June 2023 10:09 UTC](https://discourse.nodered.org/t/node-for-datetime-of-next-full-moon-and-next-new-moon/77988/6 "2023-06-28T10:09:01Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
