Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

tweetserver

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tweetserver

A server to proxy and cache requests to the Twitter v1.1 REST API

  • 0.0.6
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
8
increased by700%
Maintainers
1
Weekly downloads
 
Created
Source

TweetServer

TweetServer is a simple Node.js app for querying and caching responses from the Twitter REST API (version 1.1). It runs as a standalone server (built on Express) and effectively proxies any requests over to the API.

Why should you use it?

  • It handles the Twitter API rate limits for you, ensuring that the returned data is as up-to-date as possible without getting your application blacklisted for making too many requests.

  • It means you can communicate with the API from your front-end JavaScript with AJAX. This is difficult with the latest (1.1) version of the API since almost all requests have to be authenticated.

  • You can use it to display Tweets in your own style, rather than having to use one of the pre-built Twitter widgets.

  • Supports JSONP so you should be able to run your server anywhere and still make AJAX requests to it.

Setup

TweetServer is available as through npm. That's the recommended method of installation. Just install it as a global module:

npm install -g tweetserver

Configuration

TweetServer assumes you already have a Twitter application. If you don't, you can easily create one.

You'll need various credentials from Twitter to setup your Tweet Server. They can be found on the details page for the Twitter application you want to use. Sign in at the URL linked to above and make a note of your consumer key, consumer secret, access token and access token secret.

TweetServer will look for a configuration file on startup. Create a file named .tweetserverrc in your home directory, or the directory to which TweetServer was installed (any of the parent directories, including the root directory, will work too).

The .tweetserverrc file contains simple JSON in the following format:

{
    "port": 1234,
    "auth": {
        "accessToken": "xxxxx",
        "accessSecret": "xxxxx",
        "consumerKey": "xxxxx",
        "consumerSecret": "xxxxx"
    }
}

If you'd prefer not to store your API keys in a file, you can also specify them at startup with the following command line arguments:

Short optionLong optionValue
-k--access-tokenYour Twitter API access token
-a--access-secretYour Twitter API access token secret
-c--consumer-keyYour Twitter API consumer key
-s--consumer-secretYour Twitter API consumer secret
-p--portThe port on which the server will run

If you specify command line arguments and have a configuration file, the command line arguments will override the configuration file. You can run the server with any number of the arguments.

Running the server

If you installed TweetServer via npm with the -g (global) option, you will have a tweetserver command available to you. Just run that from anywhere (optionally with any of the command line arguments detailed above) to start the server:

tweetserver

You will see a message that tells you the server is now running. At this point you'll be able to open a browser and check that everything's working properly. Assuming your Tweet Server is running on localhost on port 3456 (which is the default), you can visit:

http://localhost:3456/statuses/user_timeline?screen_name=james_allardice

If you've used the Twitter API much before, you may have noticed that everything after the port in that URL is simply the same as what you would usually use when calling the API directly. Currently, all Twitter API v1.1 methods that support HTTP GET requests are supported.

Keeping the server running

I highly recommend using the brilliant "forever" module to keep your server up and running all the time.

Keywords

FAQs

Package last updated on 03 Feb 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc