{"record":{"id":"335c0a5ae3fce702","repo":"yt-dlp/yt-dlp","slug":"unable-to-get-available-api-hosts","errorCode":null,"errorMessage":"Unable to get available API hosts","messagePattern":"Unable to get available API hosts","errorType":"exception","errorClass":"ExtractorError","httpStatus":null,"severity":"error","filePath":"yt_dlp/extractor/audius.py","lineNumber":32,"sourceCode":"            response_data = response.get('data')\n            if response_data is not None:\n                return response_data\n            if len(response) == 1 and 'message' in response:\n                raise ExtractorError('API error: {}'.format(response['message']),\n                                     expected=True)\n        raise ExtractorError('Unexpected API response')\n\n    def _select_api_base(self):\n        \"\"\"Selecting one of the currently available API hosts\"\"\"\n        response = super()._download_json(\n            'https://api.audius.co/', None,\n            note='Requesting available API hosts',\n            errnote='Unable to request available API hosts')\n        hosts = self._get_response_data(response)\n        if isinstance(hosts, list):\n            self._API_BASE = random.choice(hosts)\n            return\n        raise ExtractorError('Unable to get available API hosts')\n\n    @staticmethod\n    def _prepare_url(url, title):\n        \"\"\"\n        Audius removes forward slashes from the uri, but leaves backslashes.\n        The problem is that the current version of Chrome replaces backslashes\n        in the address bar with a forward slashes, so if you copy the link from\n        there and paste it into youtube-dl, you won't be able to download\n        anything from this link, since the Audius API won't be able to resolve\n        this url\n        \"\"\"\n        url = urllib.parse.unquote(url)\n        title = urllib.parse.unquote(title)\n        if '/' in title or '%2F' in title:\n            fixed_title = title.replace('/', '%5C').replace('%2F', '%5C')\n            return url.replace(title, fixed_title)\n        return url\n","sourceCodeStart":14,"sourceCodeEnd":50,"githubUrl":"https://github.com/yt-dlp/yt-dlp/blob/81ecd58b1394793e6da9998cc19fdb45657f1685/yt_dlp/extractor/audius.py#L14-L50","documentation":"Raised by AudiusBaseIE._select_api_base: host discovery GETs https://api.audius.co/ and expects get_response_data() to yield a LIST of API host URLs to random.choice() from. If data is not a list, no _API_BASE can be set and every subsequent request is impossible.","triggerScenarios":"The discovery endpoint responds 200 but its data is not a list - schema change on Audius' side, a message-only error dict (which first surfaces as 'API error'), or a mangled response from a proxy.","commonSituations":"Audius changing the discovery contract; transient gateway states; SSL-inspecting or captive-portal networks returning their own JSON.","solutions":["Retry the command: discovery runs fresh each time and transient states pass","Open https://api.audius.co/ in a browser; it should print {'data': [...]} with host URLs","Update yt-dlp","Check for interfering proxies if the payload looks like an error page"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"import json, urllib.request\nresp = json.load(urllib.request.urlopen('https://api.audius.co/'))\nif not isinstance(resp.get('data'), list):\n    wait_and_retry()  # discovery unusable; extractor would raise this error","typeGuard":null,"tryCatchPattern":"for attempt in range(3):\n    try:\n        info = ydl.extract_info(url, download=False)\n        break\n    except yt_dlp.utils.ExtractorError as e:\n        if 'Unable to get available API hosts' not in str(e) or attempt == 2:\n            raise\n        time.sleep(5)  # discovery endpoint transient failure","preventionTips":["Pre-flight https://api.audius.co/ and confirm it returns a data list before batch jobs","Retry discovery failures with short backoff before treating Audius as down","Disable SSL-inspecting proxies for api.audius.co; they corrupt the discovery payload"],"tags":["audius","host-discovery","api-bootstrap","yt-dlp"],"backgroundTag":"service-discovery-failed","analyzedSha":"81ecd58b1394793e6da9998cc19fdb45657f1685","analyzedAt":"2026-08-22T12:21:25.439Z","schemaVersion":2},"datasetVersion":"2026-08-22T14:17:55.899Z"}