Rocket Launch Notifications via API


#1

1) Give a description of the problem
I would like to make a call to https://fdo.rocketlaunch.live/json/launches/next/5 and retrieve only rocket launches that will be taking off from FL trigger a notification. Need help reading the response from the GET call and storing the variables.

**2) What is the expected behaviour
When a launch is scheduled and I would like it to notify me the day before and the day of.

3) What is happening/not happening?
need help figuring out how to parse the response for Florida specific launches to capture the dates/times for the notification.

**4) Post a Green Snapshot of the piston![image|45x37]


When & where is the next rocket launch worldwide?
#2

I am a bit tied up at the moment, but depending on the schedule, FL might be found in some of these 5 dataPoints:

$response.result[0].pad.location.state = null
$response.result[1].pad.location.state = null
$response.result[2].pad.location.state = “FL”
$response.result[3].pad.location.state = “CA”
$response.result[4].pad.location.state = null


In this example, if we look at #2:
$response.result[2].win_open
we’ll get a result of:
"2020-05-27T20:32Z"

(I am guessing that “win_open” is the earliest they are allowed to launch)


#3

WCmore, Thanks for looking at this! You are correct the “win_open” is defined as…win_open, The date and time of the opening of the launch window in ISO 8601 format.

So do I write these as response expressions or how do I set these variables in the piston? Forgive me as I am very new to working with API calls and responses.

Thanks!


#4

I would pull the data first and assign to variables. Then loop through the list of states looking for FL then matching that to its date. Something like this


You’ll notice some oddities like the replace function, I had to clear some extra brackets and spaces.

Next step is to process the notification.


#5

As an alternative, I took a cut at using the expressions @WCmore provided and it seems to work simply except WebCoRE is not converting the string date properly to an actual date for comparison with $now.

provides the following log:

5/20/2020, 8:19:41 AM +690ms
+1488ms â•‘Next launch window from Florida opens at 2020-05-27T20:32Z which is Wed, May 20 2020 @ 8:32:00 PM PDT
+1503ms â•‘Next launch is in 12 hours, 12 minutes, and 16 seconds

You can see it is not converting the date from Zulu to PDT but just using today at the given time. Not sure what is going wrong. Can look at it again later.


#6

I started to suggest something similar but there is a part of my brain that prefers to see the steps, data first then process :slight_smile:

I’ve always had issues with dateTime when converting from ISO 8601


#7

Thank you all for your suggestions and input here. I am unable to get back to work through this at the moment but will give it a go tonight when not working.


#8

I forgot I had solved this problem before here.

Here is working piston that should give you a good head start:

Which give the following log:

5/20/2020, 3:37:35 PM +60ms
+1659ms	â•‘next launch is at 2020-05-27T20:32Z which is Wed, May 27 2020 @ 1:32:00 PM PDT
+1677ms	â•‘Next launch is in 6d 21:54:23

EDIT: Note you will have to edit the timezoneOffset for your timezone.


#9

Nice

For the time offset, I’ve been using integer(($localNow-$utc)/1000) = seconds offset; so that it inherently adjusts for DST. You’d have to covert to hours or adjust your formula to use addSeconds instead of addHours


#10

That’s great! I’ve been wondering if there was a way to calculate the offset. This is very helpful. Thanks!

EDIT: I looked at the values. $utc is my local time but $localNow does not correspond to either my time or GMT. I am curious how it is defined. Glad it works, though. Really wish there was a reference listing the definition for all the system variables in WebCoRE.


#11

I should have mentioned the reverse logic. For me, $localNow = GMT and $utc = current local time, which is why the math works but the variable naming doesn’t make sense. Replacing $utc with $now also gives the same result.


#12

adding this myself, very cool!


#13

It’s very strange. I see $utc=$now but where my timezone is GMT-7, $localNow=$now-7 so it is offset the opposite direction from GMT. That’s why I said it doesn’t make sense. But it works so I’m not complaining. :smile:


#14

Anyone figured out what other info can be derived from the API? Maybe a piston that calls on that API and kicks back all the data available? Maybe it can provide more detailed info


#15
VALID (RFC 8259)
Formatted JSON Data
{
   "valid_auth":false,
   "count":5,
   "limit":5,
   "total":162,
   "last_page":33,
   "result":[
      {
         "id":148,
         "cospar_id":"",
         "sort_date":"1590339600",
         "name":"LauncherOne Flight 1",
         "provider":{
            "id":34,
            "name":"Virgin Orbit",
            "slug":"virgin-orbit"
         },
         "vehicle":{
            "id":25,
            "name":"LauncherOne",
            "company_id":34,
            "slug":"launcherone"
         },
         "pad":{
            "id":87,
            "name":"Cosmic Girl, 747-400 - Runway 12\/30",
            "location":{
               "id":83,
               "name":"Mojave Air and Space Port",
               "state":"CA",
               "statename":"California",
               "country":"United States",
               "slug":"mojave-air-and-space"
            }
         },
         "missions":[
            {
               "id":143,
               "name":"LauncherOne Flight 1",
               "description":"Under development by Virgin Orbit since 2007, LauncherOne is an air launched rocket for small satellite payloads."
            }
         ],
         "mission_description":"Under development by Virgin Orbit since 2007, LauncherOne is an air launched rocket for small satellite payloads.",
         "launch_description":"A Virgin Orbit LauncherOne rocket will launch the LauncherOne Flight 1 mission on Sunday, May 24, 2020 at 5:00 PM (UTC).",
         "win_open":"2020-05-24T17:00Z",
         "t0":null,
         "win_close":"2020-05-24T21:00Z",
         "est_date":{
            "month":null,
            "day":null,
            "year":null,
            "quarter":null
         },
         "date_str":"May 24",
         "tags":[
            {
               "id":19,
               "text":"Air Launch"
            },
            {
               "id":66,
               "text":"No Live Video Expected"
            },
            {
               "id":23,
               "text":"Test Flight"
            },
            {
               "id":14,
               "text":"Vehicle Debut"
            }
         ],
         "slug":"test-flight-1",
         "weather_summary":null,
         "weather_temp":null,
         "weather_icon":null,
         "weather_updated":null,
         "quicktext":"LauncherOne - LauncherOne Flight 1 - Sun May 24, 2020 17:00:00 UTC (L-2 days, 01:45:32) - https:\/\/rocketlaunch.live\/launch\/test-flight-1 for info\/stream",
         "media":[

         ],
         "result":-1,
         "suborbital":false,
         "modified":"2020-05-22T12:43:06+00:00"
      },
      {
         "id":92,
         "cospar_id":"",
         "sort_date":"1590611520",
         "name":"Crew Dragon Demo-2 (DM-2)",
         "provider":{
            "id":1,
            "name":"SpaceX",
            "slug":"spacex"
         },
         "vehicle":{
            "id":1,
            "name":"Falcon 9",
            "company_id":1,
            "slug":"falcon-9"
         },
         "pad":{
            "id":2,
            "name":"LC-39A",
            "location":{
               "id":61,
               "name":"Kennedy Space Center",
               "state":"FL",
               "statename":"Florida",
               "country":"United States",
               "slug":"kennedy-space-center"
            }
         },
         "missions":[
            {
               "id":89,
               "name":"Crew Dragon Demo-2 (DM-2)",
               "description":"For the first time since the last flight of the Space Shuttle in 2011, U.S. astronauts will go to orbit from American soil. As part of NASA's Commercial Crew Program, SpaceX's Falcon 9 will launch the Crew Dragon spacecraft to the International Space Station."
            }
         ],
         "mission_description":"For the first time since the last flight of the Space Shuttle in 2011, U.S. astronauts will go to orbit from American soil. As part of NASA's Commercial Crew Program, SpaceX's Falcon 9 will launch the Crew Dragon spacecraft to the International Space Station.",
         "launch_description":"A SpaceX Falcon 9 rocket will launch the Crew Dragon Demo-2 (DM-2) mission on Wednesday, May 27, 2020 at 8:32 PM (UTC).",
         "win_open":"2020-05-27T20:32Z",
         "t0":null,
         "win_close":null,
         "est_date":{
            "month":null,
            "day":null,
            "year":null,
            "quarter":null
         },
         "date_str":"May 27",
         "tags":[
            {
               "id":96,
               "text":"B1058"
            },
            {
               "id":22,
               "text":"Commercial Crew Program (CCP)"
            },
            {
               "id":9,
               "text":"Crewed"
            },
            {
               "id":2,
               "text":"Droneship Landing"
            }
         ],
         "slug":"crew-dragon-demo-2-d",
         "weather_summary":"Overcast\nTemp: 82.69F\nWind: 11.06mph\n",
         "weather_temp":82,
         "weather_icon":"wi-cloudy",
         "weather_updated":"2020-05-22T12:00:24+00:00",
         "quicktext":"Falcon 9 - Crew Dragon Demo-2 (DM-2) - Wed May 27, 2020 20:32:00 UTC (L-5 days, 05:17:32) - https:\/\/rocketlaunch.live\/launch\/crew-dragon-demo-2-d for info\/stream",
         "media":[

         ],
         "result":-1,
         "suborbital":false,
         "modified":"2020-05-21T17:25:48+00:00"
      },
      {
         "id":295,
         "cospar_id":"",
         "sort_date":"1592524796",
         "name":"SSMS (POC)",
         "provider":{
            "id":4,
            "name":"Arianespace",
            "slug":"arianespace"
         },
         "vehicle":{
            "id":11,
            "name":"Vega",
            "company_id":4,
            "slug":"vega"
         },
         "pad":{
            "id":18,
            "name":"ELV",
            "location":{
               "id":70,
               "name":"Guiana Space Centre",
               "state":null,
               "statename":null,
               "country":"French Guiana",
               "slug":"guiana-space-centre"
            }
         },
         "missions":[
            {
               "id":285,
               "name":"SSMS (POC)",
               "description":null
            }
         ],
         "mission_description":null,
         "launch_description":"An Arianespace Vega rocket will launch the SSMS (POC) mission. The launch date is currently targeted for June 18, 2020 (UTC).",
         "win_open":null,
         "t0":null,
         "win_close":null,
         "est_date":{
            "month":6,
            "day":18,
            "year":2020,
            "quarter":null
         },
         "date_str":"Jun 18",
         "tags":[

         ],
         "slug":"ssms-poc",
         "weather_summary":"Humid and Mostly Cloudy\nTemp: 80.44F\nWind: 8.81mph\n",
         "weather_temp":80,
         "weather_icon":"wi-night-alt-cloudy",
         "weather_updated":"2020-03-16T12:00:29+00:00",
         "quicktext":"Vega - SSMS (POC) - Jun 18 (estimated) - https:\/\/rocketlaunch.live\/launch\/ssms-poc for info\/stream",
         "media":[

         ],
         "result":-1,
         "suborbital":false,
         "modified":"2020-05-12T13:44:19+00:00"
      },
      {
         "id":189,
         "cospar_id":"",
         "sort_date":"1593561597",
         "name":"GPS III SV03 (Columbus)",
         "provider":{
            "id":1,
            "name":"SpaceX",
            "slug":"spacex"
         },
         "vehicle":{
            "id":1,
            "name":"Falcon 9",
            "company_id":1,
            "slug":"falcon-9"
         },
         "pad":{
            "id":3,
            "name":"SLC-40",
            "location":{
               "id":62,
               "name":"Cape Canaveral AFS",
               "state":"FL",
               "statename":"Florida",
               "country":"United States",
               "slug":"cape-canaveral-afs"
            }
         },
         "missions":[
            {
               "id":182,
               "name":"GPS III SV03 (Columbus)",
               "description":null
            }
         ],
         "mission_description":null,
         "launch_description":"A SpaceX Falcon 9 rocket will launch the GPS III SV03 (Columbus) mission. The launch date is currently targeted for June, 2020 (UTC).",
         "win_open":null,
         "t0":null,
         "win_close":null,
         "est_date":{
            "month":6,
            "day":null,
            "year":2020,
            "quarter":null
         },
         "date_str":"Jun 2020",
         "tags":[
            {
               "id":26,
               "text":"Navigation Satellite"
            },
            {
               "id":70,
               "text":"Series: GPS"
            }
         ],
         "slug":"gps-iii-2",
         "weather_summary":"Clear\nTemp: 70.04F\nWind: 6.46mph\n",
         "weather_temp":70,
         "weather_icon":"wi-day-sunny",
         "weather_updated":"2020-04-07T12:00:16+00:00",
         "quicktext":"Falcon 9 - GPS III SV03 (Columbus) - Jun 2020 (estimated) - https:\/\/rocketlaunch.live\/launch\/gps-iii-2 for info\/stream",
         "media":[

         ],
         "result":-1,
         "suborbital":false,
         "modified":"2020-04-07T21:52:36+00:00"
      },
      {
         "id":636,
         "cospar_id":"",
         "sort_date":"1593561597",
         "name":"Starlink-8",
         "provider":{
            "id":1,
            "name":"SpaceX",
            "slug":"spacex"
         },
         "vehicle":{
            "id":1,
            "name":"Falcon 9",
            "company_id":1,
            "slug":"falcon-9"
         },
         "pad":{
            "id":3,
            "name":"SLC-40",
            "location":{
               "id":62,
               "name":"Cape Canaveral AFS",
               "state":"FL",
               "statename":"Florida",
               "country":"United States",
               "slug":"cape-canaveral-afs"
            }
         },
         "missions":[
            {
               "id":664,
               "name":"Starlink-8",
               "description":null
            }
         ],
         "mission_description":null,
         "launch_description":"A SpaceX Falcon 9 rocket will launch the Starlink-8 mission. The launch date is currently targeted for June, 2020 (UTC).",
         "win_open":null,
         "t0":null,
         "win_close":null,
         "est_date":{
            "month":6,
            "day":null,
            "year":2020,
            "quarter":null
         },
         "date_str":"Jun 2020",
         "tags":[
            {
               "id":74,
               "text":"B1049"
            },
            {
               "id":24,
               "text":"Communications Satellite"
            },
            {
               "id":92,
               "text":"Series: SpaceX Starlink"
            }
         ],
         "slug":"starlink-8",
         "weather_summary":"Partly Cloudy\nTemp: 72.32F\nWind: 12.85mph\n",
         "weather_temp":72,
         "weather_icon":"wi-night-alt-cloudy",
         "weather_updated":"2020-05-18T12:00:20+00:00",
         "quicktext":"Falcon 9 - Starlink-8 - Jun 2020 (estimated) - https:\/\/rocketlaunch.live\/launch\/starlink-8 for info\/stream",
         "media":[

         ],
         "result":-1,
         "suborbital":false,
         "modified":"2020-05-18T13:04:00+00:00"
      }
   ]
}

#16

Thats a lot of data, and also beyond my scope of how to integrate into a piston. Maybe someone can help me in the right direction? Looking to add “mission description” but only on the ones from FL which is the original piston idea.


#17

I believe this data will be found in this list:

  • $response.result[0].missions[0].description = “Under development by Virgin Orbit since 2007, LauncherOne is an air launched rocket for small satellite payloads.”
  • $response.result[1].missions[0].description = “For the first time since the last flight of the Space Shuttle in 2011, U.S. astronauts will go to orbit from American soil. As part of NASA’s Commercial Crew Program, SpaceX’s Falcon 9 will launch the Crew Dragon spacecraft to the International Space Station.”
  • $response.result[2].missions[0].description = null
  • $response.result[3].missions[0].description = null
  • $response.result[4].missions[0].description = null

Although, it looks like you can also use these for the same results:

  • $response.result[0].mission_description
  • $response.result[1].mission_description
  • $response.result[2].mission_description
  • $response.result[3].mission_description
  • $response.result[4].mission_description

Off Topic Side Note:

It should be easy for us to find a description for weather alerts, but so far, we have failed…
(Any experts up for the challenge?)


#18

As always, you are the best! Thanks for the point in the right direction!


#19

This is what I ended up with and looking forward to it!! :grinning: :rocket::rocket:


#20

It’s coming along pretty good, @SergL, but with the current wording, these variables will never be set:

pic

(GET requests do not linger in memory like variables do, so you either have to set those variables at 3:56AM, or make an additional request on the date & time in question… My choice would be the former)