I’ve been trying (unsuccessfully) on connecting to the birdeye.so API to my DNN (coded in Python). I have the standard plan and I’ve been using the updated APIs since their move away from public APIs (ie i’m now using https://public-api.birdeye.so/defi/price and https://public-api.birdeye.so/defi/history_price etc rather than their previous public api https://public-api.birdeye.so/public/history_price) as well as my API key, and it is not working. I’ve tried changing my dns to the google dns etc on my browser and it doesn’t fix the problem. After trying many things, I’m thinking it may be on their end, but I am not completely sure. Below I will include the error message and, below that, the code for implementation of the API so you can see it it correct. I have replaced my actual API Key with a redacted note for example purposes obviously. Any help would be so GREATLY appreciated, as I’ve been spinning my wheels for hours and wondering if it’s an issue on their end or my end. Thank you for your help.
This is the error message that is showing up:
--------------------------------------------------------------------------
`gaierror Traceback (most recent call last)
File ~anaconda3Libsite-packagesurllib3connection.py:174, in HTTPConnection._new_conn(self)
173 try:
--> 174 conn = connection.create_connection(
175 (self._dns_host, self.port), self.timeout, **extra_kw
176 )
178 except SocketTimeout:
File ~anaconda3Libsite-packagesurllib3utilconnection.py:72, in create_connection(address, timeout, source_address, socket_options)
68 return six.raise_from(
69 LocationParseError(u"'%s', label empty or too long" % host), None
70 )
---> 72 for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
73 af, socktype, proto, canonname, sa = res
File ~anaconda3Libsocket.py:962, in getaddrinfo(host, port, family, type, proto, flags)
961 addrlist = []
--> 962 for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
963 af, socktype, proto, canonname, sa = res
gaierror: [Errno 11001] getaddrinfo failed
During handling of the above exception, another exception occurred:
NewConnectionError Traceback (most recent call last)
File ~anaconda3Libsite-packagesurllib3connectionpool.py:714, in HTTPConnectionPool.urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, **response_kw)
713 # Make the request on the httplib connection object.
--> 714 httplib_response = self._make_request(
715 conn,
716 method,
717 url,
718 timeout=timeout_obj,
719 body=body,
720 headers=headers,
721 chunked=chunked,
722 )
724 # If we're going to release the connection in ``finally:``, then
725 # the response doesn't need to know about the connection. Otherwise
726 # it will also try to release it and we'll have a double-release
727 # mess.
File ~anaconda3Libsite-packagesurllib3connectionpool.py:403, in HTTPConnectionPool._make_request(self, conn, method, url, timeout, chunked, **httplib_request_kw)
402 try:
--> 403 self._validate_conn(conn)
404 except (SocketTimeout, BaseSSLError) as e:
405 # Py2 raises this as a BaseSSLError, Py3 raises it as socket timeout.
File ~anaconda3Libsite-packagesurllib3connectionpool.py:1053, in HTTPSConnectionPool._validate_conn(self, conn)
1052 if not getattr(conn, "sock", None): # AppEngine might not have `.sock`
-> 1053 conn.connect()
1055 if not conn.is_verified:
File ~anaconda3Libsite-packagesurllib3connection.py:363, in HTTPSConnection.connect(self)
361 def connect(self):
362 # Add certificate verification
--> 363 self.sock = conn = self._new_conn()
364 hostname = self.host
File ~anaconda3Libsite-packagesurllib3connection.py:186, in HTTPConnection._new_conn(self)
185 except SocketError as e:
--> 186 raise NewConnectionError(
187 self, "Failed to establish a new connection: %s" % e
188 )
190 return conn
NewConnectionError: <urllib3.connection.HTTPSConnection object at 0x000002003B400B50>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed
During handling of the above exception, another exception occurred:
MaxRetryError Traceback (most recent call last)
File ~AppDataRoamingPythonPython311site-packagesrequestsadapters.py:486, in HTTPAdapter.send(self, request, stream, timeout, verify, cert, proxies)
485 try:
--> 486 resp = conn.urlopen(
487 method=request.method,
488 url=url,
489 body=request.body,
490 headers=request.headers,
491 redirect=False,
492 assert_same_host=False,
493 preload_content=False,
494 decode_content=False,
495 retries=self.max_retries,
496 timeout=timeout,
497 chunked=chunked,
498 )
500 except (ProtocolError, OSError) as err:
File ~anaconda3Libsite-packagesurllib3connectionpool.py:798, in HTTPConnectionPool.urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, **response_kw)
796 e = ProtocolError("Connection aborted.", e)
--> 798 retries = retries.increment(
799 method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]
800 )
801 retries.sleep()
File ~anaconda3Libsite-packagesurllib3utilretry.py:592, in Retry.increment(self, method, url, response, error, _pool, _stacktrace)
591 if new_retry.is_exhausted():
--> 592 raise MaxRetryError(_pool, url, error or ResponseError(cause))
594 log.debug("Incremented Retry for (url='%s'): %r", url, new_retry)
MaxRetryError: HTTPSConnectionPool(host='api.birdseye.so', port=443): Max retries exceeded with url: /defi/history_price?symbol=SOL-USD (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x000002003B400B50>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed'))
During handling of the above exception, another exception occurred:
ConnectionError Traceback (most recent call last)
Cell In[4], line 88
85 print("No data to process.")
87 if __name__ == '__main__':
---> 88 main('SOL-USD') # Update the pair symbol as needed
Cell In[4], line 60, in main(pair_symbol)
59 def main(pair_symbol):
---> 60 df = fetch_coin_history(pair_symbol)
61 if df is not None:
62 sequences, next_prices, scaler = preprocess_data(df)
Cell In[4], line 16, in fetch_coin_history(pair_symbol, retry_attempts, delay_seconds)
14 headers = {'Authorization': 'Bearer MyRedactedAPIKey'}
15 for attempt in range(retry_attempts):
---> 16 response = requests.get(base_url, headers=headers)
17 if response.status_code == 200:
18 print("Data fetched successfully.")
File ~AppDataRoamingPythonPython311site-packagesrequestsapi.py:73, in get(url, params, **kwargs)
62 def get(url, params=None, **kwargs):
63 r"""Sends a GET request.
64
65 :param url: URL for the new :class:`Request` object.
(...)
70 :rtype: requests.Response
71 """
---> 73 return request("get", url, params=params, **kwargs)
File ~AppDataRoamingPythonPython311site-packagesrequestsapi.py:59, in request(method, url, **kwargs)
55 # By using the 'with' statement we are sure the session is closed, thus we
56 # avoid leaving sockets open which can trigger a ResourceWarning in some
57 # cases, and look like a memory leak in others.
58 with sessions.Session() as session:
---> 59 return session.request(method=method, url=url, **kwargs)
File ~AppDataRoamingPythonPython311site-packagesrequestssessions.py:589, in Session.request(self, method, url, params, data, headers, cookies, files, auth, timeout, allow_redirects, proxies, hooks, stream, verify, cert, json)
584 send_kwargs = {
585 "timeout": timeout,
586 "allow_redirects": allow_redirects,
587 }
588 send_kwargs.update(settings)
--> 589 resp = self.send(prep, **send_kwargs)
591 return resp
File ~AppDataRoamingPythonPython311site-packagesrequestssessions.py:703, in Session.send(self, request, **kwargs)
700 start = preferred_clock()
702 # Send the request
--> 703 r = adapter.send(request, **kwargs)
705 # Total elapsed time of the request (approximately)
706 elapsed = preferred_clock() - start
File ~AppDataRoamingPythonPython311site-packagesrequestsadapters.py:519, in HTTPAdapter.send(self, request, stream, timeout, verify, cert, proxies)
515 if isinstance(e.reason, _SSLError):
516 # This branch is for urllib3 v1.22 and later.
517 raise SSLError(e, request=request)
--> 519 raise ConnectionError(e, request=request)
521 except ClosedPoolError as e:
522 raise ConnectionError(e, request=request)
ConnectionError: HTTPSConnectionPool(host='api.birdseye.so', port=443): Max retries exceeded with url: /defi/history_price?symbol=SOL-USD (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x000002003B400B50>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed'))`
And this is the way I have the API connected in my code:
def fetch_coin_history(pair_symbol, retry_attempts=5, delay_seconds=10):
"""Fetch historical price data for a given trading pair symbol using Birdseye Crypto API."""
base_url = f"https://api.birdseye.so/defi/history_price?symbol={pair_symbol}"
headers = {'Authorization': 'Bearer MyRedactedAPI KEY'}
for attempt in range(retry_attempts):
response = requests.get(base_url, headers=headers)
if response.status_code == 200:
print("Data fetched successfully.")
data = response.json()
if 'data' in data and data['data']: # Ensure the key 'data' contains useful
information
return pd.DataFrame(data['data'])
else:
print("Price history is missing or empty.")
return None
else:
print(f"Attempt {attempt+1} of {retry_attempts}: Failed to fetch data: HTTP
{response.status_code}, Details: {response.text}")
time.sleep(delay_seconds) # Wait before retrying
return None`
I’ve been using the updated APIs since their move away from public APIs (ie i’m now using https://public-api.birdeye.so/defi/price and https://public-api.birdeye.so/defi/history_price etc rather than their previous public api https://public-api.birdeye.so/public/history_price) as well as my API key, and it is not working. I’ve tried changing my dns to the google dns etc on my browser and it doesn’t fix the problem. After trying many things, I’m thinking it may be on their end, but I am not completely sure. Any help would be appreciated.
Viper is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.