REST API to Dashboard 2.0

Small sample flow on how to perform a HTTP Request to a REST API, parse it, and visualise it in a Chart in Dashboard 2.0

[{"id":"da9a67e8c3ea7742","type":"inject","z":"204422ef719f74d6","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"00 12 * * *","once":false,"onceDelay":0.1,"topic":"","payload":"[]","payloadType":"json","x":150,"y":100,"wires":[["efd22a89abc3c06f","a6851a41dba2c39b"]]},{"id":"a6851a41dba2c39b","type":"http request","z":"204422ef719f74d6","name":"","method":"GET","ret":"obj","paytoqs":"ignore","url":"https://api.npmjs.org/downloads/range/last-month/@flowforge/node-red-dashboard","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":330,"y":100,"wires":[["7931f7457880f7c3"]]},{"id":"7931f7457880f7c3","type":"change","z":"204422ef719f74d6","name":"Only get the Downloads","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.downloads","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":550,"y":100,"wires":[["74e3b15c7b09726a"]]},{"id":"74e3b15c7b09726a","type":"link out","z":"204422ef719f74d6","name":"link out 1","mode":"link","links":["43e4aff34b989e83"],"x":715,"y":100,"wires":[]},{"id":"43e4aff34b989e83","type":"link in","z":"204422ef719f74d6","name":"Normalize daily data","links":["74e3b15c7b09726a"],"x":95,"y":180,"wires":[["ca8c62bfbdf75715"]]},{"id":"ca8c62bfbdf75715","type":"split","z":"204422ef719f74d6","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":210,"y":180,"wires":[["3f462d2c7e3bca50"]]},{"id":"3f462d2c7e3bca50","type":"change","z":"204422ef719f74d6","name":"Prepare data for the chart","rules":[{"t":"set","p":"payload.x","pt":"msg","to":"$toMillis(payload.day)","tot":"jsonata"},{"t":"set","p":"payload.y","pt":"msg","to":"payload.downloads","tot":"msg"},{"t":"delete","p":"payload.day","pt":"msg"},{"t":"delete","p":"payload.downloads","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":410,"y":180,"wires":[["f4e6a85b8cb8dac0"]]},{"id":"4b71fc28c2da66e7","type":"ui-chart","z":"204422ef719f74d6","group":"bac8effac57694e1","name":"","label":"Daily Downloads","order":9007199254740991,"chartType":"line","xAxisType":"time","removeOlder":1,"removeOlderUnit":"3600","removeOlderPoints":"","colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"width":0,"height":0,"className":"","x":230,"y":260,"wires":[[]]},{"id":"f4e6a85b8cb8dac0","type":"link out","z":"204422ef719f74d6","name":"link out 2","mode":"link","links":["6f7068445bfe4311"],"x":575,"y":180,"wires":[]},{"id":"6f7068445bfe4311","type":"link in","z":"204422ef719f74d6","name":"Update the chart","links":["f4e6a85b8cb8dac0","79067215ee592ec9","efd22a89abc3c06f"],"x":95,"y":260,"wires":[["4b71fc28c2da66e7"]]},{"id":"efd22a89abc3c06f","type":"link out","z":"204422ef719f74d6","name":"link out 3","mode":"link","links":["6f7068445bfe4311"],"x":315,"y":60,"wires":[]},{"id":"bac8effac57694e1","type":"ui-group","name":"NPM Downloads","page":"f10b4d0259e43aeb","width":"6","height":"1","order":-1,"disp":true},{"id":"f10b4d0259e43aeb","type":"ui-page","name":"Main","ui":"b4498e02eeb28614","path":"/","layout":"grid","theme":"2c5d702b11de7dd1","order":-1},{"id":"b4498e02eeb28614","type":"ui-base","name":"REST Dashboard","path":"/dashboard"},{"id":"2c5d702b11de7dd1","type":"ui-theme","name":"Theme Name","colors":{"surface":"#ffffff","primary":"#0094ce","bgPage":"#eeeeee","groupBg":"#ffffff","groupOutline":"#cccccc"}}]

Flow Info

Created 8 months, 2 weeks ago
Rating: not yet rated

Owner

Actions

Rate:

Node Types

Core
  • change (x2)
  • http request (x1)
  • inject (x1)
  • link in (x2)
  • link out (x3)
  • split (x1)
Other

Tags

  • dashboard
  • http
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option