From 8cbda5038a1c8cb0cdea8c93188a95450fb20418 Mon Sep 17 00:00:00 2001 From: HandelSM Date: Wed, 8 Jan 2025 14:44:59 -0300 Subject: [PATCH 1/3] Add is_data_json flag to write method in HTTPSync to support JSON payloads (#1071) --- cryptofeed/connection.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/cryptofeed/connection.py b/cryptofeed/connection.py index 13c79a08e..48661d987 100644 --- a/cryptofeed/connection.py +++ b/cryptofeed/connection.py @@ -56,9 +56,13 @@ def read(self, address: str, params=None, headers=None, json=False, text=True, u r = requests.get(address, headers=headers, params=params) return self.process_response(r, address, json=json, text=text, uuid=uuid) - def write(self, address: str, data=None, json=False, text=True, uuid=None): + def write(self, address: str, data=None, json=False, text=True, uuid=None, is_data_json=False): LOG.debug("HTTPSync: post to %s", address) - r = requests.post(address, data=data) + if (is_data_json): + r = requests.post(address, json=data) + else: + r = requests.post(address, data=data) + return self.process_response(r, address, json=json, text=text, uuid=uuid) From 16a12adf9beb720df359ef1cfbe223feae0fee22 Mon Sep 17 00:00:00 2001 From: HandelSM Date: Wed, 8 Jan 2025 14:44:59 -0300 Subject: [PATCH 2/3] Add is_data_json flag to write method in HTTPSync to support JSON payloads (#1071) --- AUTHORS.md | 1 + CHANGES.md | 3 +++ cryptofeed/connection.py | 8 ++++++-- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/AUTHORS.md b/AUTHORS.md index 9e1d95a71..61c069f37 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -18,3 +18,4 @@ Cryptofeed was originally created by Bryant Moscon, but many others have contrib * [Thomas Bouamoud](https://github.com/thomasbs17) - * [Carlo Eugster](https://github.com/carloe) - * [Marten Schlüter](https://github.com/maschlr) +* [Handel Scholze](https://github.com/HandelSM) - diff --git a/CHANGES.md b/CHANGES.md index 32c921495..68341dc78 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,8 @@ ## Changelog +### [Unreleased] + * Added `is_data_json` to `write()` in `HTTPSync` from `connection.py` to support JSON payloads (#1071) + ### 2.4.1 * Bugfix: Handle empty nextFundingRate in OKX * Bugfix: Handle null next_funding_time and estimated_rate in HuobiSwap funding diff --git a/cryptofeed/connection.py b/cryptofeed/connection.py index 13c79a08e..48661d987 100644 --- a/cryptofeed/connection.py +++ b/cryptofeed/connection.py @@ -56,9 +56,13 @@ def read(self, address: str, params=None, headers=None, json=False, text=True, u r = requests.get(address, headers=headers, params=params) return self.process_response(r, address, json=json, text=text, uuid=uuid) - def write(self, address: str, data=None, json=False, text=True, uuid=None): + def write(self, address: str, data=None, json=False, text=True, uuid=None, is_data_json=False): LOG.debug("HTTPSync: post to %s", address) - r = requests.post(address, data=data) + if (is_data_json): + r = requests.post(address, json=data) + else: + r = requests.post(address, data=data) + return self.process_response(r, address, json=json, text=text, uuid=uuid) From ebec079aed399d580e5a554b7e10ef848d2c47bb Mon Sep 17 00:00:00 2001 From: Handel Date: Sun, 26 Jan 2025 19:08:21 -0300 Subject: [PATCH 3/3] Update CHANGES.md --- CHANGES.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 68341dc78..6a9c032b9 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,9 +1,7 @@ ## Changelog -### [Unreleased] - * Added `is_data_json` to `write()` in `HTTPSync` from `connection.py` to support JSON payloads (#1071) - ### 2.4.1 + * Update: Added `is_data_json` to `write()` in `HTTPSync` from `connection.py` to support JSON payloads (#1071) * Bugfix: Handle empty nextFundingRate in OKX * Bugfix: Handle null next_funding_time and estimated_rate in HuobiSwap funding * Update: transitioned from Coinbase Pro (retired) to Coinbase Advanced Trade