<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def single_value(self, key, ts=None, direction=None):
 """Return a single value for a series. You can supply a timestamp as the ts argument, otherwise the search defaults to the current time. The direction argument can be one of "exact", "before", "after", or "nearest". :param string key: the key for the series to use :param ts: (optional) the time to begin searching from :type ts: ISO8601 string or Datetime object :param string direction: criterion for the search :rtype: :class:`tempodb.response.Response` with a :class:`tempodb.protocol.objects.SingleValue` object as the data payload"""


        url = make_series_url(key)
        url = urlparse.urljoin(url + '/', 'single')

        if ts is not None:
            vts = check_time_param(ts)
        else:
            vts = None

        params = {
            'ts': vts,
            'direction': direction
        }

        url_args = endpoint.make_url_args(params)
        url = '?'.join([url, url_args])
        resp = self.session.get(url)
        return resp