Options
All
  • Public
  • Public/Protected
  • All
Menu

Class BitlyClient

This is the main Bitly module that returns an object of methods. You need to pass in your OAuth access token, as well as an optional config object. You are returned several helper methods, as well as access to a method to pass any bitly api request to.

For information on the data returned from the API, see the docs at https://dev.bitly.com/api.html

module

node-bitly

type

{function}

param

The access token, this from an OAuth session

param

Optional config object

returns
example

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

Hierarchy

  • BitlyClient

Index

Constructors

constructor

  • new BitlyClient(accessToken: string, config?: BitlyConfig): BitlyClient
  • Parameters

    • accessToken: string
    • Default value config: BitlyConfig = {}

    Returns BitlyClient

Properties

Private accessToken

accessToken: string

Private config

config: BitlyConfig

Methods

bitlyRequest

  • bitlyRequest(method: string, data: BitlyUrlQueryParams | any): Promise<BitlyResponseData>
  • Perform any bitly API request using a method name and passed data object

    Parameters

    • method: string

      The method name to be called on the API

    • data: BitlyUrlQueryParams | any

      The data object to be passed. Keys should be query paramaters

    Returns Promise<BitlyResponseData>

    The bitly request return data

clicks

  • clicks(items: string | string[]): Promise<BitlyResponseData>
  • Request to get clicks for urls and hashes

    Parameters

    • items: string | string[]

      A string or array of strings of short urls and hashes.

    Returns Promise<BitlyResponseData>

clicksByDay

  • clicksByDay(items: string | string[]): Promise<BitlyResponseData>
  • Request to get clicks by day for urls and hashes

    Parameters

    • items: string | string[]

      A string or array of strings of short urls and hashes.

    Returns Promise<BitlyResponseData>

clicksByMinute

  • clicksByMinute(items: string | string[]): Promise<BitlyResponseData>
  • Request to get clicks by minute for urls and hashes

    Parameters

    • items: string | string[]

      A string or array of strings of short urls and hashes.

    Returns Promise<BitlyResponseData>

countries

  • countries(item: string): Promise<BitlyResponseData>
  • Request countries for a single url

    Parameters

    • item: string

    Returns Promise<BitlyResponseData>

expand

  • expand(items: string | string[]): Promise<BitlyResponseData>
  • Request to expand urls and hashes

    Parameters

    • items: string | string[]

      A string or array of strings of short urls and hashes.

    Returns Promise<BitlyResponseData>

    The results of the request

info

  • info(items: string | string[]): Promise<BitlyResponseData>
  • This is used to return the page title for a given Bitlink.

    Parameters

    • items: string | string[]

      An array of short urls or hashes

    Returns Promise<BitlyResponseData>

    The results of the request

lookup

  • lookup(url: string): Promise<BitlyResponseData>
  • Lookup a single url

    Parameters

    • url: string

      The url to look up

    Returns Promise<BitlyResponseData>

referrers

  • referrers(item: string): Promise<BitlyResponseData>
  • Request referrers for a single url

    Parameters

    • item: string

    Returns Promise<BitlyResponseData>

shorten

  • shorten(longUrl: string): Promise<BitlyResponseData>
  • Used to shorted a url

    Parameters

    • longUrl: string

      The URL to be shortened

    Returns Promise<BitlyResponseData>

    The results of the request

Generated using TypeDoc