How to Incorporate Twitter Functionality into Your Node.js App

If you incorporated Twitter sign in functionality according to https://medium.com/@hohanga/how-to-add-twitter-sign-in-to-your-node-js-back-end-with-angular-app-as-the-front-end-d90213f95703, then it is very easy to incorporate Twitter functionality into your app by calling the Twitter API. To get the consumer key and secret, and find out how to get the OAuth access token and secret from Twitter which you will use with the Twitter API, follow https://medium.com/@hohanga/how-to-add-twitter-sign-in-to-your-node-js-back-end-with-angular-app-as-the-front-end-d90213f95703

Once you have the OAuth access token and secret, calling Twitter API is a piece of cake. For Node.js, I had success with https://www.npmjs.com/package/twit.

You simply pass in whatever credentials are requested to build the Twit object, which allows you to call the Twitter API.

Once that is done, you can do many things which otherwise has to be done manually.

According to https://www.npmjs.com/package/twit, here are the endpoints that it can call:

  • GET ‘statuses/update’
  • GET ‘search/tweets’
  • GET ‘followers/ids’
  • GET ‘account/verify_credentials’
  • POST ‘statuses/retweet/:id’
  • POST ‘statuses/destroy/:id’
  • GET ‘users/suggestions/:slug’
  • POST ‘media/upload’
  • ‘media/metadata/create’
  • ‘statuses/filter’

All the basic functionality like tweeting, uploading photos, and streaming can be used with this library, which means that you can automate tweeting and getting data from your account.

The full list of endpoints are at https://developer.twitter.com/en.html

Image for post
Image for post

Written by

Web developer. Subscribe to my email list now at http://jauyeung.net/subscribe/. Email me at hohanga@gmail.com

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store