<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _query_api(self, endpoint, **kwargs):
 """ Query the API. """

        try:
            response = requests.get(
                '{api}/{endpoint}?{args}'.format(
                    api=self.url,
                    endpoint=endpoint,
                    args=urllib.urlencode(kwargs)),
                headers={
                    'Authorization': 'Token {token}'.format(token=self.token)},
                timeout=self.timeout)

        except requests.RequestException as err:
            raise ServiceUnavailable(err)

        if response.status_code == 404:
            raise NoResults()

        try:
            response.raise_for_status()
        except requests.HTTPError as http_err:
            raise ServerException(http_err)

        return response.json()