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

bitly-node-api

v0.0.5

Published

bitly api wrapper

Downloads

3,765

Readme

bitly-node-api (Bitly Node Rest API)

Build Status Stackoverflow Thread

This API supported Bitly standard REST API that accepts/returns JSON requests. Here is the API reference

You can find examples of JavaScript and TypeScript. This will help you for faster implementation of Bitly APIs.

It does supports EcmaScript 5, EcmaScript 6, EcmaScript 8, TypeScript, async-await, Promises, Callback!!!
It does also supports for AWS Lambda like serverless cloud function call.
It supports pure JSON response.
All methods support Promise and Callback both.
Please Feel free to create issue for any help!
All developers/contributors are requested to open Pull Request/Merge Request on develop branch.
Please make sure Test Cases be passed.

Get started

Using the Bitly API wrapper for Node.js is really simple. Given that you already have a Node.js project with NPM setup just follow these steps:

Installation

npm install bitly-node-api --save

Pull Request

  • Contributors can send their Pull Request to develop branch.
  • Kindly validate test cases & linting before opening new PR.

Do you need an expert?

Are you finding a developer or team for your world-class enterprise product development? If yes, please send email to. Submit your project request here. Originally by Vijay Patoliya.

Configuration Using JavaScript

Already you having access token then use below configuration

export BITLY_USER_TOKEN=ACCESS_TOKEN
var bitly = require("bitly-node-api")("YOUR_ACCESS_TOKEN");

If you don't have access token then get access token using below configuration and example

var bitly = require("bitly-node-api");

bitly.setApiKey(clientId, clientSecret);

var options = {
  username: "Username",
  password: "Password",
};
var response = bitly.application.getOAuthToken(options);
if (response && response.access_token) {
  bitly.setUserToken(response.access_token);
}

Configuration Using TypeScript

import * as BitlyAPI from "bitly-node-api";
const bitly = new BitlyAPI();
bitly.setUserToken("YOUR_ACCESS_TOKEN");
Originally by [email protected] : [Vijay Patoliya](https://github.com/vijaypatoliya).

Examples

  1. BITLINKS

  2. BSDS

  3. CAMPAIGNS

  4. CUSTOM BITLINKS

  5. GROUPS

  6. ORGANIZATIONS

  7. USER

  8. WEBHOOKS


BITLINKS

/** Bulk update */
var group_guid = "string";

var payload = {
  action: "string",
  archive: "boolean",
  add_tags: ["array of string"],
  remove_tags: ["array of string"],
  links: ["array of string"],
};
try {
  var response = await bitly.bitlinks.bulkUpdate(group_guid, payload);
} catch (error) {
  return;
}
/** Create */
var payload = {
  long_url: "https://www.google.com",
};
try {
  var response = await bitly.bitlinks.create(payload);
} catch (error) {
  return;
}
/** Create QR */

var bitlink = "bitly.is/2rAZFZ1";

var payload = {
  color: "string",
  exclude_bitly_logo: "boolean",
  image_format: "string",
  logo_image_guid: "string",
};

try {
  var response = await bitly.bitlinks.createQR(bitlink, payload);
} catch (error) {
  return;
}
/** Delete */

var bitlink = "bitly.is/2rAZFZ1";

try {
  var response = await bitly.bitlinks.delete(bitlink);
} catch (error) {
  return;
}
/** Expand */
var bitlink = "bitly.is/2rAZFZ1";
try {
  var response = await bitly.bitlinks.expand(bitlink);
} catch (error) {
  return;
}
/** Get */

var bitlink = "bitly.is/2rAZFZ1";
try {
  var response = await bitly.bitlinks.get(bitlink);
} catch (error) {
  return;
}
/** Get by group */
var group_guid = "Bibh7CqXlyA";
var payload = {
  size: "number",
  page: "number",
  keyword: "string",
  query: "string",
  created_before: "number",
  created_after: "number",
  modified_after: "number",
  archived: "string",
  deeplinks: "string",
  domain_deeplinks: "string",
  campaign_guid: "string",
  channel_guid: "string",
  custom_bitlink: "string",
  tags: "array",
  launchpad_ids: "array",
  encoding_login: "array",
};
try {
  var response = await bitly.bitlinks.getByGroup(group_guid, payload);
} catch (error) {
  return;
}
/** Get clicks */

var bitlink = "bitly.is/2rAZFZ1";
var payload = {
  units: "integer",
  unit: "string",
  unit_reference: "string",
};

try {
  var response = await bitly.bitlinks.getClicks(bitlink, payload);
} catch (error) {
  return;
}
/** Get clicks summary */

var bitlink = "bitly.is/2rAZFZ1";
var payload = {
  units: "integer",
  unit: "string",
  unit_reference: "string",
};

try {
  var response = await bitly.bitlinks.getClicksSummary(bitlink, payload);
} catch (error) {
  return;
}
/** Get metrics by city */

var bitlink = "bitly.is/2rAZFZ1";
var payload = {
  unit: "minute",
};
try {
  var response = await bitly.bitlinks.getMetricsByCity(bitlink, payload);
} catch (error) {
  return;
}
/** Get metrics by country */

var bitlink = "bitly.is/2rAZFZ1";
var payload = {
  units: "number",
  unit: "string",
  size: "number",
  unit_reference: "string",
};

try {
  var response = await bitly.bitlinks.getMetricsByCountry(bitlink, payload);
} catch (error) {
  return;
}
/** Get Metrics by device type */

var bitlink = "bitly.is/2rAZFZ1";
var payload = {
  units: "number",
  unit: "string",
  size: "number",
  unit_reference: "string",
};

try {
  var response = await bitly.bitlinks.getMetricsByDeviceType(bitlink, payload);
} catch (error) {
  return;
}
/** Get metrics by referrers */

var bitlink = "bitly.is/2rAZFZ1";
var payload = {
  units: "number",
  unit: "string",
  size: "number",
  unit_reference: "string",
};

try {
  var response = await bitly.bitlinks.getMetricsByReferrers(bitlink, payload);
} catch (error) {
  return;
}
/** Get metrics by referrers domain */

var bitlink = "bitly.is/2rAZFZ1";
var payload = {
  units: "number",
  unit: "string",
  size: "number",
  unit_reference: "string",
};

try {
  var response = await bitly.bitlinks.getMetricsByReferrersDomain(
    bitlink,
    payload
  );
} catch (error) {
  return;
}
/** Get metrics by referring domain */

var bitlink = "bitly.is/2rAZFZ1";
var payload = {
  units: "number",
  unit: "string",
  size: "number",
  unit_reference: "string",
};

try {
  var response = await bitly.bitlinks.getMetricsByReferringDomain(
    bitlink,
    payload
  );
} catch (error) {
  return;
}
/** Get QR */

var bitlink = "bitly.is/2rAZFZ1";
try {
  var response = await bitly.bitlinks.getQR(bitlink);
} catch (error) {
  return;
}
/** List sorted by group */

var group_guid = "Bibh7CqXlyA";
var sort = "clicks";
var payload = {
  size: 10,
};
try {
  var response = await bitly.bitlinks.listSortedByGroup(
    group_guid,
    sort,
    payload
  );
} catch (error) {
  return;
}
/** shorted link */

var group_guid = "string";
var sort = "string";

var payload = {
  unit: "string",
  units: "number",
  unit_reference: "string",
  size: "number",
};

try {
  var response = await bitly.bitlinks.shortedLink(group_guid, sort, payload);
} catch (error) {
  return;
}
/** Update */

var bitlink = "bitly.is/2rAZFZ1";

var payload = {
  references: {
    /* any */
  },
  link: "string",
  id: "string",
  long_url: "string",
  title: "string",
  archived: "boolean",
  created_at: "string",
  created_by: "string",
  client_id: "string",
  custom_bitlinks: ["string"],
  tags: ["string"],
  launchpad_ids: ["string"],
  deeplinks: [
    {
      guid: "string",
      bitlink: "string",
      app_uri_path: "string",
      install_url: "string",
      app_guid: "string",
      os: "string",
      install_type: "string",
      created: "string",
      modified: "string",
      brand_guid: "string",
    },
  ],
  is_deleted: "boolean",
};

try {
  var response = await bitly.bitlinks.update(bitlink, payload);
} catch (error) {
  return;
}
/** Update QR */

var bitlink = "bitly.is/2rAZFZ1";

var payload = {
  color: "string",
  exclude_bitly_logo: "boolean",
  image_format: "string",
  logo_image_guid: "string",
};

try {
  var response = await bitly.bitlinks.updateQR(bitlink, payload);
} catch (error) {
  return;
}

BSDS

/** Get group overrides */

var group_guid = "string";
var payload = {
  group_guid: ["array"],
  created_after: "number",
  limit: "number",
  offset: "number",
  bsd: ["array"],
};

try {
  var response = await bitly.bsds.getGroupOverrides(group_guid, payload);
} catch (error) {
  return;
}
/** List */

try {
  var response = await bitly.bsds.list();
} catch (error) {
  return;
}

CAMPAIGNS

/** Create */
var payload = {
  group_guid: "string",
  name: "string",
  description: "string",
  channel_guids: ["array of string"],
};

try {
  var response = await bitly.campaigns.create(payload);
} catch (error) {
  return;
}
/** Create channel */
var payload = {
  name: "string",
  guid: "string",
  creted: "string",
  modified: "string",
  group_guid: "string",
  bitlinks: [
    {
      campaign_guid: "string",
      bitlink_id: "string",
    },
  ],
};

try {
  var response = await bitly.campaigns.createChannel(payload);
} catch (error) {
  return;
}
/** Get */

try {
  var response = await bitly.campaigns.get(campaign_guid);
} catch (error) {
  return;
}
/** Get channel */

var channel_guid = "string";
try {
  var response = await bitly.campaigns.getChannel(channel_guid);
} catch (error) {
  return;
}
/** List */
try {
  var payload = {
    group_guid: "string",
  };

  var response = await bitly.campaigns.list(payload);
} catch (error) {
  return;
}
/** List channels */
var payload = {
  group_guid: "string",
  campaign_guid: "string",
};
try {
  var response = await bitly.campaigns.listChannels(payload);
} catch (error) {
  return;
}
/** Update */

var campaign_guid = "string";
var payload = {
  group_guid: "string",
  name: "string",
  description: "string",
  channel_guids: ["array of string"],
};

try {
  var response = await bitly.campaigns.update(campaign_guid, payload);
} catch (error) {
  return;
}
/** Update channel */

var channel_guid = "string";

var payload = {
  name: "string",
  guid: "string",
  creted: "string",
  modified: "string",
  group_guid: "string",
  bitlinks: [
    {
      campaign_guid: "string",
      bitlink_id: "string",
    },
  ],
};

try {
  var response = await bitly.campaigns.updateChannel(channel_guid, payload);
} catch (error) {
  return;
}

CUSTOM BITLINKS

/** Add */
var payload = {
  custom_bitlink: "https://www.google.com",
  bitlink_id: "string",
};
try {
  var response = await bitly.customBitlinks.add(payload);
} catch (error) {
  return;
}
/** Get */

var custom_bitlink = "string";
try {
  var response = await bitly.customBitlinks.get(custom_bitlink);
} catch (error) {
  return;
}
/** Get click for entire history */

var custom_bitlink = "string";
var payload = {
  units: "integer",
  unit: "string",
  unit_reference: "string",
};

try {
  var response = await bitly.customBitlinks.getClicksForEntireHistory(
    custom_bitlink,
    payload
  );
} catch (error) {
  return;
}
/** Get metrics for custom destination  */
var custom_bitlink = "string";
var payload = {
  units: "integer",
  unit: "string",
  unit_reference: "string",
};

try {
  var response = await bitly.customBitlinks.getMetricsForCustomDestination(
    custom_bitlink,
    payload
  );
} catch (error) {
  return;
}
/** Update */

var custom_bitlink = "bitly.is/2rAZFZ1";

var payload = {
  bitlink_id: "string",
};

try {
  var response = await bitly.customBitlinks.update(custom_bitlink, payload);
} catch (error) {
  return;
}

GROUPS

/** Get */

var group_guid = "string";

try {
  var response = await bitly.groups.get(group_guid);
} catch (error) {
  return;
}
/** Get click metrics by city */

var group_guid = "string";
var payload = {
  unit: "string",
  units: "number",
  size: "number",
  unit_reference: "string",
};
try {
  var response = await bitly.groups.getClickMetricsByCity(group_guid, payload);
} catch (error) {
  return;
}
/** Get click metrics by country */

var group_guid = "string";
var payload = {
  unit: "string",
  units: "number",
  size: "number",
  unit_reference: "string",
};

try {
  var response = await bitly.groups.getClickMetricsByCountry(
    group_guid,
    payload
  );
} catch (error) {
  return;
}
/** Get click metrics by device type */

var group_guid = "string";
var payload = {
  unit: "string",
  units: "number",
  size: "number",
  unit_reference: "string",
};
try {
  var response = await bitly.groups.getClickMetricsByDeviceType(
    group_guid,
    payload
  );
} catch (error) {
  return;
}
/** Get click metrics by referring networks */

var group_guid = "string";

try {
  var response = await bitly.groups.getClickMetricsByReferringNetworks(
    group_guid
  );
} catch (error) {
  return;
}
/** Get clicks */

var group_guid = "string";

try {
  var response = await bitly.groups.getClicks(group_guid);
} catch (error) {
  return;
}
/** Get preferences */

var group_guid = "string";
try {
  var response = await bitly.groups.getPreferences(group_guid);
} catch (error) {
  return;
}
/** Get QR */

var group_guid = "string";

try {
  var response = await bitly.groups.getQR(group_guid);
} catch (error) {
  return;
}
/** Get shorten counts */

var group_guid = "string";
var payload = {
  unit: "string",
  units: "number",
  unit_reference: "string",
};
try {
  var response = await bitly.groups.getShortenCounts(group_guid, payload);
} catch (error) {
  return;
}
/** Get list */
var payload = {
  organization_guid: "string",
};
try {
  var response = await bitly.groups.list(payload);
} catch (error) {
  return;
}
/** Get list tags */

var group_guid = "string";
try {
  var response = await bitly.groups.listTags(group_guid);
} catch (error) {
  return;
}
/** update */
var group_guid = "Bibh7CqXlyA";
var payload = {
  name: "string",
  organization_guid: "string",
  bsds: ["string"],
};

try {
  var response = await bitly.groups.update(group_guid, payload);
} catch (error) {
  return;
}
/** Update preferences */

var group_guid = "string";
var payload = {
  group_guid: "string",
  domain_preference: "bit.ly",
};

try {
  var response = await bitly.groups.updatePreferences(group_guid, payload);
} catch (error) {
  return;
}

ORGANIZATIONS

/** Get */

var organization_guid = "string";

try {
  var response = await bitly.organizations.get(organization_guid);
} catch (error) {
  return;
}
/** Get plan limits */
var organization_guid = "string";
try {
  var response = await bitly.organizations.getPlanLimits(organization_guid);
} catch (error) {
  return;
}
/** Get shorten Counts */

var organization_guid = "string";

var payload = {
  unit: "string",
  units: "number",
  unit_reference: "string",
};

try {
  var response = await bitly.organizations.getShortenCounts(
    organization_guid,
    payload
  );
} catch (error) {
  return;
}
/** List */
try {
  var response = await bitly.organizations.list();
} catch (error) {
  return;
}

USER

/** Get */
try {
  var response = await bitly.user.get();
} catch (error) {
  return;
}
/** Get platform limits */
var payload = {
  path: "string",
};

try {
  var response = await bitly.user.getPlatformLimits(payload);
} catch (error) {
  return;
}
/** Update */

var payload = {
  name: "string",
  default_group_guid: "string",
};

try {
  var response = await bitly.user.update(payload);
} catch (error) {
  return;
}

WEBHOOKS

/** Create */

var payload = {
  organization_guid: "string",
  name: "string",
  event: "string",
  url: "string",
  is_active: "boolean",
  group_guid: "string",
  oauth_url: "string",
  client_id: "string",
  client_secret: "string",
  fetch_tags: "boolean",
};

try {
  var response = await bitly.webhooks.create(payload);
} catch (error) {
  return;
}
/** Delete */
var webhook_guid = "string";
try {
  var response = await bitly.webhooks.delete(webhook_guid);
} catch (error) {
  return;
}
/** Get */
try {
  var response = await bitly.webhooks.get(webhook_guid);
} catch (error) {
  return;
}
/** List */

try {
  var organigation_guid = "string";

  var response = await bitly.webhooks.list(organigation_guid);
} catch (error) {
  return;
}
/** Update */

var webhook_guid = "string";
var payload = {
  guid: "string",
  organization_guid: "string",
  name: "string",
  event: "string",
  url: "string",
  is_active: "boolean",
  group_guid: "string",
  oauth_url: "string",
  client_id: "string",
  client_secret: "string",
  fetch_tags: "boolean",
};

try {
  var response = await bitly.webhooks.update(webhook_guid, payload);
} catch (error) {
  return;
}
/** Verify */

var webhook_guid = "string";
try {
  var response = await bitly.webhooks.verify(webhook_guid);
} catch (error) {
  return;
}