Skip to content

Commit 98916a0

Browse files
authored
feat: Api support timeout setting
1 parent 782b688 commit 98916a0

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

hyperliquid/api.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,17 @@
1010

1111

1212
class API:
13-
def __init__(self, base_url=None):
13+
def __init__(self, base_url=None, timeout=None):
1414
self.base_url = base_url or MAINNET_API_URL
1515
self.session = requests.Session()
1616
self.session.headers.update({"Content-Type": "application/json"})
1717
self._logger = logging.getLogger(__name__)
18+
self.timeout = timeout
1819

1920
def post(self, url_path: str, payload: Any = None) -> Any:
2021
payload = payload or {}
2122
url = self.base_url + url_path
22-
response = self.session.post(url, json=payload)
23+
response = self.session.post(url, json=payload, timeout=self.timeout)
2324
self._handle_exception(response)
2425
try:
2526
return response.json()

0 commit comments

Comments
 (0)