{"id":20786113,"url":"https://github.com/thomassuedbroecker/node-red-twitter-follower","last_synced_at":"2026-03-27T02:16:17.210Z","repository":{"id":127030629,"uuid":"250086578","full_name":"thomassuedbroecker/node-red-twitter-follower","owner":"thomassuedbroecker","description":"This flow covers REST Endpoints, 2 Level Authentication usage of the Twitter API. Paging of REST Endpoint responses.","archived":false,"fork":false,"pushed_at":"2020-04-02T10:03:53.000Z","size":18549,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-12-26T18:48:24.592Z","etag":null,"topics":["endpoint","node-red-flow","paging","twitter-api"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thomassuedbroecker.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-03-25T20:40:11.000Z","updated_at":"2021-04-02T13:37:57.000Z","dependencies_parsed_at":"2023-08-14T20:04:09.810Z","dependency_job_id":null,"html_url":"https://github.com/thomassuedbroecker/node-red-twitter-follower","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/thomassuedbroecker/node-red-twitter-follower","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomassuedbroecker%2Fnode-red-twitter-follower","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomassuedbroecker%2Fnode-red-twitter-follower/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomassuedbroecker%2Fnode-red-twitter-follower/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomassuedbroecker%2Fnode-red-twitter-follower/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thomassuedbroecker","download_url":"https://codeload.github.com/thomassuedbroecker/node-red-twitter-follower/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomassuedbroecker%2Fnode-red-twitter-follower/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31009857,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-27T01:56:05.093Z","status":"online","status_checked_at":"2026-03-27T02:00:08.055Z","response_time":164,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["endpoint","node-red-flow","paging","twitter-api"],"created_at":"2024-11-17T14:50:47.228Z","updated_at":"2026-03-27T02:16:17.182Z","avatar_url":"https://github.com/thomassuedbroecker.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Node-RED Twitter-follower-flow\n\nNode-RED is very good for prototyping, that is the reason why it is often used in hackathons. If you are new to Node-RED and you start to develop a Node-RED flow, you normally have following challenges: \n\n* **How to ...**\n\n  1. ... define own **REST endpoints** to encapsulate an external API?\n  2. ... automate the **authentication** to that external API?\n  3. ... **extract data** from the external API?\n  4. ... **customize data** and **CRUD** with databases? \n\nThe Node-RED flow of that project has the objective to provide an (little advanced) introduction to the first three topics above.\nThe CRUD (Create, Read, Update, Delete) topic that is not covered here. Visit that [CRUD example](https://github.com/gitjps/Node-RED-Cloudant-CRUD) for more information.\n\n* **The \"Twitter-follower-flow\" example ...**\n\n  * ... uses open technologies (Node-RED is a Project of the [OpenJS foundation](https://openjsf.org/)\n\n  * ... creates no additional costs \n    * Uses a free runtime on [IBM Cloud](https://ibm.biz/BdqZTm)\n    * Uses the free [Twitter developer API](https://developer.twitter.com/en)\n\n  * ... has following technical level:\n    * Beginner to intermediate \n    * Needs a basic knowledge of JavaScript and REST\n\n  * ... takes 30 - 45 min to setup the example from scratch\n    1. Register on IBM Cloud \n    2. Create a Node-RED instance on IBM Cloud\n    3. Register at Twitter for a developer API Account \n    4. Copy the existing Node-RED flow\n    5. Configure the flow\n    6. Run the flow\n\nThe YouTube video gives a 13 min introduction to the _Twitter-follower-flow_.\n\n[![Introduction to the Node-RED flow](https://img.youtube.com/vi/4HvBya4Zhn8/0.jpg)](https://www.youtube.com/watch?v=4HvBya4Zhn8 \"Click play on youtube\")\n\n## 1. The UseCase\n\nThe UseCase **_\"Extract the twitter follower list\"_** addresses three topics listed above in the Node-RED _Twitter-follower-flow_.\n\n  1. Define own **REST endpoints** to encapsulate Twitter developer API calls.\n  2. Automate the **authentication** the two step authentication of the Twitter developer API.\n  3. **Extract data** from the Twitter follower list and build an own list.\n\n## 2. Topics related to the Node-RED usage\n\nThe _Twitter-follower-flow_ is an concrete example of following topics ...\n\n * ... the **implementation** of Node-RED REST endpoints.\n\n   1. Create a very basic authentication to protect each Node-RED endpoint\n   2. Realize the two step authentication _(also known as two-factor authentication)_ to access the Twitter developer API:\n        1. Basic authentication with a key and secret to request a bearer token from Twitter\n        2. Use the bearer token for authentication to use the Twitter API \n   3. Get the follower list from Twitter using the bearer token\n\n * ... the **usage** of the implemented REST endpoints to automate following sequence to get the Twitter follower.\n\n   1. Get the **authorization** bearer token from Twitter to access the Twitter API\n   2. Get all followers from Twitter using a **bearer token** ( _the challenge is: how implement the paging thought the followers list from Twitter_ )\n   3. Extract the names of the follower from the follower list\n\n * ... the **work** with following Nodes in the Node-RED _Twitter-follower-flow_.\n\n   1. Function _(Do small programming in javascript.)_\n   2. Inject _(Start a flow in Node-RED.)_\n   3. HTTP _in_ _(Creates an HTTP end-point for creating web services.)_\n   4. HTTP _request_ _(Sends HTTP requests and returns the response.)_\n   5. HTTP _response_ _(Sends responses back to requests received from an HTTP Input node.)_\n   6. Base64 (A function that converts the chosen property (default msg.payload) to and from base64 format.)\n   7. JSON _(Converts between a JSON string and its JavaScript object representation, in either direction.)_\n   8. Switch _(Define a decision how to route the payload. Route messages based on their property values or sequence position.)_\n\n * ... the **usage** of flow variables to exchange values between functions in the _Twitter-follower-flow_.\n\nThe gif shows a execution of the _Twitter-follower-flow_:\n\n![](images/twitter-follower-flow-execution.gif)\n\n---\n\n## 3. Setup the Twitter-follower-flow example \n\nThat section contains six major steps to setup the _Twitter-follower-flow_ example on IBM Cloud. \n\n1. Setup Twitter developer application\n2. Create a Node-RED instance on IBM Cloud\n3. Install a additional Node to the Node-RED instance\n4. Import the Node-RED flow\n5. Configure the Node-RED flow\n6. Introduction to the Node-RED flow (13 min video)\n\nIn the image you see the full flow.\n\n![](images/twitter-follower-flow.png)\n\n---\n\n### Step 1: Setup Twitter developer application\n\nYou need a Twitter account and a Twitter developer application.\nWith your Twitter account can register for the **Twitter developer API** and create a Twitter developer application. That application provides the needed credentials to access the Twitter API, which is used in that example.\n\n#### a. [Link to add a Twitter developer application](https://developer.twitter.com/en/apps). \n\nHere is a blog post with an example how to setup a Twitter application: [How to Register a Twitter App in 8 Easy Steps](https://iag.me/socialmedia/how-to-create-a-twitter-app-in-8-easy-steps/)\n\nHere is a preview, how to get the credentials from your Twitter developer application:\n\n![](images/configure-twitter-auth.png)\n\n#### [b. Twitter API documentation `get-followers-list`](https://developer.twitter.com/en/docs/accounts-and-users/follow-search-get-users/api-reference/get-followers-list)\n\n---\n\n### Step 2: Create a Node-RED instance on IBM Cloud\n\nWe use a Node-RED instance on IBM Cloud with an IBM Lite Account.\n\n1. Create an IBM Cloud Lite Account just by register [here](https://ibm.biz/Bdzr7G).\n2. Follow the steps in my blog post to [setup a Node-RED instance on IBM Cloud](https://suedbroecker.net/2020/03/09/a-short-introduction-of-the-node-red-starter-kit-on-ibm-cloud-for-hackathons/)\n\n---\n\n### Step 3: Install a additional Node to the Node-RED instance\n\nInstall the `node-red-node-base64` **Node** to the Node-RED instance. The gif shows the installation.\n\n![](images/install-node.gif)\n\n---\n\n### Step 4: Import the Node-RED flow\n\nImport the flow from the [flow.json](flows/flows.json) file in `flows` folder of that project. The gif below shows how to import the flow in the Node-RED.\n\n![](images/import-flow.gif)\n\n---\n\n### Step 5: Configure the Node-RED flow\n\nWe need to configure ...\n\n* ... the Twitter authentication \n* ... the Twitter username\n* ... the Node-RED URL \n\n---\n\n#### a. Set Twitter API key and secret\n\nInsert the values for the `user` and `secret` of the Twitter API credentials in the _function_ `set user and secret`. The image shows an example, where you get the credentials information.\n\n![](images/configure-twitter-auth.png)\n\nThe mapping for the Node-RED flow:\n  1. `user` = _Twitter API_ key\n  2. `secret` = _Twitter API_ secret key\n  3. `nodereduser` = Your own definition to secure the Node-RED REST Endpoints\n  4. `noderedpassword` = Your own definition to secure the Node-RED REST Endpoints\n\nHere is the source code for the `set user and secret` function.\n\n```javascript\nvar user = \"USER\";\nvar secret = \"SECRET\"\nvar nodereduser = \"admin\";\nvar noderedpassword = \"notreallysecure\"\n\nflow.set(\"nodereduser\", nodereduser);\nflow.set(\"noderedpassword\", noderedpassword);\n\nmsg.payload = user + \":\" + secret;\n\nreturn msg;\n```\n\n#### b. Set Twitter username\n\nDefine _\"username display name\"_ you want get the follower list from, by inserting \nin function `set_basic_auth` the `\"YOUR_TWITTER_DISPLAY_NAME\"`.\n\n```javascript\n// Set basic auth\nflow.set(\"auth\", msg.payload);\nmsg.payload = flow.get(\"auth\");\n\n// Init parameters:\n// For more information visit get-followers-list:\n// https://developer.twitter.com/en/docs/accounts-and-users/follow-search-get-users/api-reference/get-followers-list\nflow.set(\"twitterCursor\", \"-1\");\nflow.set(\"twitterResultCount\", \"50\");\nflow.set(\"twitterSN\", \"YOUR_TWITTER_DISPLAY_NAME\");\n\nmsg.nodereduser = flow.get(\"nodereduser\");\nmsg.noderedpassword = flow.get(\"noderedpassword\");\n\nreturn msg;\n```\n---\n\n#### c. Set Node-RED URL\n\nConfigure the HTTP request nodes. Replace the `https://node-red-my-hackathon.mybluemix.net` URL with your URL in each _HTTP request node_:\n\n* `getTwitterFollower-Indicrect`\n* `getTwitterToken-Indicrect`\n\nThe image shows how you enter the URL in the _HTTP requests node_ `getTwitterFollower-Indicrect`.\n\n![](images/configure-http-node.png)\n\nThat image shows _HTTP requests nodes_ to be change.\n\n![](images/request-automation-followers-setup.png)\n\n---\n\n### Step 6: Introduction to the Node-RED flow\n\nThe YouTube video gives a 13 min introduction to the _Twitter-follower-flow_.\n\n[![Introduction to the Node-RED flow](https://img.youtube.com/vi/4HvBya4Zhn8/0.jpg)](https://www.youtube.com/watch?v=4HvBya4Zhn8 \"Click play on youtube\")\n\n---\n\n## 4. Understand the content of the _Twitter-follower-flow_\n\n1. Implementation of REST endpoints in the Node-RED\n2. Automation of the flow to get followers from the Twitter API\n\n### 4.1 Implementation of REST endpoints in the Node-RED \n\nThat is the implementation of the REST endpoints in Node-RED _Twitter-follower-flow_. \n\nBoth Node-RED HTTP endpoints encapsulating the invocation of the Twitter API call.\nEach endpoint validates the custom defined `nodeusername` and `noderedpassword`, before they start to send the REST call of the **Twitter API** and provide the result.\n\n* Endpoint _(POST)_: `/getToken` Gets the bearer token from the Twitter API and saves the token in a flow variable.\n* Endpoint _(GET)_: `/followers` Does the authorization with the bearer token and gets a follower list for a _user display name_ in a _page size_ of 50 entries.\n\n![](images/request-endpoints.png)\n\nThat is a simplified view of the combination of the _Node-RED Nodes_ **\"HTTP in\"**, **HTTP request** and **HTTP response** to implement the REST endpoints.\n\n![](images/request-encapsulate.png)\n\n---\n\n##### 4.1.1 Endpoint to request the followers\n\nThis endpoint does encapsulate the invocation of the external Twitter API call `followers/list`. The Node-RED endpoint very basiclly secured with a `noderedusername` and a `noderedpassword`. Only when the simple verification was successful, the Twitter API call can be invoked. The Twitter API invocation is done with authorization of the bearer token and gets a follower list for a user display name in a page size of 50 entries. The image shows the endpoint. \n\n![](images/request-followers.png)\n\n**Endpoint (GET):** `/followers` That endpoint has following query parameters:\n* `screen_name`\n* `count`\n* `cursor`\n* `nodereduser`\n* `noderedpassword`\n\n```javascript \n\n  //https://[YOUR NODE_RED URL]/followers?screen_name={{twitterSN}}}\u0026count={{{twitterCount}}}\u0026cursor={{{twitterCursor}}}\u0026nodereduser={{{nodereduser}}}\u0026noderedpassword={{{noderedpassword}}}\n\n```\n\nThis is the **Twitter API** invocation in the HTTP node `Request twitter follower list`, when the simple user validation was successful.\n\n```javascript\n\n  //https://api.twitter.com/1.1/followers/list.json?screen_name={{{twitterSN}}}\u0026cursor={{{twitterCursor}}}\u0026count={{{twitterCount}}}\n\n```\n\n##### a. Function node: `set bearer auth headers and parameters`\n\nThat function Node verifies the `nodereduser`/`noderedpassword` input of the HTTP request and loads the flow variable `bearer_token` and collects the query parameter `screen_name`, `cursor`and `count` for the Twitter API endpoint invocation.\n\n```javascript\n// validate the request user and password\nif ( msg.payload.nodereduser === flow.get(\"nodereduser\") \u0026\u0026 msg.payload.noderedpassword === flow.get(\"noderedpassword\")){\n \n    // Get variables\n    bearer_token = flow.get(\"bearer_token\");\n     \n    msg.headers = {\n         'Authorization' : bearer_token\n    }\n    \n    // Get query parameter\n    msg.twitterSN =  msg.req.query.screen_name;\n    msg.twitterCursor =  msg.req.query.cursor;\n    msg.twitterCount =  msg.req.query.count;\n    \n    msg.valid_request = 1;\n  \n} else {\n    msg.valid_request = 0;\n}\n  \nreturn msg;\n```\n\n---\n\n#### 4.1.2 Endpoint to request the bearer token from twitter\n\nThis endpoint does encapsulate the invocation of the external Twitter API call `getToken`. To secure the Node-RED endpoint very basiclly it validates a `nodereduser` and `noderedpassword`. The Twitter API endpoint itself is secured by a basic authentication with a _Twitter key_ and _secret_. The `getToken` call requests the bearer token from the Twitter API and saves the token in a flow variable. The Twitter API provides the `getToken` endpoint. \nThe image shows the endpoint.\n\n![](images/request-bearer-token.png)\n\n* Flow endpoint (POST): `/getToken`\n* Twitter API request: `https://api.twitter.com/oauth2/token`\n\nLet's get a deeper look in the function implementation.\n\n* Function: `set header with bearer token`\n\nIn the `set header with bearer token` function, we load the base64 encoded `auth` string and we configure the HTTP `auth` header for the Twitter API request.\n\n```javascript\n// validate the request user and password\nif ( msg.payload.nodereduser === flow.get(\"nodereduser\") \u0026\u0026 msg.payload.noderedpassword === flow.get(\"noderedpassword\")){\n  \n  msg.headers = {\n     'Authorization' : 'Basic ' + flow.get(\"auth\"),\n     'Content-Type' : 'application/x-www-form-urlencoded;charset=UTF-8.'\n  };\n  \n  msg.payload = 'grant_type=client_credentials';\n  msg.valid_request = 1;\n  \n} else {\n  msg.valid_request = 0;\n}\n  \nreturn msg;\n```\n\n---\n\n### 4.2 Automation of the flow to get followers from the Twitter API\n\nIn this part of the flow we fully automate the authentication and extraction of the follower data.\n\nWe start that flow simply with pressing the _Inject Node_ `start get follower list` button. That is the simplified sequence we use:\n\n   1. Get the **authorization** bearer token from Twitter to access the Twitter API\n   2. Get all followers from Twitter using the **bearer token** ( _the challenge is: how implement the pageing thought the followers list from Twitter_ )\n   3. Extract the names of the follower from the follower list\n\n_Remember:_ The authorization for the Twitter API needs a two step Authentication and we protect the Node-RED REST endpoints with a simple authenication. \n\nThe image displays the relevant part of the flow.\n\n![](images/request-automation-followers-and-save-in-db.png)\n\nThat are the different main chapters of the automation.\n\n   1. Get bearer token from Twitter to access the Twitter API\n   2. Load and build the follower list from Twitter\n   3. Verify the end of follower list\n   4. Build the final followers list\n\n---\n\n#### 4.2.1 Get bearer token from Twitter to access the Twitter API\n\nThe image displays the relevant part of the flow.\n\n![](images/request-followers-get-token.png)\n\nLet's get a deeper look in the function implementations.\n\n##### a. Function node: `set_basic_auth`\n\nIn that function we set the following flow variables to prepare the `auth` for the Twitter API token request.\n\n * `auth` EncodedBase64 user and secret combination.\n * `twitterCursor` The page position of for the followers list.\n * `twitterResultCount` The response size of the followers for one page. \n * `twitterSN` Define the Twitter user name for the followers list.\n * `noderedusername` \n * `noderedpassword` \n\n```javascript\n// Set basic auth\nflow.set(\"auth\", msg.payload);\nmsg.payload = flow.get(\"auth\");\n\n// Init parameters:\n// For more information visit get-followers-list:\n// https://developer.twitter.com/en/docs/accounts-and-users/follow-search-get-users/api-reference/get-followers-list\nflow.set(\"twitterCursor\", \"-1\");\nflow.set(\"twitterResultCount\", \"50\");\nflow.set(\"twitterSN\", \"YOUR_USER_DISPAYNAME\");\n\n// Set basic auth\nflow.set(\"auth\", msg.payload);\nmsg.payload = flow.get(\"auth\");\nmsg.noderedusername = flow.get(\"noderedusername\");\nmsg.noderedpassword = flow.get(\"noderedpassword\");\n\nreturn msg;\n```\n\n##### b. Function: `set_bearer_token`\n\nIn that function we do the initailization of the following flow variables:\n\n* `bearer_token` \n* `savedFollowers` \n\n```javascript\n// Set token before loop\nflow.set(\"bearer_token\", \"Bearer \" + msg.payload.access_token);\nvar followers = [];\n// Init the follower list for the flow\nflow.set(\"savedFollowers\", followers)\n\nreturn msg;\n```\n\n##### c. Function: `set twitter user and page cursor`\n\nIn that function we prepare the needed values of the parameters for the _HTTP request_ of the endpoint `/followers`: \n\n```javascript\n\n//https://YOU_NODE_RED_URL/followers?screen_name={{{twitterSN}}}\u0026count={{{twitterCount}}}\u0026cursor={{{twitterCursor}}}\u0026nodereduser={{{nodereduser}}}\u0026noderedpassword={{{{noderedpassword}}}\n\n```\n\nThe function source code:\n\n```javascript\n// Set the tweeter request query parameter before the loop\n\n// Data is used in the REST request \n// (Issue Twitter API REST Request (GET))\n// -----------------------------------------------------------------------\n// https://api.twitter.com/1.1/followers/list.json?\n//   screen_name={{{twitterSN}}}\u0026\n//   cursor={{{twitterCursor}}}\u0026\n//   count={{{twitterCount}}}\u0026\n//   nodereduser={{{nodereduser}}}\u0026\n//   noderedpassword={{{{noderedpassword}}}\n\n// For more information visit get-followers-list:\n// https://developer.twitter.com/en/docs/accounts-and-users/follow-search-get-users/api-reference/get-followers-list\nmsg.payload = flow.get(\"bearer_token\")\n\n// Prepare the get follower request parameter\nmsg.twitterCursor = flow.get(\"twitterCursor\");\nmsg.twitterCount = flow.get(\"twitterResultCount\");\nmsg.twitterSN = flow.get(\"twitterSN\");\n\nmsg.nodereduser = flow.get(\"nodereduser\");\nmsg.noderedpassword = flow.get(\"noderedpassword\");\n\nreturn msg;\n```\n\n---\n\n#### 4.2.2 Load and build the follower list from Twitter\n\n![](images/request-followers-invoke-request.png)\n\nLet's get a deeper look in the function implementations.\n\n##### a. Function: `build follower list`\n\nThat function loads the existing follower list from the flow variable `savedFollowers` and add the new followers from the current response to that list.\n\n```javascript\nif (msg.payload.errors !== undefined ){\n    if (msg.payload.errors[0] !== undefined ){\n        // do nothing\n    }\n} else {\n    flow.set(\"twitterCursor\", msg.payload.next_cursor);\n\n    // load the exiting list from the flow variable to be saved later in the Cloudant database\n    var savedFollowers  = [];\n    savedFollowers = flow.get(\"savedFollowers\");\n    \n    var users = [];\n    // load the response data from the twitter request users\n    users = msg.payload.users;\n\n    // build the customized follower list \n    var follower = {};\n    for (var i=0; i\u003c50; i++){\n        \n       if( users[i] !== undefined) {\n         follower.username = users[i].name;\n         follower.screen_name = users[i].screen_name;\n         savedFollowers.push(follower);\n         follower = {};\n       } else {\n           i = 50;\n       }\n    }   \n    flow.set(\"savedFollowers\",savedFollowers);\n    followers = [];\n}\n\nreturn msg;\n```\n\n#### 4.2.3 Verify the end of follower list\n\nThe **switch** verifies the `payload.next_cursor` value, if it is null or not. If the `payload.next_cursor` is not null, that indicates that more followers can be loaded from the next page of the follower list. With that we need to trigger the start of the Twitter API request for the next follower page.\n\nIn that example the follower page size is **50** and it invokes the  function `set twitter user and page cursor` to start once again with the load of the next page.\n\nThe image displays the relevant part of the flow.\n\n![](images/request-verify-followers-end.png)\n\nLet's get a deeper look in the function implementations.\n\n##### a. Function `move on`: Start of the next load of a page.\n\n```javascript\nmsg.payload.message = \"move on - next page\";\nreturn msg;\n```\n\n##### b. Function `end`: End the paging and start to build the final follower list.\n\n```javascript\nmsg.payload.message = \"end, no additional followers\";\nreturn msg;\n```\n\n#### 4.2.4 Build the final followers list\n\n![](images/request-build-follower-list.png)\n\n* Function `build followers name list`\n\nThat function uses the extracted followers in the flow variable `savedFollowers` and builds a new follower list. It also adds data to new follower list:\n\n* date\n* time\n* follower count.\n\nThat is the JSON format of the new follower list.\n\n```json\n{\n  \"twitterFollowers\": {\n    \"date\": \"2020.3.20\",\n    \"time\": 1584691605226,\n    \"count\": 2,\n    \"followers\": [\n      {\n        \"username\": \"user1\",\n        \"screen_name\": \"user1\"\n      },\n      {\n        \"username\": \"user2\",\n        \"screen_name\": \"user2\"\n      }]\n  }\n}\n```\n\nThis is the code of the function `build followers name list`.\n\n```javascript\nvar savedFollowers = [];\n    savedFollowers = flow.get(\"savedFollowers\");\n    \nvar data = {};\nvar twitterFollowers = {}; \n\nvar date = new Date();\n\ntwitterFollowers.date = date.getFullYear() + \".\" + \n            (date.getMonth() + 1) + \".\" + \n            date.getDate();\ntwitterFollowers.time = date.getTime(); \ntwitterFollowers.count = savedFollowers.length; \n            \ntwitterFollowers.followers = savedFollowers;\ndata.twitterFollowers = twitterFollowers;\n\n\nvar reset = [];\nflow.set(\"followers\", reset);\nflow.set(\"savedFollowers\", reset);\n\nmsg.payload = data;\n\nreturn msg;\n```\n\n---\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthomassuedbroecker%2Fnode-red-twitter-follower","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthomassuedbroecker%2Fnode-red-twitter-follower","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthomassuedbroecker%2Fnode-red-twitter-follower/lists"}