← All public flows
PublicFlow #39
Polite API poller with back-pressure
Shared by Anonymous on 24 Aug 2026
18 views0 votes
About this flow
A base flow for polling a slow local API without piling up requests. The delay node drops overlapping triggers, the function records response time, and non-2xx replies go to a separate debug output. Replace the example URL before deploying.
Node-RED JSON
[{"id":"tab-api","type":"tab","label":"Polite API poller","disabled":false,"info":"Rate-limited HTTP polling with basic response routing."},{"id":"inject-api","type":"inject","z":"tab-api","name":"Every 5 minutes","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"300","crontab":"","once":true,"onceDelay":5,"topic":"","payload":"","payloadType":"date","x":160,"y":100,"wires":[["delay-api"]]},{"id":"delay-api","type":"delay","z":"tab-api","name":"Only one request","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"minute","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"allowrate":false,"outputs":1,"x":380,"y":100,"wires":[["stamp-api"]]},{"id":"stamp-api","type":"function","z":"tab-api","name":"Start timer","func":"msg.startedAt = Date.now();\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":580,"y":100,"wires":[["request-api"]]},{"id":"request-api","type":"http request","z":"tab-api","name":"Fetch local API","method":"GET","ret":"obj","paytoqs":"ignore","url":"http://192.168.1.20:8080/status","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":790,"y":100,"wires":[["timing-api"]]},{"id":"timing-api","type":"function","z":"tab-api","name":"Add response time","func":"msg.responseTimeMs = Date.now() - msg.startedAt;\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1010,"y":100,"wires":[["status-api"]]},{"id":"status-api","type":"switch","z":"tab-api","name":"HTTP status","property":"statusCode","propertyType":"msg","rules":[{"t":"btwn","v":"200","vt":"num","v2":"299","v2t":"num"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":1210,"y":100,"wires":[["ok-api"],["error-api"]]},{"id":"ok-api","type":"debug","z":"tab-api","name":"API data","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1390,"y":70,"wires":[]},{"id":"error-api","type":"debug","z":"tab-api","name":"API problem","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":1400,"y":130,"wires":[]}]Visual preview
Drag to pan · Scroll to zoom