code: async def async_get_api_key(session, host, port, username=None, password=None, **kwargs):
      
      url = 'http://{host}:{port}/api'.format(host=host, port=str(port))
  
      auth = None
      if username and password:
          auth = aiohttp.BasicAuth(username, password=password)
  
      data = b'{"devicetype": "pydeconz"}'
      response = await async_request(session.post, url, auth=auth, data=data)
  
      api_key = response[0]['success']['username']
      _LOGGER.info("API key: %s", api_key)
      return api_key
docs: Get a new API key for devicetype.