Implemented APIs

Currently, pyshorteners implements the following APIs:

Adf.ly

class pyshorteners.shorteners.adfly.Shortener(**kwargs)

Adf.ly implementation.

Parameters
  • api_key (str) – adf.ly API key.

  • user_id (str) – adf.ly user id.

  • domain (str, optional) –

    Domain used upon shortening, options are:

    • ad.fly (default)

    • q.gs

    • custom.com

    • 0 (Random domain)

  • type (int, optional) –

    For advertising on the shortened link, options are:

    • 1, int, interstitial - Interstitial advertising

    • 2 - No advertising

    • 3, banner - Framed Banner

  • group_id (int, optional) – API parameter group_id.

Example

>>> import pyshorteners
>>> s = pyshorteners.Shortener(api_key='YOUR_KEY', user_id='USER_ID',
                               domain='test.us', group_id=12, type='int')
>>> s.adfly.short('http://www.google.com')
'http://test.us/TEST'
expand(url)

Expand implementation for Adf.ly.

Parameters

url (str) – The URL you want to expand.

Returns

The expanded URL.

Return type

str

Raises
short(url)

Short implementation for Adf.ly.

Parameters

url (str) – The URL you want to shorten.

Returns

The shortened URL.

Return type

str

Raises

Bit.ly

class pyshorteners.shorteners.bitly.Shortener(**kwargs)

Bit.ly shortener Implementation

Parameters

api_key (str) – bit.ly API key

Example

>>> import pyshorteners
>>> s = pyshorteners.Shortener(api_key='YOUR_KEY')
>>> s.bitly.short('http://www.google.com')
'http://bit.ly/TEST'
>>> s.bitly.expand('https://bit.ly/TEST')
'http://www.google.com'
>>> s.bitly.total_clicks('https://bit.ly/TEST')
10
expand(url)

Expand implementation for Bit.ly :param url: The URL you want to expand. :type url: str

Returns

The expanded URL.

Return type

str

Raises
short(url)

Short implementation for Bit.ly :param url: the URL you want to shorten :type url: str

Returns

The shortened URL.

Return type

str

Raises
total_clicks(url)

Total clicks implementation for Bit.ly :param url: the URL you want to get the total clicks count :type url: str

Returns

The total clicks count

Return type

int

Raises

BadAPIResponseException – If the API Returns an error as response

Chilp.it

class pyshorteners.shorteners.chilpit.Shortener(**kwargs)

Chilp.it shortener implementation

Example

>>> import pyshorteners
>>> s = pyshorteners.Shortener()
>>> s.chilpit.short('http://www.google.com')
'http://chilp.it/TEST'
>>> s.chilpit.expand('http://chilp.it/TEST')
'http://www.google.com'
short(url)

Short implementation for Chilp.it

Parameters

url – the URL you want to shorten

Returns

A string containing the shortened URL

Raises

ShorteningErrorException – If the API returns an error as response

Clck.ru

class pyshorteners.shorteners.clckru.Shortener(**kwargs)

Clck.ru shortener implementation

Example

>>> import pyshorteners
>>> s = pyshorteners.Shortener()
>>> s.clckru.short('http://www.google.com')
'http://clck.ru/TEST'
>>> s.clckru.expand('http://clck.ru/TEST')
'http://www.google.com'
short(url)

Short implementation for Clck.ru

Parameters

url – the URL you want to shorten

Returns

A string containing the shortened URL

Raises

ShorteningErrorException – If the API returns an error as response

Cutt.ly

class pyshorteners.shorteners.cuttly.Shortener(**kwargs)

Cutt.ly shortener implementation

Parameters

api_key (str) – cutt.ly API key

Example

>>> import pyshorteners
>>> s = pyshorteners.Shortener(api_key='YOUR_KEY')
>>> s.cuttly.short('http://www.google.com')
'http://cutt.ly/TEST'
>>> s.cuttly.expand('https://cutt.ly/TEST')
'http://www.google.com'
short(url)

Short implementation for Cutt.ly :param url: the URL you want to shorten :type url: str

Returns

The shortened URL.

Return type

str

Raises

Da.gd

class pyshorteners.shorteners.dagd.Shortener(**kwargs)

Da.gd shortener implementation

Example

>>> import pyshorteners
>>> s = pyshorteners.Shortener()
>>> s.dagd.short('http://www.google.com')
'http://da.gd/TEST'
>>> s.dagd.expand('http://da.gd/TEST')
'http://www.google.com'
expand(url)

Expand implementation for Da.gd :param url: The URL you want to expand. :type url: str

Returns

The expanded URL.

Return type

str

Raises

ExpandingErrorException – If the API Returns an error as response.

short(url)

Short implementation for Da.gd :param url: the URL you want to shorten :type url: str

Returns

The shortened URL.

Return type

str

Raises

ShorteningErrorException – If the API Returns an error as response

Git.io

class pyshorteners.shorteners.gitio.Shortener(**kwargs)

Git.io shortener Implementation

Example

>>> import pyshorteners
>>> s = pyshorteners.Shortener(code='12345')
>>> s.gitio.short('https://github.com/TEST')
'https://git.io/12345'
>>> s.gitio.expand('https://git.io/12345')
'https://github.com/TEST'
short(url)

Short implementation for Git.io Only works for github urls

Parameters
  • url (str) – the URL you want to shorten

  • code (str) – (Optional) Custom permalink code: Eg.: test

Returns

The shortened URL

Return type

str

Raises

ShorteningErrorException – If the API returns an error as response

Is.gd

class pyshorteners.shorteners.isgd.Shortener(**kwargs)

Is.gd shortener implementation

Example

>>> import pyshorteners
>>> s = pyshorteners.Shortener()
>>> s.isgd.short('http://www.google.com')
'http://is.gd/TEST'
>>> s.isgd.expand('http://is.gd/TEST')
'http://www.google.com'
short(url)

Short implementation for Is.gd

Parameters

url – the URL you want to shorten

Returns

A string containing the shortened URL

Raises

ShorteningErrorException – If the API returns an error as response

NullPointer

class pyshorteners.shorteners.nullpointer.Shortener(**kwargs)

The Null Pointer implementation

Parameters

domain (str) –

Optional string for the null pointer instance to use. Default is ‘https://0x0.st’. Any URL to a Null Pointer instance is supported, for example:

  • https://0x0.st

  • https://ttm.sh

Example

>>> import pyshorteners
>>> s = pyshorteners.Shortener(domain='https://0x0.st')
>>> s.nullpointer.short('https://www.google.com')
'https://0x0.st/jU'
short(url)

Short implementation for The Null Pointer :param url: the URL you want to shorten :type url: str

Returns

The shortened URL

Return type

str

Raises

Os.db

class pyshorteners.shorteners.osdb.Shortener(**kwargs)

Os.db shortener implementation

Example

>>> import pyshorteners
>>> s = pyshorteners.Shortener()
>>> s.osdb.short('http://www.google.com')
'https://osdb.link/TEST'
>>> s.osdb.expand('http://osdb.link/TEST')
'https://www.google.com'
short(url)

Short implementation for Os.db

Parameters

url – the URL you want to shorten

Returns

A string containing the shortened URL

Raises

ShorteningErrorException – If the API returns an error as response

Ow.ly

class pyshorteners.shorteners.owly.Shortener(**kwargs)

Ow.ly url shortner api implementation

Example

>>> import pyshorteners
>>> s = pyshorteners.Shortener()
>>> s.owly.short('http://www.google.com')
'http://ow.ly/TEST'
>>> s.owly.expand('http://ow.ly/TEST')
'http://www.google.com'
expand(url)

Expand implementation for ow.ly.

Parameters

url (str) – The URL you want to expand.

Returns

The expanded URL.

Return type

str

Raises
short(url)

Short implementation for ow.ly.

Parameters

url (str) – The URL you want to shorten.

Returns

The shortened URL.

Return type

str

Raises

Po.st

class pyshorteners.shorteners.post.Shortener(**kwargs)

Po.st Shortener implementation

Parameters

api_key (str) – adf.ly API key.

Example

>>> import pyshorteners
>>> s = pyshorteners.Shortener(api_key='YOUR_KEY')
>>> s.post.short('http://www.google.com')
'http://po.st/TEST'
>>> s.post.expand('http://po.st/TEST')
'http://www.google.com'
short(url)

Short implementation for Po.st.

Parameters

url (str) – The URL you want to shorten.

Returns

The shortened URL.

Return type

str

Raises

Qps.ru

class pyshorteners.shorteners.qpsru.Shortener(**kwargs)

Qps.ru shortener implementation

Example

>>> import pyshorteners
>>> s = pyshorteners.Shortener()
>>> s.qpsru.short('http://www.google.com')
'http://qps.ru/TEST'
>>> s.qpsru.expand('http://qps.ru/TEST')
'http://www.google.com'
short(url)

Short implementation for Qps.ru

Parameters

url – the URL you want to shorten

Returns

A string containing the shortened URL

Raises

ShorteningErrorException – If the API returns an error as response

Short.cm

class pyshorteners.shorteners.shortcm.Shortener(**kwargs)

Short.cm shortener Implementation

Parameters
  • api_key (str) – short.cm API key

  • domain (str) – which registered domain to create the link on

Example

>>> import pyshorteners
>>> s = pyshorteners.Shortener(api_key='YOUR_KEY')
>>> s.shortcm.short('http://www.google.com')
'http://short.cm/TEST'
>>> s.shortcm.expand('https://short.cm/test')
'http://www.google.com'
>>> s.shortcm.expand('https://short.cm/test')
10
expand(url)

Expand implementation for Short.cm :param url: the short URL you want to expand

Returns

The expanded URL

Return type

str

Raises

ExpandingErrorException – If the API Returns an error as response

short(url)

Short implementation for Short.cm :param url: the URL you want to shorten :type url: str

Returns

The shortened URL

Return type

str

Raises

Tiny.cc

class pyshorteners.shorteners.tinycc.Shortener(**kwargs)

Tiny.cc implementation.

Parameters
  • api_key (str) – Tiny.cc API key.

  • login (str) – Tiny.cc username.

Example

>>> import pyshorteners
>>> s = pyshorteners.Shortener(api_key='12345', login='user')
>>> s.tinycc.short('http://www.google.com')
'http://tiny.cc/6lbsez'
expand(url)

Expand implementation for Tiny.cc.

Parameters

url (str) – The URL you want to expand.

Returns

The expanded URL.

Return type

str

Raises

ExpandingErrorException – If the API Returns an error as response.

short(url)

Short implementation for Tiny.cc.

Parameters

url (str) – The URL you want to shorten.

Returns

The shortened URL.

Return type

str

Raises
total_clicks(url)

How many times the shortened URL has been clicked on.

Parameters

url (str) – The shortened URL to examine.

Returns

The number of times the shortened URL has been used.

Return type

int

Raises

BadAPIResponseException – If the data is malformed or we got a bad status code on API response.

TinyURL.com

class pyshorteners.shorteners.tinyurl.Shortener(**kwargs)

TinyURL.com shortener implementation

Example

>>> import pyshorteners
>>> s = pyshorteners.Shortener()
>>> s.tinyurl.short('http://www.google.com')
'http://tinyurl.com/TEST'
>>> s.tinyurl.expand('http://tinyurl.com/test')
'http://www.google.com'
short(url)

Short implementation for TinyURL.com

Parameters

url – the URL you want to shorten

Returns

A string containing the shortened URL

Raises

ShorteningErrorException – If the API returns an error as response

Git.io

class pyshorteners.shorteners.gitio.Shortener(**kwargs)

Git.io shortener Implementation

Example

>>> import pyshorteners
>>> s = pyshorteners.Shortener(code='12345')
>>> s.gitio.short('https://github.com/TEST')
'https://git.io/12345'
>>> s.gitio.expand('https://git.io/12345')
'https://github.com/TEST'
short(url)

Short implementation for Git.io Only works for github urls

Parameters
  • url (str) – the URL you want to shorten

  • code (str) – (Optional) Custom permalink code: Eg.: test

Returns

The shortened URL

Return type

str

Raises

ShorteningErrorException – If the API returns an error as response

Tiny.cc

class pyshorteners.shorteners.tinycc.Shortener(**kwargs)

Tiny.cc implementation.

Parameters
  • api_key (str) – Tiny.cc API key.

  • login (str) – Tiny.cc username.

Example

>>> import pyshorteners
>>> s = pyshorteners.Shortener(api_key='12345', login='user')
>>> s.tinycc.short('http://www.google.com')
'http://tiny.cc/6lbsez'
expand(url)

Expand implementation for Tiny.cc.

Parameters

url (str) – The URL you want to expand.

Returns

The expanded URL.

Return type

str

Raises

ExpandingErrorException – If the API Returns an error as response.

short(url)

Short implementation for Tiny.cc.

Parameters

url (str) – The URL you want to shorten.

Returns

The shortened URL.

Return type

str

Raises
total_clicks(url)

How many times the shortened URL has been clicked on.

Parameters

url (str) – The shortened URL to examine.

Returns

The number of times the shortened URL has been used.

Return type

int

Raises

BadAPIResponseException – If the data is malformed or we got a bad status code on API response.