YOURLS Client¶
This small library was created to provide an easy interface to YOURLS from a python program.
Simple example of shortening a URL:
import yourls.client
c = yourls.client.YourlsClient('http://localhost/yourls/yourls-api.php', username='username', password='password')
url = c.shorten('http://autoqa.fedorahosted.org/autoqa', custom='autoqa')
News¶
There has been a change in how errors are thrown in 0.2.0, please see the API documenatation for details.
Code Download¶
- The code can be checked out from the github repository:
git clone git://github.com/tflink/python-yourls.git
- Or the code can be downloaded as a tarball from github:
API Documentation¶
- class yourls.client.YourlsClient(apiurl, username=None, password=None, token=None)[source]¶
- expand(shorturl)[source]¶
Expand a shortened URL to its original form
- Parameters
shorturl – The URL to expand
- Returns
str – The expanded URL
- Raises
YourlsOperationError
- get_url_stats(shorturl)[source]¶
Get statistics about a shortened URL
- Parameters
shorturl – The URL to expand
- Returns
a list of stuff - FIXME, this isn’t complete
- Raises
YourlsOperationError
- shorten(url, custom=None, title=None)[source]¶
Request a shortened URL from YOURLS with an optional keyword request
- Parameters
url (str) – The URL to shorten
custom (str) – The custom keyword to request
title (str) – Use the given title instead of download it from the URL, this will increase performances
- Returns
str – The short URL
- Raises
YourlsOperationError