Skip to content
This repository has been archived by the owner on Jul 14, 2019. It is now read-only.
/ surl-cli Public archive

CLI for shortening URL with Firebase, Bitly, Goo.gl API

License

Notifications You must be signed in to change notification settings

hankchanocd/surl-cli

Repository files navigation

surl-cli    npm Build Status Commitizen friendly Known Vulnerabilities Github issues

CLI for shortening URL with Firebase, Bitly, Goo.gl API.

No more distraction from leaving to a web page just to create a short URL. surl is a CLI tool for shortening URL and retrieving URL's usage statistics from many API providers, including but not limited to Bitly, Firebase, and Goo.gl. The key advantage of Firebase API allows you to create links for Android and iOS apps in addition to web platform.

Install

$ npm install surl-cli -g

Usage

Init

Before start using surl, initialize configuration with surl init to select a default API provider. You must save at least one API key/token to surl from one of the three API providers (Bitly, Firebase, Goo.gl). While you can choose to store every API keys/tokens from all three service providers, surl only allows the default provider to be used at one time.

  • Follow the guide to go to Bitly's API page to receive your API key/token.
  • Follow the guide to go to Firebase (FDB)'s API page to receive your API key/token.
  • To comply with Google's policy on sunsetting goo.gl service on May 2019, we recommend users not to use URL shortening service from goo.gl. However, existing users of goo.gl can still receive their API keys/tokens at console until May 2019, while no new users are allowed to register with the service.
$ surl init
=> select your API provider (Bitly, Firebase, Google)
=> provide your API key/token

Config

Update your API key/token and change the default API provider after surl init

$ surl config

Shorten URL

$ surl www.example.com/test/test
=> success! https://goo.gl copied to clipboard

Expand URL

$ surl --reverse goo.gl   (or)   surl -r goo.gl
=> success! expanded url copied to clipboard

Stats

Fetch shortened URL's meta data and usage statistics, available only if the chosen provider has such feature.

$ surl --stats goo.gl
=> shortUrl: goo.gl
   origin: www.example.com/test/test
   created: 2009 11 12
   clicks:
       PERIOD   SHORTURL  LONGURL      COUNTRIES DATA
       allTime  30        40           Canada       5
       month    0         0            Australia    2
       week     0         0
       day      0         0
       twoHours 0         0

Help

Should you have any doubt, refer to help page.

$ surl --help

Tests

To run unit tests and API tests, run npm test.

Contributing

Development of surl now focuses on transforming URLs. Any other suggestions are welcomed, but will have to wait until the next major release. For more details, please refer to Contribution.

FAQ

  1. Why is ow.ly not included in the CLI?

    Access to ow.ly API is restricted to the enterprise users of its parent company, Hootsuite. At this point, I don't see many paid users of Hootsuite requesting this feature. You can still use ow.ly service on Hootsuite's website though.

License

MIT License | Copyright (c) 2018 Hank Chan