Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add JSON support to write() in HTTPSync for POST requests #1071 #1072

Merged
merged 4 commits into from
Jan 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ Cryptofeed was originally created by Bryant Moscon, but many others have contrib
* [Thomas Bouamoud](https://github.com/thomasbs17) - <[email protected]>
* [Carlo Eugster](https://github.com/carloe) - <[email protected]>
* [Marten Schlüter](https://github.com/maschlr)
* [Handel Scholze](https://github.com/HandelSM) - <[email protected]>
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## Changelog

### 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
Expand Down
8 changes: 6 additions & 2 deletions cryptofeed/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down
Loading