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

vogel

v0.0.7

Published

Straight-forward Twitter API client with OAuth support

Downloads

4

Readme

Vogel

Straight-forward Twitter API client with full OAuth support (Bearer, PIN and 1.0a)

Installation

npm install --save vogel

yarn add vogel

Usage

If you want more in-depth and currently working examples, checkout example/.

Starting with no access token:

const Vogel = require('vogel')

const vogel = new Vogel({
  consumerKey: TWITTER_CONSUMER_KEY,
  consumerSecret: TWITTER_CONSUMER_SECRET,
  oauthCallback: 'http://localhost:8000/api/oauth-token'
})

const url = await vogel.getRequestToken()

// User goes to url, clicks the button, you get a request token + verifier back

// Access tokens!
// These tokens are also persisted to Vogel's scope so you don't need to send
// them with subsequent requests or manage them yourself
const {
  token,
  tokenSecret
} = await vogel.getAccessToken(requestToken, verifier)

Have an access token already:

const Vogel = require('vogel')

const vogel = new Vogel({
  consumerKey: TWITTER_CONSUMER_KEY,
  consumerSecret: TWITTER_CONSUMER_SECRET,
  accessTokenKey: TWITTER_ACCESS_TOKEN,
  accessTokenSecret: TWITTER_ACCESS_TOKEN_SECRET
})

Bearer tokens

const Vogel = require('vogel')

const vogel = new Vogel({
  consumerKey: TWITTER_CONSUMER_KEY,
  consumerSecret: TWITTER_CONSUMER_SECRET,
  bearerToken: TWITTER_BEARER_TOKEN
})

CLI / PIN-based OAuth (oob)

const Vogel = require('vogel')

const vogel = new Vogel({
  consumerKey: TWITTER_CONSUMER_KEY,
  consumerSecret: TWITTER_CONSUMER_SECRET,
  oauthCallback: 'oob'
})

const url = await vogel.getRequestToken()

// User goes to url, clicks the button, user is shown a pin

// Ask the user for the PIN and pass in
const {
  token,
  tokenSecret
} = await vogel.getAccessToken(pin)

Making requests

After you have authenticated either manually (getRequestToken() -> getAccessToken) or through passing the token, you will be able to make any request fully authenticated

get

const vogel = new Vogel({ ... })

const res = await vogel.get('/1.1/statuses/home_timeline.json', {
  query: {
    count: '200'
  }
})

// Uses node-fetch under the hood
const body = await res.json()

post

const vogel = new Vogel({ ... })

// Twitter is teasing us! We want tweet editing!
const res = await vogel.post('/1.1/statuses/update.json', {
  query: {
    status: 'hello!'
  }
})

// Uses node-fetch under the hood
const body = await res.json()

stream

coming soon?