Node-RED Twitter (X) Integration: a Working Polling Flow

By TwitterAPI.io Team•17 min read
Diagram of a working Node-RED Twitter (X) flow: inject timer, build request Function node, http request node with an X-API-Key header calling advanced_search, dedupe and paginate Function node, mqtt out and debug outputs, flow context storing sinceTime and seenIds.
A Node-RED flow that replaces the retired Twitter node with core nodes and a REST search call.
TL;DR
  • The old node is retired: node-red-node-twitter 1.2.0 (March 14, 2021) is deprecated on npm as "No longer maintained" and is built on v1.1 endpoints, including statuses/filter, which X deprecated on March 14, 2023.
  • Replacement, core nodes only: inject -> Function (build URL) -> http request (X-API-Key header, parsed JSON) -> Function (dedupe + paginate) -> mqtt out / debug. The full flow JSON is below; import it and set TWITTERAPI_KEY.
  • State lives in flow context: sinceTime, a capped seenIds list and an in-flight guard. Switch context storage to localfilesystem so a restart does not replay or skip posts.
  • Pick the interval from data: across six keyword searches, 1-minute polling came back empty 74.8% to 99.6% of the time; at 15 minutes the busier keywords (about 260 to 420 posts a day) were almost never empty.
  • Cost per keyword, 30 days: about $6.51 to $8.36 at 1-minute polling (the $6.48 empty-poll floor dominates), $0.46 to $2.32 at 15 minutes.
  • Versus the official X API: $0.15 per 1,000 posts returned here, against $0.005 per post read ($5 per 1,000) on X pay-per-use, about 33x more per 1,000 posts.

This page is about Node-RED, the flow-based tool people run on a Raspberry Pi, a home server or a factory gateway, and about getting new X (Twitter) posts into it with the nodes it already ships. If you build in n8n instead, our n8n workflow guide covers that tool's own X node and its OAuth2 credentials; the two tools are wired differently, and nothing below depends on n8n. Here the work is done by an Inject timer, an http request node and two short Function nodes, and the output is one message per new post that you can hand to MQTT, a Dashboard widget or a Telegram bot.

We start with the question that brings people here, why the old Twitter node in the Node-RED palette stopped working, and answer it from its npm record, its source on GitHub and X's own changelog. Then we give you a flow you can import, explain every node against the Node-RED documentation, and show what the polling interval does to latency and to your bill using a real study: six keyword searches over one 24-hour window, 939 posts in total, replayed through the same polling logic at 1, 5, 15 and 60 minutes.

What we ran ourselves: the two Function node bodies against saved API pages in a Node.js harness, and the whole flow inside Node-RED 5.0.10 installed in a throwaway directory, pointed at a local mock server that replayed real advanced_search pages (4 requests, 54 posts emitted, no duplicates on a second pass). Node-RED behavior that we did not exercise, such as the editor's import dialog, is described per the Node-RED docs.

Share of 1-minute polls that found nothing for the keyword node-red

99.6% (6 matching posts in 24 hours, collected in 2026). Each empty poll is still billed the 15-credit minimum, so a 1-minute Inject timer costs about $6.51 per 30 days; at 15 minutes it is $0.46.

01 — Section

Why the node-red-node-twitter node stopped working

The Twitter node that many Node-RED tutorials use is node-red-node-twitter, maintained in the node-red/node-red-nodes repository under social/twitter. Its npm record tells the story in three fields: the latest version is 1.2.0, published on March 14, 2021; the package carries the deprecation message "No longer maintained"; and nothing has been published since. In the GitHub repository, the last commit touching the social/twitter folder is a January 2022 housekeeping change (lint and security checks across the mono-repo), not a feature or an API update.

The node's source (27-twitter.js) shows why it cannot simply be revived. Every mode is wired to X API v1.1 with OAuth 1.0a user keys (consumer key and secret plus an access token from an X developer app):

Node modeWhat it callsStatus
Search all public posts for a termstatuses/filter (v1.1 streaming)Deprecated by X on March 14, 2023; v2 filtered stream is the named replacement
Posts from specific usersstatuses/user_timeline.json, polled every 60 sv1.1 REST, user keys, billed per post read under X pay-per-use
Your home timeline / followsstatuses/home_timeline.json, polled every 60 sSame as above
A user's activity streamnoneThe node itself errors: "Twitter removed this API in August 2018"
Send a post or DMstatuses/update.json, direct_messages/events/new.jsonv1.1 write paths, user keys

X's developer changelog lists "Deprecation of Statuses/Filter endpoint" on March 14, 2023, with the sentence that developers can use the filtered stream endpoint in X API v2, and on September 28, 2023 it deprecated the v1.1 search/tweets, users/search and geo/search endpoints as well. A keyword monitor, which is what people usually want from Node-RED, therefore has no v1.1 path left. The repository's issue tracker has an open request titled "Twitter API V2.0 public search update" from October 2022 that was never merged.

Even the user-timeline modes, where X still answers some v1.1 calls, would now need a paid X developer account: X's pricing page (docs.x.com/x-api/getting-started/pricing) bills $0.005 per post read and $0.010 per user read on pay-per-usage, capped at 3 million post reads a month before Enterprise. The other Twitter packages on npm do not fill the gap either: node-red-contrib-twitter (1.1.3, 2016) is marked "Package no longer supported", node-red-contrib-twitter-stream was last published in 2019 and node-red-twitter in 2017. All of them predate API v2.

The practical answer: do not install a Twitter node at all. Node-RED's core http request node can call any JSON API, so the flow below talks to a REST search endpoint directly and keeps its own state, which is also easier to debug than a third-party node that hides the API behind a config dialog.

02 — Section

The replacement flow, node by node

The flow has five working nodes on one tab. Everything is core Node-RED, so there is nothing to add to the palette.

1. Inject, every 5 min. Fires a timestamp every 300 seconds and once, five seconds after the flow starts. Per the Node-RED docs, the interval option repeats from deploy time and can be up to about 596 hours; the "interval between times" and "at a specific time" options use cron, which aligns to the clock ("20 minutes" means on the hour, :20 and :40, not 20 minutes from now). For polling, the plain interval is what you want.

2. Function, build request. Reads sinceTime from flow context, subtracts a 60-second overlap, and builds the request: msg.url for https://api.twitterapi.io/twitter/tweet/advanced_search with queryType=Latest and the query ("node-red" OR nodered) -filter:retweets since_time:<unix seconds>, msg.method = "GET", and msg.headers = {"X-API-Key": env.get("TWITTERAPI_KEY")}. When the message is a loop-back for page two, it adds &cursor=. It also refuses to start a second poll while one is still paging, and treats that guard as stale after 120 seconds so a restart cannot wedge it.

3. http request, advanced_search. Method - set by msg.method -, URL left empty, return "a parsed JSON object". The node's help text says a URL or method not configured in the node is taken from msg.url / msg.method, and that msg.headers sets request headers (headers configured in the node override matching ones in msg.headers). The response arrives as msg.payload with msg.statusCode.

4. Function, dedupe + paginate, two outputs. If msg.statusCode is not 200 or msg.payload.tweets is missing, it sets a red node status with the API's msg or detail text, raises node.error() (so a Catch node can alert you) and ends the poll. Otherwise it drops every post whose id is in seenIds, appends the rest, and returns [fresh, next]: per the Node-RED docs, an array on output 1 sends each message in turn, and null on output 2 sends nothing there. When has_next_page is true and the page was not empty, output 2 carries next_cursor back into build request for the same poll, up to five pages.

5. Outputs. Output 1 feeds an mqtt out node (topic x/search/node-red, QoS 1, a localhost:1883 broker config) and a debug node. Each message's payload is a small object: id, url, text, createdAt, author (the author.userName field), likes and isReply. Swap the MQTT node for whatever consumes the post.

Why Function nodes rather than change + switch nodes. You could build the URL with a change node and mustache tags (the http request help notes that {{{topic}}}-style tags are expanded in a configured URL), but the dedupe step needs a set, a list cap and a two-way decision about the next page, which is a few lines of JavaScript and a long chain of switch nodes.

03 — Section

The flow JSON: import it and set one environment variable

Copy the JSON below into the Node-RED editor's Import dialog. It creates a tab called X keyword monitor with the five nodes and an MQTT broker config node.

Set the key outside the flow. The build request node reads env.get("TWITTERAPI_KEY"). Set TWITTERAPI_KEY in the environment that starts Node-RED (a systemd unit, a Docker -e, or your shell) rather than pasting the key into the Function node, so it never ends up in an exported flow or a git repository. Get a key from the dashboard; new accounts that pass the automatic bot check receive free starter credits (no card, one per person or network, expiring after 31 days), with the amount on the pricing page.

Change the keyword in one place. The KEYWORD constant at the top of build request takes the full advanced search syntax: from: for an account, OR, quoted phrases, -filter:retweets, -filter:replies, lang:en. Keep since_time: out of it; the node appends that.

We validated this exact JSON by parsing it, compiling both Function bodies, and running it inside Node-RED 5.0.10 against a local mock of the search endpoint that replayed saved response pages. Against the live API you will see the same message shapes.

json
[
  {
    "id": "a1b2c3d4e5f60001",
    "type": "tab",
    "label": "X keyword monitor",
    "disabled": false,
    "info": "Polls TwitterAPI.io advanced_search for a keyword, drops posts already seen (flow context), publishes each new post to MQTT. Set the TWITTERAPI_KEY environment variable before starting Node-RED."
  },
  {
    "id": "a1b2c3d4e5f60002",
    "type": "inject",
    "z": "a1b2c3d4e5f60001",
    "name": "every 5 min",
    "props": [
      {
        "p": "payload"
      }
    ],
    "repeat": "300",
    "crontab": "",
    "once": true,
    "onceDelay": "5",
    "topic": "",
    "payload": "",
    "payloadType": "date",
    "x": 130,
    "y": 100,
    "wires": [
      [
        "a1b2c3d4e5f60003"
      ]
    ]
  },
  {
    "id": "a1b2c3d4e5f60003",
    "type": "function",
    "z": "a1b2c3d4e5f60001",
    "name": "build request",
    "func": "const KEYWORD = '(\"node-red\" OR nodered) -filter:retweets';\nconst OVERLAP = 60; // seconds re-read on each poll so late-indexed posts are not missed; seen ids are dropped later\nconst now = Math.floor(Date.now() / 1000);\nif (!msg.cursor) {\n    const inFlight = flow.get(\"pollInFlight\"); // start time of a running poll, or false\n    if (inFlight && now - inFlight < 120) {\n        node.status({fill: \"yellow\", shape: \"ring\", text: \"previous poll still running\"});\n        return null;\n    }\n    flow.set(\"pollInFlight\", now);\n    msg.pollStartedAt = now;\n    msg.pageCount = 0;\n    const since = flow.get(\"sinceTime\") || (now - 3600);\n    msg.sinceTime = since - OVERLAP;\n}\nconst q = KEYWORD + \" since_time:\" + msg.sinceTime;\nlet url = \"https://api.twitterapi.io/twitter/tweet/advanced_search\"\n    + \"?queryType=Latest&query=\" + encodeURIComponent(q);\nif (msg.cursor) url += \"&cursor=\" + encodeURIComponent(msg.cursor);\nmsg.url = url;\nmsg.method = \"GET\";\nmsg.headers = {\"X-API-Key\": env.get(\"TWITTERAPI_KEY\")};\ndelete msg.payload;\nreturn msg;\n",
    "outputs": 1,
    "timeout": 0,
    "noerr": 0,
    "initialize": "",
    "finalize": "",
    "libs": [],
    "x": 330,
    "y": 100,
    "wires": [
      [
        "a1b2c3d4e5f60004"
      ]
    ]
  },
  {
    "id": "a1b2c3d4e5f60004",
    "type": "http request",
    "z": "a1b2c3d4e5f60001",
    "name": "advanced_search",
    "method": "use",
    "ret": "obj",
    "paytoqs": "ignore",
    "url": "",
    "tls": "",
    "persist": false,
    "proxy": "",
    "insecureHTTPParser": false,
    "authType": "",
    "senderr": false,
    "headers": [],
    "x": 540,
    "y": 100,
    "wires": [
      [
        "a1b2c3d4e5f60005"
      ]
    ]
  },
  {
    "id": "a1b2c3d4e5f60005",
    "type": "function",
    "z": "a1b2c3d4e5f60001",
    "name": "dedupe + paginate",
    "func": "const MAX_PAGES = 5;\nconst SEEN_LIMIT = 2000;\nif (msg.statusCode !== 200 || !msg.payload || !Array.isArray(msg.payload.tweets)) {\n    flow.set(\"pollInFlight\", false);\n    const why = (msg.payload && (msg.payload.msg || msg.payload.detail)) || (\"HTTP \" + msg.statusCode);\n    node.status({fill: \"red\", shape: \"dot\", text: String(why).slice(0, 60)});\n    node.error(\"advanced_search failed: \" + why, msg);\n    return null;\n}\nconst seen = flow.get(\"seenIds\") || [];\nconst seenSet = new Set(seen);\nconst fresh = [];\nfor (const t of msg.payload.tweets) {\n    if (seenSet.has(t.id)) continue;\n    seenSet.add(t.id);\n    seen.push(t.id);\n    fresh.push({\n        topic: \"x/search/node-red\",\n        payload: {\n            id: t.id,\n            url: t.url,\n            text: t.text,\n            createdAt: t.createdAt,\n            author: t.author ? t.author.userName : null,\n            likes: t.likeCount,\n            isReply: t.isReply\n        }\n    });\n}\nflow.set(\"seenIds\", seen.slice(-SEEN_LIMIT));\nmsg.pageCount += 1;\nflow.set(\"lastNew\", (msg.pageCount === 1 ? 0 : (flow.get(\"lastNew\") || 0)) + fresh.length);\nconst more = msg.payload.has_next_page && msg.payload.tweets.length > 0 && msg.pageCount < MAX_PAGES;\nlet next = null;\nif (more) {\n    next = {cursor: msg.payload.next_cursor, sinceTime: msg.sinceTime,\n            pollStartedAt: msg.pollStartedAt, pageCount: msg.pageCount};\n} else {\n    flow.set(\"sinceTime\", msg.pollStartedAt);\n    flow.set(\"pollInFlight\", false);\n    node.status({fill: \"green\", shape: \"dot\", text: \"last poll: \" + (flow.get(\"lastNew\") || 0) + \" new\"});\n}\nfresh.reverse(); // oldest first downstream\nreturn [fresh, next];\n",
    "outputs": 2,
    "timeout": 0,
    "noerr": 0,
    "initialize": "",
    "finalize": "",
    "libs": [],
    "x": 760,
    "y": 100,
    "wires": [
      [
        "a1b2c3d4e5f60006",
        "a1b2c3d4e5f60007"
      ],
      [
        "a1b2c3d4e5f60003"
      ]
    ]
  },
  {
    "id": "a1b2c3d4e5f60006",
    "type": "mqtt out",
    "z": "a1b2c3d4e5f60001",
    "name": "publish new post",
    "topic": "",
    "qos": "1",
    "retain": "false",
    "respTopic": "",
    "contentType": "",
    "userProps": "",
    "correl": "",
    "expiry": "",
    "broker": "a1b2c3d4e5f60008",
    "x": 990,
    "y": 80,
    "wires": []
  },
  {
    "id": "a1b2c3d4e5f60007",
    "type": "debug",
    "z": "a1b2c3d4e5f60001",
    "name": "new posts",
    "active": true,
    "tosidebar": true,
    "console": false,
    "tostatus": false,
    "complete": "payload",
    "targetType": "msg",
    "statusVal": "",
    "statusType": "auto",
    "x": 980,
    "y": 140,
    "wires": []
  },
  {
    "id": "a1b2c3d4e5f60008",
    "type": "mqtt-broker",
    "name": "local broker",
    "broker": "localhost",
    "port": "1883",
    "clientid": "",
    "autoConnect": true,
    "usetls": false,
    "protocolVersion": "4",
    "keepalive": "60",
    "cleansession": true
  }
]
04 — Section

Deduplication and state that survives a restart

A polling flow has two ways to go wrong: it can emit the same post twice, or it can silently skip posts. The flow guards against both with three values in flow context, the store that, per the Node-RED docs, is shared by all nodes on the same tab.

sinceTime is the Unix time at which the last completed poll started. Each poll asks for since_time: that value minus 60 seconds. The overlap catches a post that was created just before the previous poll but indexed a moment after it. The cost is that posts in the overlap are returned (and billed) twice; the next value fixes the duplicates.

seenIds is the list of post ids already emitted, capped at the last 2,000. A post that comes back in the overlap is dropped here before it reaches MQTT. 2,000 ids is many hours of headroom even for the busiest keyword in our study.

pollInFlight holds the start time of a poll that is still paging. If the Inject node fires while a five-page poll is running, the new tick is dropped with a yellow status instead of starting a second, overlapping poll.

By default context lives in memory and is cleared when Node-RED restarts. After a restart the flow would then search the last hour and emit everything in it again. The Node-RED docs describe the fix: set contextStorage in settings.js to the localfilesystem module, which keeps context under ~/.node-red/context/, caches it in memory and writes it to disk every 30 seconds. With that setting, a restart resumes from the stored sinceTime and the stored seenIds. Restart Node-RED after editing settings.js.

What the cap of five pages means. Five pages is 100 posts in one poll. In our study the largest single 60-minute poll held 23 posts (raspberry pi) and the largest 5-minute poll held 5, so the cap is far from binding at sensible intervals. If you raise the interval for a very busy query, raise MAX_PAGES with it, because pages arrive newest first and a capped poll drops the oldest posts in its window.

javascript
// settings.js (in your Node-RED user directory, usually ~/.node-red)
contextStorage: {
    default: {
        module: "localfilesystem"
    }
},
05 — Section

Choosing the Inject interval: what a fixed timer actually returns

The interval decides two things: how stale an alert can be (on average half the interval, plus indexing time) and how many polls you pay for that return nothing. To put numbers on the second part we collected one 24-hour window of advanced_search results for six keywords a Node-RED user might watch, then replayed a fixed timer over the real post timestamps.

KeywordPosts per dayEmpty polls, every 1 minEvery 5 minEvery 15 min
node-red699.6%97.9%93.8%
mqtt5496.5%83.0%56.2%
home assistant16089.9%58.7%19.8%
arduino25984.0%41.0%5.2%
raspberry pi321 (est.)80.7%36.7%1.2%
esp32420 (est.)74.8%29.3%0.0%

The keyword node-red itself is quiet: 6 matching posts in 24 hours, a median gap of 73 minutes between them. Polling it every minute means 99.6% of the polls return an empty tweets array, and even at 15 minutes 93.8% are empty. For a niche keyword like this the 60-minute row is the honest choice unless you need alerts within minutes: it is still empty 79.2% of the time.

The busier hardware keywords behave differently. esp32 (about 420 posts a day, estimated from a 10.3-hour covered span), raspberry pi (about 321) and arduino (259) were empty in 74.8% to 84.0% of 1-minute polls, but at 15 minutes almost every poll had something: 0.0% to 5.2% empty, with 4.4, 3.3 and 2.7 new posts per poll on average.

Rule of thumb from the data: match the interval to the median gap between posts. If posts arrive every few minutes, a 5-minute timer gives near-real-time alerts with roughly a third of polls empty; if they arrive every hour or more, anything faster than 15 minutes is mostly paying to hear nothing.

KeywordMax new posts in one poll, 5 min15 min60 minPolls over one page at 60 min
node-red1120.0%
mqtt3460.0%
home assistant48180.0%
arduino58190.0%
raspberry pi510235.0%
esp325102230.0%

The last column is the pagination check. At 60 minutes, esp32 passed 20 new posts in 30.0% of polls and raspberry pi in 5.0%, which is exactly the case the loop-back on output 2 exists for. At 5 and 15 minutes no keyword in the sample ever needed a second page.

Line chart of the share of empty polls at 1, 5, 15 and 60 minute intervals for six keywords. node-red stays above 79% at every interval; esp32, raspberry pi and arduino fall to near 0% at 15 minutes.
Share of polls that return no new post, by Inject interval. Simulated over real advanced_search timestamps from one 24-hour window, collected in 2026.
06 — Section

What the flow costs per month at each interval

TwitterAPI.io bills tweet endpoints at 15 credits per post returned ($0.15 per 1,000 posts), with a minimum of 15 credits per request, so a search that returns nothing costs $0.00015 and a full 20-post page costs $0.003. There is no per-request cap. For a poller that gives a simple formula: every empty poll costs the minimum, and every non-empty poll costs 15 credits per post plus one more minimum for the page that ends the pagination (see below).

KeywordEvery 1 minEvery 5 minEvery 15 minEvery 60 min
node-red$6.51$1.32$0.46$0.14
mqtt$6.72$1.54$0.68$0.35
home assistant$7.20$2.02$1.15$0.83
arduino$7.65$2.46$1.60$1.27
raspberry pi$7.92$2.73$1.86$1.49
esp32$8.36$3.18$2.32$1.98

At 1-minute polling every keyword lands between about $6.50 and $8.40 for 30 days, because 43,200 checks a month at the $0.00015 floor is $6.48 before a single post is returned. Moving the same flow to 15 minutes cuts that to $0.46 for the quiet keyword and $2.32 for the busiest one, and from there on the bill is mostly the posts themselves, which you pay for at any interval.

The trailing empty page. In all 6 of our 6 searches, the last page that held posts still reported has_next_page: true, and following its next_cursor returned an empty page. A flow that follows has_next_page to the end (as ours does, which is the safe choice because pages can hold fewer than 20 posts when non-post items are filtered out) pays one extra 15-credit minimum on every poll that found something. The table includes that request; without it, the 15-minute esp32 figure would be $1.89 instead of $2.32.

The 60-second overlap adds re-read posts on top: about $0.38 per 30 days for esp32 at 5 minutes and $0.01 for node-red. At a 1-minute interval the overlap equals the interval, so every post is read twice; shrink OVERLAP to 20 or 30 seconds if you poll that often.

Against the official X API. X's pay-per-usage rate card lists $0.005 per post read, with a resource read twice in the same UTC day charged once. For the esp32 search, about 420 posts a day is roughly 12,600 posts in 30 days: about $63 in post reads on X, against about $1.89 for the same posts here plus the poll floor shown above. Per 1,000 posts that is $5 against $0.15, about 33x. X's rate card also needs an X developer app and OAuth credentials; the flow above needs only an API key.

Grouped bar chart of estimated USD per 30 days for six keyword pollers at 1, 5, 15 and 60 minute intervals, with a dashed line at the $6.48 floor for 1-minute polling.
Estimated cost per 30 days of one keyword poller, by interval. Includes the trailing empty page per non-empty poll. Collected in 2026.
07 — Section

Sending new posts onward: MQTT, Dashboard and Telegram

Because output 1 emits one message per post with a plain object payload, the rest of the flow is ordinary Node-RED wiring.

MQTT. The mqtt out node publishes each post to x/search/node-red with QoS 1. Per the node's help text, an object payload is converted to a JSON string before it is sent, and a blank topic in the node means msg.topic is used, which the dedupe node sets. Any subscriber on the broker (a Home Assistant automation, a microcontroller with a display, a logging service) gets the post within the polling interval. If you watch several keywords, give each its own topic, for example x/search/<keyword>.

Dashboard or a log. Feed the same output into a template or table widget, or into a file node that appends one JSON line per post. Because the payload already holds url, a dashboard link is one field away.

Telegram or Discord. Add a change node that builds the chat message (author, text, url) and a second http request node that POSTs to the bot or webhook URL. Mind the http request help note: when two http request nodes sit in one path, the first one's response headers end up in msg.headers, so reset msg.headers to {} before the second request. Our Telegram bot guide covers the Bot API side.

Filter before you forward. In our sample, 39% to 50% of matching posts per keyword were replies and 30% to 38% carried a photo or video. If you only want original posts, add -filter:replies to KEYWORD: filtering in the query is cheaper than filtering in Node-RED, because posts you drop downstream are still returned and billed.

Watching accounts instead of a keyword. Put from:account1 OR from:account2 in KEYWORD. The same dedupe and paging logic applies; the search syntax is documented in our advanced search API guide.

08 — Section

When to push instead of poll

Polling is the right default for Node-RED because the flow runs behind your router and needs no public URL. Its limits are latency (half the interval on average) and the empty-poll floor shown above.

If you need posts within seconds, TwitterAPI.io also offers filter rules (/oapi/tweet_filter/add_rule) that deliver matching posts to a webhook URL you register. In Node-RED that receiver is an http in node plus an http response node, and it has to be reachable from the internet (a reverse proxy or a tunnel in front of Node-RED, with HTTPS). That is more setup and more exposure than a timer, so it pays off mainly for busy queries where alerts must be immediate; our webhooks guide covers the rule format and delivery.

A middle path: keep the polling flow, but drive the Inject node from a schedule (for example every 2 minutes during your working hours and every 30 minutes at night) using two Inject nodes with the cron-style "interval between times" option. Per the Node-RED docs, those cron options align to the clock rather than to deploy time.

09 — Section

How we collected this

Question. If a Node-RED flow polls X search on a fixed Inject interval, how many polls come back empty, how many posts does each poll return, how often does one poll need a second page, and what does that cost per day?

Queries. Six advanced_search queries with queryType=Latest and retweets excluded: ("node-red" OR nodered), mqtt, "home assistant", esp32, arduino and "raspberry pi".

Window and sample. One fixed 24-hour UTC window bounded with since_time: and until_time:, collected in 2026. 54 requests returned 939 posts, deduplicated by id; the collection cost about $0.14 at list price. For esp32 and raspberry pi the search's pagination ended before reaching the start of the window (10.3 and 21.0 hours covered), so those two keywords were simulated over the covered span only and their per-day figures are scaled estimates.

Method. A fixed-cadence poller was replayed offline over the real createdAt timestamps: polls fire every 60, 300, 900 or 3,600 seconds from the window start and each poll returns the posts created since the previous one. Costs apply the price rules above: 15 credits per post, 15 credits minimum per request, one trailing empty page per non-empty poll.

What the sample cannot show. One day is one day: weekends, launches and news events change volumes. The replay assumes a post is searchable the moment it is created; real indexing takes a little time, which is why the flow overlaps its windows by 60 seconds. The study does not measure delivery latency or how many matching posts X search does not return at all.

Privacy. Keyword searches return posts by private individuals, so the raw pages were kept out of the repository. Only aggregates and de-identified rows (keyword, minute in the window, reply / media / quote flags, language) were kept, with no ids, text or account names.

python
"""pick_interval.py - measure how busy an X (Twitter) search is before you set the
Node-RED Inject interval, then estimate what each interval would cost.

    pip install requests
    export TWITTERAPI_KEY=...        # from https://twitterapi.io/dashboard
    python pick_interval.py '"home assistant" -filter:retweets'
"""
import os
import sys
import time
from datetime import datetime

import requests

BASE = "https://api.twitterapi.io"
HEADERS = {"X-API-Key": os.environ["TWITTERAPI_KEY"]}
USD_PER_CREDIT = 1 / 100_000
PER_POST = 15   # credits per post returned
MIN_CALL = 15   # credits for a request that returns nothing


def fetch_window(query, since, until, max_pages=30):
    """All posts matching `query` created between two Unix times, newest first."""
    created, cursor = {}, ""
    for _ in range(max_pages):
        r = requests.get(
            f"{BASE}/twitter/tweet/advanced_search",
            headers=HEADERS,
            params={
                "query": f"{query} since_time:{since} until_time:{until}",
                "queryType": "Latest",
                "cursor": cursor,
            },
            timeout=30,
        )
        r.raise_for_status()
        page = r.json()
        tweets = page.get("tweets", [])
        for t in tweets:
            created[t["id"]] = datetime.strptime(
                t["createdAt"], "%a %b %d %H:%M:%S %z %Y").timestamp()
        if not page.get("has_next_page") or not tweets:
            break
        cursor = page["next_cursor"]
        time.sleep(1)  # fixed pacing between pages
    return sorted(created.values())


def simulate(times, start, end, interval):
    """New posts returned by each poll of a fixed timer (same logic as the flow)."""
    polls, i, t = [], 0, start + interval
    while t <= end:
        n = 0
        while i < len(times) and times[i] <= t:
            n += 1
            i += 1
        polls.append(n)
        t += interval
    return polls


def credits_for(polls):
    # empty poll: one minimum; non-empty poll: 15 per post + the trailing empty page
    return sum(MIN_CALL if n == 0 else PER_POST * n + MIN_CALL for n in polls)


if __name__ == "__main__":
    query = sys.argv[1] if len(sys.argv) > 1 else '("node-red" OR nodered) -filter:retweets'
    until = int(time.time()) // 3600 * 3600   # last full hour
    since = until - 6 * 3600                  # look back 6 hours
    times = fetch_window(query, since, until)
    hours = (until - since) / 3600
    print(f"{len(times)} posts in {hours:.0f} h = {len(times) / hours:.1f} per hour")
    for interval in (60, 300, 900, 3600):
        polls = simulate(times, since, until, interval)
        empty = sum(1 for n in polls if n == 0) / len(polls)
        usd_30d = credits_for(polls) * (24 / hours) * 30 * USD_PER_CREDIT
        print(f"every {interval // 60:>2} min: {empty:6.1%} empty polls, "
              f"max {max(polls)} new in one poll, about ${usd_30d:.2f} per 30 days")

Researching this?Free starter credits cover end-to-end testing — Google sign-in, no card. Get a key.

10 — Questions

Questions readers ask

Does node-red-node-twitter still work?

Not for new flows. The npm package is deprecated with the message "No longer maintained", its last release (1.2.0) is from March 14, 2021, and its keyword search mode uses the v1.1 statuses/filter stream that X deprecated on March 14, 2023. It also needs OAuth 1.0a keys from a paid X developer app. Use the core http request node with a REST search endpoint instead, as in the flow on this page.

Do I need an X developer account or OAuth keys for this Node-RED flow?

No. Reading public posts through TwitterAPI.io needs only an API key sent in the X-API-Key header; no X account is needed. Set it as the TWITTERAPI_KEY environment variable and the Function node reads it with env.get().

How often should the Inject node poll for new tweets?

Match it to how often the keyword is posted. In our study a quiet keyword (6 posts a day) was empty in 93.8% of 15-minute polls, so 15 to 60 minutes is enough; keywords with a few hundred posts a day were rarely empty at 15 minutes and about a third empty at 5 minutes. Faster than that mostly buys empty polls at $0.00015 each.

How do I stop duplicate tweets after Node-RED restarts?

Store the dedupe state in persistent context. Set contextStorage in settings.js to the localfilesystem module; per the Node-RED docs it writes context under ~/.node-red/context/ every 30 seconds. The flow keeps sinceTime and a capped seenIds list there, so after a restart it resumes where it stopped instead of replaying the last hour.

What does a Node-RED Twitter monitor cost to run?

With TwitterAPI.io, $0.15 per 1,000 posts returned and a $0.00015 minimum per request. In our study one keyword poller cost about $6.50 to $8.40 per 30 days at a 1-minute interval and $0.46 to $2.32 at 15 minutes, including one trailing empty page per non-empty poll. Current plans and credits are on the pricing page.

Can Node-RED post tweets, not just read them?

Yes, through an authenticated session. One /twitter/user_login_v2 login ($0.10, with a proxy you supply) returns login_cookies, and POST /twitter/create_tweet_v2 with login_cookies, tweet_text and proxy then posts as that account at 60 credits ($0.0006) per successful call; calls that return status: error are not charged. The call acts as that account, so X can rate-limit, lock or suspend it; keep a normal human pace, and expect the session to need a re-login at times.

Is there a maintained Node-RED node for X API v2?

We did not find one. An npm search this year returned only older packages: node-red-contrib-twitter (2016, marked no longer supported), node-red-contrib-twitter-stream (2019) and node-red-twitter (2017). The core http request node calling a REST API is the dependable route.

Why does the flow sometimes make one more request than it needs?

Because search pages can report has_next_page: true on the last page that holds posts. In all six of our study searches, following that cursor returned an empty page, which is billed the 15-credit minimum. The flow stops as soon as a page comes back empty, so the extra cost is one minimum per poll that found posts.

11 — Further reading

Continue

Sources & further reading
More from this series

Writing about something you built with TwitterAPI.io? Our community rewards program pays API credits for honest tutorials, build logs and videos.

Build it

Stop reading. Start building.

Starter credits cover real testing on real data. Google sign-in, no card, no application queue.

Get an API key

Already building with TwitterAPI.io? Publish an honest tutorial or build log about it and earn up to $200 a month in API credits.