Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions yourls/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,36 @@ def shorten(self, url, keyword=None, title=None):

return url

def list(self):
"""List all URL

Returns:
ShortenedURL[]: List of Shortened URL and associated data.

Raises:
requests.exceptions.HTTPError: Generic HTTP Error
"""
data = dict(action='list')
jsondata = self._api_request(params=data)
urls = []
for url in jsondata['result']:
urls.append(_json_to_shortened_url(url, url['shorturl']))

return urls

def delete(self, keyword):
"""Delete URL by keyword

Returns:
Int: Number of deleted URL

Raises:
requests.exceptions.HTTPError: Generic HTTP Error
"""
data = dict(action='delete', keyword=keyword)
jsondata = self._api_request(params=data)
return jsondata['result']

def expand(self, short):
"""Expand short URL or keyword to long URL.

Expand Down