npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

bacon-and-eggs

v0.1.11

Published

A functional reactive Twitter API client in node

Downloads

55

Readme

#bacon-and-eggs

NPM

NPM version Build Status

A functional reactive Twitter API client in node.

Install

$ npm install bacon-and-eggs

Use

The following shows how to use BaconAndEggs can be used to connect to a Twitter API stream. In this example we connect to the statuses_filter stream and look for public tweets containing the string 'funny'.

creds =
  key: process.env.TWITTER_USER_KEY
  secret: process.env.TWITTER_USER_SECRET
  token:  process.env.TWITTER_USER_TOKEN
  tokenSecret:  process.env.TWITTER_USER_TOKEN_SECRET

request = BaconAndEggs.requestStatusesFilterStreaming { track: 'funny' }

stream = BaconAndEggs.toEventStream(creds, request)

stream.log()

API

Bacon

#####Description: The baconjs library used by BaconAndEggs. It is highly recommended that you use this rather than require your own version of baconjs to avoid conflicts.

toEventStream(creds, method, resource, params)

#####Description: Returns a bacon.js EventStream containing JSON responses from the Twitter REST API. See the bacon.js documentation for a list of methods that can be applied to a bacon.js EventStream.

#####Arguments: creds - An object containing the keys 'key', 'secret', 'token', 'token_secret' with values being your API key, secret, token, and token secret. If needed, API credentials can be obtained from the twitter app manager.

method - The HTTP method ('get', 'put', 'post', or 'delete')

resource - The REST API resource (e.g. 'user', 'followers/ids', etc)

params (optional) - Request parameters.

toEventStream(creds, streamingEndpoint, params)

#####Description: Returns a bacon.js EventStream containing JSON responses from the one of the Twitter Streaming APIs (indicated by the streamingEndpoint parameter). See the bacon.js documentation for a list of methods that can be applied to a bacon.js EventStream.

#####Arguments: creds - An object containing the keys 'key', 'secret', 'token', 'token_secret' with values being your API key, secret, token, and token secret. If needed, API credentials can be obtained from the twitter app manager.

streamingEndpoint - A BaconAndEggs Streaming Endpoint (see Streaming Endpoints below).

params (optional) - Request parameters.

Streaming Endpoints

The streaming endpoints below define the set of streaming API endpoints available to us via Twitter.

BaconAndEggs.TWITTER_STREAMING_API_GET_USER - GET user.

BaconAndEggs.TWITTER_STREAMING_API_GET_SITE - GET site.

BaconAndEggs.TWITTER_STREAMING_API_GET_STATUSES_SAMPLE - GET statuses/sample.

BaconAndEggs.TWITTER_STREAMING_API_GET_STATUSES_FIREHOSE - GET statuses/firehose.

  • Note: This endpoint requires special permission to access.

BaconAndEggs.TWITTER_STREAMING_API_POST_STATUSES_FILTER - POST statuses/filter.

  • Note: At least one param (follow, locations, or track) must be specified in the POST body.

Examples

Examples are included in the examples folder.

The examples can be ran via the following (replace <example.coffee> with the name of the example to run).

gulp compile && coffee examples/<example.coffee> --n

The examples use a few environment variables to load the Twitter API credentials. i.e.

creds =
  key: process.env.TWITTER_USER_KEY
  secret: process.env.TWITTER_USER_SECRET
  token:  process.env.TWITTER_USER_TOKEN
  token_secret:  process.env.TWITTER_USER_TOKEN_SECRET

Prior to running the examples, either export your twitter key, secret, token, and token_secret via the command line OR put a .env file at the root of the project with the values to be exported.

Example .env file:

TWITTER_USER_KEY=YOUR-USER-KEY-HERE
TWITTER_USER_SECRET=YOUR-USER-SECRET-HERE
TWITTER_USER_TOKEN=YOUR-USER-TOKEN-HERE
TWITTER_USER_TOKEN_SECRET=YOUR-USER-TOKEN-SECRET-HERE

License

MIT © Mike Groseclose