Giter VIP home page Giter VIP logo

twitter-rest-api-server's Introduction

A prototype of twitter restful API server, copied from @igorlima.

This repo is a public HTTP API to retrieve Twitter user timelines. It has basically two files: server.js and twitter.js.

The first file creates an basic instance of express and defines a route for a GET request method, which is /twitter/timeline/:user.

The second one is a module responsible for retrieving data from Twitter. It requires:

  • twit: Twitter API Client for node
  • async: is a utility module which provides straight-forward, powerful functions for working with asynchronous JavaScript
  • moment: a lightweight JavaScript date library for parsing, validating, manipulating, and formatting dates.

Part of these modules will be mocked and overridden in our tests.

Running the example

This example is already running in a cloud. So you can reach the urls below and see it working:

To run it locally, clone this gist by git clone https://gist.github.com/b31f1a26a5b100186a98.git twitter-rest-api-server and set five environment variables. Those envs are listed below. For secure reason I won't share my token. To get yours, access Twitter developer documentation, create a new app and set up your credentials.

For Mac users, you can simply type:

export TwitterConsumerKey="xxxx"
export TwitterConsumerSecret="xxxx"
export TwitterAccessToken="xxxx"
export TwitterAccessTokenSecret="xxxx"
export MomentLang="pt-br"

For Windows users, do:

SET TwitterConsumerKey="xxxx"
SET TwitterConsumerSecret="xxxx"
SET TwitterAccessToken="xxxx"
SET TwitterAccessTokenSecret="xxxx"
SET MomentLang="pt-br"

After setting up the environment variables, go to twitter-rest-api-server folder, install all node dependencies by npm install, then run via terminal node server.js. It should be available at the port 5000. Go to your browser and reach http://localhost:5000/twitter/timeline/igorribeirolima.

running express app example locally

twitter-rest-api-server's People

Contributors

igorlima avatar ruanyf avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

kevinyzy

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.