Node.js

Free Node.js Twitter bot hosting.

twitter-api-v2 or plain fetch. Upload a package.json, name your entry file, and your bot posts on schedule around the clock.

Our hosting is free. X's API mostly is not.

Everything on this page is about running your bot here, which costs nothing. What your bot is allowed to do on X is set by X's API tiers, and the free one is small and mostly about posting. Reading mentions, timelines or search needs a paid tier bought from X, whatever host you use. Check the current tiers in X's developer portal before you build a bot that replies to people.

Tools that avoid the API by logging in as a normal user and scraping the site break whenever the site changes and get accounts suspended. We will not stop you running one within our acceptable use policy, and we do not recommend it: an account lost that way is lost, and we accept no responsibility for it.

Libraries

Libraries that run here

twitter-api-v2

The established Node client for X's API, with TypeScript types, OAuth 1.0a and 2.0, and media upload. For a posting bot it is a constructor and one call.

Plain fetch

Possible, and not recommended for OAuth 1.0a: every request has to be signed, and getting the signature exactly right is the part a library exists for.

Deploying

Getting it running

  1. 1

    Upload your project

    Drag the folder into the file manager or push it over SFTP. Leave node_modules behind: it is installed for you on deploy.

  2. 2

    Dependencies install themselves

    Your package.json is read and installed before the bot starts. A posting bot's dependency tree is small.

  3. 3

    Point us at your entry file

    Usually index.js. All four keys come from process.env, so none of them sit in a file.

Memory

What actually fits in 256 MB

A posting bot barely registers. It holds a client object and a timer, and between posts it is idle.

What costs memory is what you post. A bot that renders a chart or an image each time can outgrow the allocation if it launches a headless browser to do it; drawing with a canvas library, or fetching a ready-made image, fits easily.

The other thing worth keeping is a record of what you have already posted, so a restart does not post the same news twice. Keep it in a file on your 512 MB of disk rather than in memory.

FAQ

Questions

Which authentication should I use?

OAuth 1.0a with the access token and secret the developer portal generates for your own account, if the bot posts as you or as one account you own. Those do not expire. Use OAuth 2.0 only if the bot acts for other people, and then store the refresh token on disk.

Can it post images and video?

Images, yes: upload the media first, then attach its ID to the post. Video is heavier to upload and process; keep files small and delete them after posting so they do not fill your 512 MB of disk.

How do I stop duplicate posts after a restart?

Record each item you post, such as a feed entry's ID, in a file before posting it, and check that file first. Your files persist across restarts and crashes.

Do I need to upload node_modules?

No. Upload your source and your package.json and the dependencies install on deploy.