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

bitly

Package Overview
Dependencies
Maintainers
1
Versions
124
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bitly

A Bit.ly API library for Node.JS

  • 5.0.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
12K
decreased by-1.85%
Maintainers
1
Weekly downloads
 
Created
Source

node-bitly - Bitly API for nodejs

CircleCI

NPM version

Dependencies

This module provides calls to the Bitly API for Nodejs. For more information on the API request and responses visit the Bitly API docs

node-bitly is programmed with ES7 async/await but uses the typescript compiler to ES5, so the library has been tested back to support node v4.8.4

Installation

To install via NPM type the following: npm install bitly

You can also install via git by cloning: git clone https://github.com/tanepiper/node-bitly.git /path/to/bitly

Usage

This library uses the API provided by bitly and requires an OAuth token to use. To get your access token, visit https://bitly.com/a/oauth_apps (under Generic Access Token)

See http://dev.bitly.com/ for format of returned objects from the API

Code

const BitlyClient = require('bitly');
const bitly = BitleyClient('<accessToken>');

const myFunc = async(uri = 'https://github.com/tanepiper/node-bitly') => {
  try {
    return await bitly.shorten(uri);
  } catch(e) {
    throw e;
  }
}

If you are not using node 8 then you can still use the library with Promise values:

const BitlyClient = require('bitly');
const bitly = BitleyClient('<accessToken>');

const uri = 'https://github.com/tanepiper/node-bitly';
bitly.shorten(uri).then(result => {
  console.log(result);
});

You can also do raw requests to any Bitly endpoint. With this you need to pass the access token to the method

const BitlyClient = require('bitly');
const MY_API_TOKEN = '<accessToken>';
const bitly = BitleyClient(MY_API_TOKEN);

const myFunc = async(method, data) => {
  try {
    return await bitly.doRequest({accessToken: MY_API_TOKEN, method, data});
  } catch(e) {
    throw e;
  }
}

Tests

To run tests type npm test.

Bit.ly Features

This module is limited to the following API methods:

  • info
  • shorten
  • expand
  • clicks / clicks_by_minute / clicks_by_day
  • referrers
  • countries
  • lookup

Keywords

FAQs

Package last updated on 31 Oct 2017

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