diff --git a/yourls/core.py b/yourls/core.py index 3996707..cee4a32 100644 --- a/yourls/core.py +++ b/yourls/core.py @@ -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.