From 769f2f139282248d3dcd4aa6da5144f1fe18fcf4 Mon Sep 17 00:00:00 2001 From: Anton Avramov Date: Sun, 7 Oct 2018 12:02:24 -0400 Subject: [PATCH] Add support for using a proxy. The parameter is set on init the same way as described in http://docs.python-requests.org/en/master/user/advanced/#proxies and used later on --- krakenex/api.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/krakenex/api.py b/krakenex/api.py index de361f7..ea8e485 100644 --- a/krakenex/api.py +++ b/krakenex/api.py @@ -47,7 +47,7 @@ class API(object): No query rate limiting is performed. """ - def __init__(self, key='', secret=''): + def __init__(self, key='', secret='', proxies={}): """ Create an object with authentication information. :param key: (optional) key identifier for queries to the API @@ -67,6 +67,7 @@ def __init__(self, key='', secret=''): }) self.response = None self._json_options = {} + self.proxies = proxies return def json_options(self, **kwargs): @@ -132,7 +133,8 @@ def _query(self, urlpath, data, headers=None, timeout=None): url = self.uri + urlpath self.response = self.session.post(url, data = data, headers = headers, - timeout = timeout) + timeout = timeout, + proxies = self.proxies) if self.response.status_code not in (200, 201, 202): self.response.raise_for_status()