Google Maps travel times
This flow creates some HTTP service in Node Red that provides Google Maps travel time data to external systems, in my case this gets called by Tasker on an Android Phone to deliver live traffic information to the user.
Detail video on this integration can be found here: https://youtu.be/z4ybCzT0pbY
[{"id":"ae38598b.f38e28","type":"tab","label":"Google Maps","disabled":false,"info":""},{"id":"47d6c022.c08b8","type":"http in","z":"ae38598b.f38e28","name":"","url":"/traveltime","method":"get","upload":false,"swaggerDoc":"","x":119.99999237060547,"y":113.33332824707031,"wires":[["1fd4e71c.f20469"]]},{"id":"1fd4e71c.f20469","type":"http request","z":"ae38598b.f38e28","name":"Travel to work","method":"GET","ret":"txt","url":"https://maps.googleapis.com/maps/api/distancematrix/json?origins=353+Uxbridge+Road+London+W3+9RH&destinations=Bridgehouse+Oxford Rd+Uxbridge+UB8+1HS&key=your_api_key&mode=driving&units=metric&departure_time=now","tls":"","x":344.9000244140625,"y":111.73336791992188,"wires":[["ee4f664e.6320a8"]]},{"id":"ee4f664e.6320a8","type":"json","z":"ae38598b.f38e28","name":"","x":545.9000511169434,"y":110.73336791992188,"wires":[["c9f30811.84a778","da98cb9c.fc23a8"]]},{"id":"c9f30811.84a778","type":"function","z":"ae38598b.f38e28","name":"Parse data","func":"msg.payload = \"Driving time to work is \" + msg.payload.rows[0].elements[0].duration_in_traffic.text.replace(\"mins\",\"minutes\");\n\nreturn msg;","outputs":1,"noerr":0,"x":720.9000091552734,"y":110.73336791992188,"wires":[["a2e0fd99.078fc"]]},{"id":"a2e0fd99.078fc","type":"http response","z":"ae38598b.f38e28","name":"","statusCode":"","headers":{},"x":898.0000152587891,"y":110.13336849212646,"wires":[]},{"id":"d6f94609.fab758","type":"http in","z":"ae38598b.f38e28","name":"","url":"/traveltime2","method":"get","upload":false,"swaggerDoc":"","x":118.23346710205078,"y":286.7333984375,"wires":[["7b351f9b.7978e","da60ec97.7f8ee"]]},{"id":"6acaa704.9bada8","type":"json","z":"ae38598b.f38e28","name":"","x":548.1335182189941,"y":286.13339042663574,"wires":[["64414ef4.c9c2e"]]},{"id":"64414ef4.c9c2e","type":"function","z":"ae38598b.f38e28","name":"Parse data","func":"msg.topic = \"work\";\nmsg.payload = msg.payload.rows[0].elements[0].duration_in_traffic.text.replace(\"mins\",\"minutes\");\n\nreturn msg;","outputs":1,"noerr":0,"x":720.1335792541504,"y":285.13339710235596,"wires":[["a6c77ef4.d1407"]]},{"id":"c819ccea.c30fd","type":"http response","z":"ae38598b.f38e28","name":"","statusCode":"","headers":{},"x":1227.2335929870605,"y":284.53339862823486,"wires":[]},{"id":"9133073f.ce76f8","type":"json","z":"ae38598b.f38e28","name":"","x":540.2334594726562,"y":332.7333507537842,"wires":[["b060620d.f8f3"]]},{"id":"b060620d.f8f3","type":"function","z":"ae38598b.f38e28","name":"Parse data","func":"msg.topic = \"airport\";\nmsg.payload = msg.payload.rows[0].elements[0].duration_in_traffic.text.replace(\"mins\",\"minutes\");\n\nreturn msg;","outputs":1,"noerr":0,"x":722.2334594726562,"y":332.7333507537842,"wires":[["a6c77ef4.d1407"]]},{"id":"a6c77ef4.d1407","type":"join","z":"ae38598b.f38e28","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"2","x":882.7334861755371,"y":283.93339920043945,"wires":[["eb57cbf2.114528","7afc1deb.a1e6d4"]]},{"id":"eb57cbf2.114528","type":"function","z":"ae38598b.f38e28","name":"Parse data","func":"msg.payload = \"Driving time to work is \" + msg.payload.work + \", and to Heathrow T5 is \" + msg.payload.airport;\n\nreturn msg;","outputs":1,"noerr":0,"x":1054.2334594726562,"y":284.7333507537842,"wires":[["c819ccea.c30fd"]]},{"id":"51ad2418.83e96c","type":"comment","z":"ae38598b.f38e28","name":"Get travel time","info":"This flow uses the travel distance API to get the \ntravel time in between to places.","x":117.5,"y":55.33334255218506,"wires":[]},{"id":"da98cb9c.fc23a8","type":"debug","z":"ae38598b.f38e28","name":"","active":true,"console":"false","complete":"false","x":717.5000228881836,"y":165.66668796539307,"wires":[]},{"id":"efc502ee.bf20f","type":"comment","z":"ae38598b.f38e28","name":"Get multiple travel times","info":"This flow is similar to the above, but executes\ntwo queries for two different routes and later \ncombines the results to one single message.","x":139.99999237060547,"y":239.99998474121094,"wires":[]},{"id":"7b351f9b.7978e","type":"http request","z":"ae38598b.f38e28","name":"Travel to work","method":"GET","ret":"txt","url":"https://maps.googleapis.com/maps/api/distancematrix/json?origins=353+Uxbridge+Road+London+W3+9RH&destinations=Bridgehouse+Oxford Rd+Uxbridge+UB8+1HS&key=your_api_key&mode=driving&units=metric&departure_time=now","tls":"","x":354.9999885559082,"y":286.66664028167725,"wires":[["6acaa704.9bada8"]]},{"id":"da60ec97.7f8ee","type":"http request","z":"ae38598b.f38e28","name":"Travel to work","method":"GET","ret":"txt","url":"https://maps.googleapis.com/maps/api/distancematrix/json?origins=353+Uxbridge+Road+London+W3+9RH&destinations=Heathrow+Business+Parking+Terminal+5&key=your_api_key&mode=driving&units=metric&departure_time=now","tls":"","x":353.33331298828125,"y":331.6666450500488,"wires":[["9133073f.ce76f8"]]},{"id":"7afc1deb.a1e6d4","type":"debug","z":"ae38598b.f38e28","name":"","active":true,"console":"false","complete":"false","x":1060,"y":341.6666564941406,"wires":[]},{"id":"cfd02523.636ec8","type":"comment","z":"ae38598b.f38e28","name":"Next tram","info":"This flow uses the directions API to get directions\ndata and in this case using public transport.\nUnfortunately this cannot be used to get a \ntimetable of a stop showing future arrivals\nbut can be used to get the next bus/tram\narriving at a particular stop.","x":96.66665649414062,"y":419.9999694824219,"wires":[]},{"id":"b540553d.cc47b8","type":"http in","z":"ae38598b.f38e28","name":"","url":"/nexttram","method":"get","upload":false,"swaggerDoc":"","x":109.99999237060547,"y":468.33331298828125,"wires":[["a219de18.82fe2"]]},{"id":"a219de18.82fe2","type":"http request","z":"ae38598b.f38e28","name":"Next Tram","method":"GET","ret":"txt","url":"https://maps.googleapis.com/maps/api/directions/json?origin=place_id:ChIJa8o4LH7nQUcRo2XNV7Ae-Vs&destination=place_id:ChIJuV9SgJndQUcRJRrgPQ7ajjw&key=your_api_key&mode=transit&units=metric&transit_mode=tram&departure_time=now","tls":"","x":334.9000244140625,"y":466.7333526611328,"wires":[["be1529e3.b50a68"]]},{"id":"be1529e3.b50a68","type":"json","z":"ae38598b.f38e28","name":"","x":545.9000511169434,"y":465.7333526611328,"wires":[["996cb702.cf65b8","9bc8d447.a439a8"]]},{"id":"996cb702.cf65b8","type":"function","z":"ae38598b.f38e28","name":"Parse data","func":"msg.payload = \"Next tram is number \" + msg.payload.routes[0].legs[0].steps[0].transit_details.line.short_name + \" leaving at \" + msg.payload.routes[0].legs[0].steps[0].transit_details.departure_time.text;\n\nreturn msg;","outputs":1,"noerr":0,"x":720.9000091552734,"y":465.7333526611328,"wires":[["fd01b62.21cd748"]]},{"id":"fd01b62.21cd748","type":"http response","z":"ae38598b.f38e28","name":"","statusCode":"","headers":{},"x":898.0000152587891,"y":465.1333532333374,"wires":[]},{"id":"9bc8d447.a439a8","type":"debug","z":"ae38598b.f38e28","name":"","active":true,"console":"false","complete":"false","x":717.5000228881836,"y":520.666672706604,"wires":[]}]