Code Monkey home page Code Monkey logo

node-bitlyapi's Introduction

node-bitlyapi

A NodeJS interface for the public Bitly API

For more information about the Bitly API: dev.bitly.com

Dependencies

node-bitlyapi requires the btoa, request and querystring node modules (installed via NPM)

Installation

npm install node-bitlyapi

Version

The current published version of node-bitlyapi is 0.4.0. It is API complete, but missing some of the helper objects I intend to create.

Usage

node-bitlyapi uses Bitly's OAuth implementation, so you'll need to register an OAuth application with them. Register a Bitly OAuth app

var BitlyAPI = require("node-bitlyapi");
var bitly = new BitlyAPI({
	client_id: "Something",
	client_secret: "Something"	
});

You can then either authenticate using your username and password

bitly.authenticate(username, password, function(err, access_token) {
	// Returns an error if there was one, or an access_token if there wasn't 
});

or if you know your OAuth access_token, you can simply call:

bitly.setAccessToken(access_token);

The Bitly Object

Each of the public Bitly API endpoints are mapped and available with the following method signature

bitly.[method name](parameters, callback(error, response){

});

For Example:

bitly.shorten({longUrl:"https://github.com/nkirby/node-bitlyapi"}, function(err, results) {
	// Do something with your new, shorter url...
});

Where parameters is a key-value object {} according to Bitly's API documentation.

To see the full mapping of the Bitly API, visit The Wiki

Helpers

To make navigating the Bitly API a bit easier, a handful of small wrapper objects & methods have been provided to make your life a bit easier.

Shortening

Since the vast majority of Bitly's usage is through shortening, I've provided a simpler alternative to the standard Bitly.shorten mapping:

bitly.shortenLink("https://github.com/nkirby/node-bitlyapi", function(err, results) {

});

Objects

The following objects are provided to wrap the API in a friendlier manner

BitlyUser

bitly.user()
bitly.user('login')
bitly.user('login').getLinkHistory(null, function(err, results) {
	// Gets the public link history of "login"
});

For more information about a BitlyUser - Wiki

BitlyLink

bitly.link('http://bit.ly/1eOHYrA')
bitly.link('http://bit.ly/1eOHYrA').getInfo(function(err, results) {

});

For more information about a BitlyLink - Wiki

BitlyBundle

To Do.

BitlyBundleLink

To Do.

Credits & Such

This project was created by Nathaniel Kirby

[email protected]

@thenatekirby

Despite being Bitly's iOS developer, this project doesn't mean that

a) I know anything more or less about iOS because of it.
b) Or, inversely, that I know more or less about JavaScript, CoffeeScript or whatever else script is coming up next.
c) That Bitly approves, condones, supports or even acknowledge this project.

Feel free to use this to make great NodeJS apps using Bitly's API. Your usage of their API is subject to their terms and conditions. Don't be a jackass, or a spammer...or a jackass spammer.

License

This software is provided via the MIT License.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

node-bitlyapi's People

Contributors

alanjames1987 avatar nkirby avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.