A Bit.ly API library for react
npm install bitly-react
* v6.0.x - Support for Node >=6. Available on npm as npm install bitly@latest
* v5.1.x - Support for Node >=4. Available on npm as npm install bitly@stable
Version 5 is end-of-life and will only recieve minor updates in the future and is considered stable. This will only ever support the Bitly v3 API
Version 6 is the current in-development version, re-written in Typescript. This version currently only supports the Bitly v3 API and will continue to do so in v6.0.x. Version 6.1.x will introduce Bitly v4 support.
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. When you import the client you get full type information. There maybe be some gaps in the information but this will be filled in, in future releases.
Currently node-bitly only supports Bitly's v3 API and has this hard coded in the parameter type. Support for version 4 will be added in a future release
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
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 offline, or you can view the index here (the generated documentation does not work on Github).
#### TypeScript / ES6 Imports
``js
import { BitlyClient } from 'bitly-react';
const bitly = new BitlyClient('
async function init() {
let result;
try {
result = await bitly.shorten('https://github.com/tanepiper/node-bitly');
} catch (e) {
throw e;
}
return result;
}
init();
`
#### JavaScript
`js
const { BitlyClient } = require('bitly-react');
const bitly = new BitlyClient('
let result;
try {
result = await bitly.shorten(uri);
} catch(e) {
throw e;
}
return result;
`
If you are not using node 8 then you can still use the library with Promise values:
`js
const BitlyClient = require('bitly-react');
const bitly = new BitlyClient('
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
`js
const BitlyClient = require('bitly-react');
const bitly = new BitlyClient('
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;
}
`
To run tests type npm test`. Please note one test will fail if you use your own API key, please update the string accordingly.
 
You can also PayPal Me.