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 🙏

© 2026 – Pkg Stats / Ryan Hefner

gapi-url

v1.0.0

Published

Small wrapper around Google Url Shortener API providing 'insert' and 'get' methods.

Readme

gapi-url build status

Small wrapper around Google Url Shortener API providing 'insert' and 'get' methods.

const gapiUrl = require('gapi-url')

const API_KEY = '<your api key here>'

// Shorten a URL
shortenURL(API_KEY, 'https://github.com', print)

function printShortened(err, res) {
  if (err) return console.error(err)
  console.log('shortened url: ', res)
  // => shortened url:  https://goo.gl/un5E
}

// Expand a shortened URL
expandURL(API_KEY, 'https://goo.gl/un5E', 'FULL', print)

function print(err, res) {
  if (err) return console.error(err)
  console.log('expanded url: ', res)
  // => expanded url: https://github.com
}

Installation

npm install gapi-url

Table of Contents generated with DocToc

API

shortenURL

Shortens the provided url

Parameters

  • apiKey String api key of your google application
  • link String that you want to shorten
  • cb Function with following signature function (err, shortenedLink)

expandURL

Expands the provided shortened url

Supported projections
  • ANALYTICS_CLICKS: Returns only click counts
  • ANALYTICS_TOP_STRINGS: Returns only top string counts
  • FULL: Returns the creation timestamp and all available analytics

Parameters

  • apiKey String api key of your google application
  • shortened String link that you want to expand
  • projection String to include more info ANALYTICS_CLICKS| ANALYTICS_TOP_STRINGS | FULL
  • cb Function with following signature function (err, expanedLink)
  • shortLink

getAnalyticsURL

Returns the url for the google analytics page for the given shortened url.

Example

getAnalyticsURL('https://goo.gl/un5E')

=> https://goo.gl/#analytics/goo.gl/un5E/all_time

Parameters

  • url String shortened URL, i.e. obtained via shortenURL

Returns String link to the Google Analytics page.

Resources

Getting Started with the Google Shortener API

API documented here

https://developers.google.com/url-shortener/v1/url

link

Get API key

https://developers.google.com/url-shortener/v1/getting_started

link

View Shortener Console

https://console.developers.google.com/apis/api/urlshortener.googleapis.com/overview?project=gapi-url-1513446857763&duration=PT1H

link

Testing with curl

curl https://www.googleapis.com/urlshortener/v1/url?key=AIzaSyA2LZbzpowavq0euPXmNhrSW6Q-R4-HnZA \
-H 'Content-Type: application/json'                                                             \
-d '{"longUrl": "http://www.google.com/" }'

Kudos

Thanks to @anvaka for his initial shortener implementation.

License

MIT