yourls/core.py
def shorten(self, url, keyword=None, title=None):
        """Shorten URL with optional keyword and title.

        Parameters:
            url: URL to shorten.
            keyword: Optionally choose keyword for short URL, otherwise automatic.
            title: Optionally choose title, otherwise taken from web page.

        Returns:
            ShortenedURL: Shortened URL and associated data.

        Raises:
            ~yourls.exceptions.YOURLSKeywordExistsError: The passed keyword
                already exists.

                .. note::

                    This exception has a ``keyword`` attribute.

            ~yourls.exceptions.YOURLSURLExistsError: The URL has already been
                shortened.

                .. note::

                    This exception has a ``url`` attribute, which is an instance
                    of :py:class:`ShortenedURL` for the existing short URL.

            ~yourls.exceptions.YOURLSNoURLError: URL missing.

            ~yourls.exceptions.YOURLSNoLoopError: Cannot shorten a shortened URL.

            ~yourls.exceptions.YOURLSAPIError: Unhandled API error.

            ~yourls.exceptions.YOURLSHTTPError: HTTP error with response from
                YOURLS API.

            requests.exceptions.HTTPError: Generic HTTP error.
        """
        data = dict(action='shorturl', url=url, keyword=keyword, title=title)
        jsondata = self._api_request(params=data)

        url = _json_to_shortened_url(jsondata['url'], jsondata['shorturl'])

        return url
def shorten(self, url, keyword=None, title=None):
        data = dict(action='shorturl', url=url, keyword=keyword, title=title)
        jsondata = self._api_request(params=data)

        url = _json_to_shortened_url(jsondata['url'], jsondata['shorturl'])

        return url
def shorten ( self , url , keyword = None , title = None ) : data = dict ( action = 'shorturl' , url = url , keyword = keyword , title = title ) jsondata = self . _api_request ( params = data ) url = _json_to_shortened_url ( jsondata [ 'url' ] , jsondata [ 'shorturl' ] ) return url
Shorten URL with optional keyword and title.

        Parameters:
            url: URL to shorten.
            keyword: Optionally choose keyword for short URL, otherwise automatic.
            title: Optionally choose title, otherwise taken from web page.

        Returns:
            ShortenedURL: Shortened URL and associated data.

        Raises:
            ~yourls.exceptions.YOURLSKeywordExistsError: The passed keyword
                already exists.

                .. note::

                    This exception has a ``keyword`` attribute.

            ~yourls.exceptions.YOURLSURLExistsError: The URL has already been
                shortened.

                .. note::

                    This exception has a ``url`` attribute, which is an instance
                    of :py:class:`ShortenedURL` for the existing short URL.

            ~yourls.exceptions.YOURLSNoURLError: URL missing.

            ~yourls.exceptions.YOURLSNoLoopError: Cannot shorten a shortened URL.

            ~yourls.exceptions.YOURLSAPIError: Unhandled API error.

            ~yourls.exceptions.YOURLSHTTPError: HTTP error with response from
                YOURLS API.

            requests.exceptions.HTTPError: Generic HTTP error.
Shorten URL with optional keyword and title .