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

  • 6.0.0-beta.843
  • 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 TypeScript but is compiled to JavaScript and supports node 6, 8, 10.

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

Note: This is the Version 6 API

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

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

To see the available libary APIs, you can view the API Documentation

Code

TypeScript / ES6 Imports
import { BitlyClient } from 'bitly';
const bitly = new BitlyClient('<accessToken>', {});
try {
  return await bitly.shorten(uri);
} catch(e) {
  throw e;
}
JavaScript
const { BitlyClient } = require('bitly');
const bitly = new BitlyClient('<accessToken>', {});

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 = BitlyClient('<accessToken>');

bitly.shorten('https://github.com/tanepiper/node-bitly')
.then(function(result) {
  console.log(result);
})
.catch(function(error) {
  console.error(error);
});

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 bitly = new BitlyClient('<accessToken>');

try {
  return await bitly.bitlyRequest('link/referrers_by_domain', {
    link: 'https://github.com/tanepiper/node-bitly',
    unit: 'hour',
    timezone: 'Europe/Amsterdam'
  });
} catch(e) {
  throw e;
}

Tests

To run tests type npm test. Please note one test will fail if you use your own API key, please update the string accordingly.

Keywords

FAQs

Package last updated on 11 Jun 2018

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