async def api(self, endpoint, params=None, test=False):
        """Comunicate with the API."""
        data = {}
        url = "{}/{}".format(self._api, endpoint)
        try:
            async with async_timeout.timeout(8, loop=self._loop):
                response = await self._session.get(
                    url, auth=self._auth, headers=HEADERS, params=params
                )

            if response.status == 200:
                self._authenticated = True
                self._connected = True
                if not test:
                    data = await response.json()
            elif response.status == 401:
                self._authenticated = False
                self._connected = True

        except asyncio.TimeoutError as error:
            self._authenticated, self._connected = False, False
            if not test:
                _LOGGER.warning("Timeouterror connecting to Traccar, %s", error)
        except aiohttp.ClientError as error:
            self._authenticated, self._connected = False, False
            if not test:
                _LOGGER.warning("Error connecting to Traccar, %s", error)
        except socket.gaierror as error:
            self._authenticated, self._connected = False, False
            if not test:
                _LOGGER.warning("Error connecting to Traccar, %s", error)
        except TypeError as error:
            self._authenticated, self._connected = False, False
            if not test:
                _LOGGER.warning("Error connecting to Traccar, %s", error)
        except Exception as error:  # pylint: disable=broad-except
            self._authenticated, self._connected = False, False
            if not test:
                _LOGGER.warning("Error connecting to Traccar, %s", error)

        return data
Comunicate with the API.