Giter Club home page Giter Club logo

node-shorturl's Introduction

Simple URL shortener client library for node.js

Forked from: https://github.com/jdub/node-shorturl to fix the is.gd service.
shorturl is a simple, asynchronous client library for common URL shortener services. It currently supports: arseh.at, bit.ly, goo.gl, is.gd, v.gd and string substitution links (with %@). It includes a perky little script for shortening URLs on the command line, also named shorturl.

If you need to go deeper, try the more complete client libraries for individual services such as node-bitly or node-googl.

Requirements

You can install node-shorturl and its dependencies with npm: npm install shorturl. Otherwise, manually install:

Examples

var shorturl = require('shorturl-2');
shorturl('http://bethesignal.org/', function(result) {
	console.log(result);
});

By default it will shorten URLs with is.gd, but you can choose an alternative service and pass parameters:

shorturl('http://bethesignal.org/', 'bit.ly', {
	login: 'STATE YOUR NAME',
	apiKey: 'STATE YOUR IDENTIFICATION NUMBER'
}, function(result) {
	console.log(result);
});

Simple services can be described using a string substitution link. Pass the entire link as the service name; '%@' will be replaced with your URL:

var arsehat = 'http://arseh.at/api.php?action=shorturl&format=simple&url=%@';
shorturl('http://bethesignal.org/', arsehat, function(result) {
	console.log(result);
});

Command line script

$ shorturl
Usage: shorturl [options] <longurl>

$ shorturl --service=goo.gl --key=STATE_YOUR_ID_NUMBER http://bethesignal.org/
http://goo.gl/dgTLo

$ ARSEHAT="http://arseh.at/api.php?action=shorturl&format=simple&url=%@"
$ shorturl --service=$ARSEHAT https://github.com/jdub/node-shorturl
http://arseh.at/3yd

Display the built-in command line documentation with shorten --help.

Changelog

0.0.7 - Update to allow goo.gl to accept a key (docs were there but code didn't allow for it).

node-shorturl's People

Contributors

darrin avatar eceeb avatar jdub 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.