Giter VIP home page Giter VIP logo

twitter-api-demo's Introduction

Twitter API Code Example

Quick API Note

Due to limitations of existing NodeJS Twitter API implementations (such as not being able to use premium search features like non-truncated text and 100+ results) some of the tweets may look incorrect due to truncated text.

Before you begin

You will need Twitter application credentials, as I did not upload my application credentials to github. Instructions are below in an npm script to run this project locally or you can visit http://167.99.63.15 where I've spun up a droplet to see the project in action.

Setup

To set up this project, you need to have NodeJS >= 10.0 and Yarn installed (although NPM may be used in place of Yarn, and run the simple command of yarn or yarn install.

Running the project

The project is divided into two sections: server and client. The client is the base-level project, with a server directory used to connect to the twitter API via OAuth2 and do server side object creation for the word count statistics.

  1. To run the server, create a new terminal instance inside the root directory, and run the following command. Due to the recommended Twitter library used, we have to declare all keys as ENV variables. This will spawn a file watcher and http server in case you would like to live-edit server code.
  • $ twitterConsumerKey=YOUR_CONSUMER_KEY twitterConsumerSecret=YOUR_CONSUMER_SECRET twitterAccessToken=YOUR_ACCESS_TOKEN twitterAccessTokenSecret=YOUR_ACCESS_SECRET npx nodemon server
  1. In a new terminal tab, pane, or instance, run the yarn start command to start the client in a similar live-reload server situation. This will open a new tab in your primary browser with the project.

Usage

You can toggle between the list of most used words and tweets by pressing the button in the upper right of the screen. You can also update the hashtag searched via the input at the top, this functionality is to make up for the not-so-hot design I've implemented, hopefully.

Running tests

To run basic tests in Jest with a spawned watcher, run yarn test. To generate a coverage report, run yarn test --coverage.

twitter-api-demo's People

Contributors

tommymcdonald avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.