From 179a957eec279be6f96a01defdb6cb170484392b Mon Sep 17 00:00:00 2001 From: Victor Ramirez Date: Tue, 15 Oct 2024 18:30:56 +0000 Subject: [PATCH] Update Request Header This MR adds user agent metadata to the request header --- coinmetrics/api_client.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/coinmetrics/api_client.py b/coinmetrics/api_client.py index d189910..08bbf8a 100644 --- a/coinmetrics/api_client.py +++ b/coinmetrics/api_client.py @@ -81,7 +81,8 @@ def run( on_close = self._on_close ws = websocket.WebSocketApp( - self.ws_url, on_message=on_message, on_error=on_error, on_close=on_close + self.ws_url, on_message=on_message, on_error=on_error, on_close=on_close, + header={"User-Agent": f"Coinmetrics-Python-API-Client/{version}"} ) self.ws = ws @@ -131,12 +132,12 @@ def __init__( api_path_prefix = "community-" self._api_base_url = "https://{}api.coinmetrics.io/v4".format(api_path_prefix) self._ws_api_base_url = "wss://{}api.coinmetrics.io/v4".format(api_path_prefix) - self._http_header = {"Api-Client-Version": version} + self._http_header = {"User-Agent": f"Coinmetrics-Python-API-Client/{version}"} self._proxies = {"http": proxy_url, "https": proxy_url} if session is None: self._session = requests.Session() self._session.verify = self._verify_ssl_certs - self._session.headers.update({"Api-Client-Version": version}) + self._session.headers.update({"User-Agent": f"Coinmetrics-Python-API-Client/{version}"}) self._session.proxies.update({"http": proxy_url, "https": proxy_url}) # type: ignore else: self._session = session