krakenex documentation¶
Interface classes¶
General-use interface provided by krakenex.
Internally, classes are in separate modules, but they are also exported to the top-level namespace, so the following uses are possible:
# recommended, unlikely to result in namespace collisions
import krakenex
kraken = krakenex.API()
# OK for simple scripts
from krakenex import *
kraken = API()
# can be explicit in both cases
# <some import form here>
kraken = krakenex.api.API()
-
class
krakenex.API(key='', secret='')[source]¶ Bases:
objectMaintains a single session between this machine and Kraken.
Specifying a key/secret pair is optional. If not specified, private queries will not be possible.
The
sessionattribute is arequests.Sessionobject. Customise networking options by manipulating it.Query responses, as received by
requests, are retained as attributeresponseof this object. It is overwritten on each query.Note
No query rate limiting is performed.
-
__init__(key='', secret='')[source]¶ Create an object with authentication information.
Parameters: Returns: None
-
__module__= 'krakenex.api'¶
-
_query(urlpath, data, headers=None, timeout=None)[source]¶ Low-level query handling.
Note
Use
query_private()orquery_public()unless you have a good reason not to.Parameters: Returns: requests.Response.json()-deserialised Python objectRaises: requests.HTTPError: if response status not successful
-
_sign(data, urlpath)[source]¶ Sign request data according to Kraken’s scheme.
Parameters: Returns: signature digest
-
json_options(**kwargs)[source]¶ Set keyword arguments to be passed to JSON deserialization.
Parameters: kwargs – passed to requests.Response.json()Returns: this instance for chaining
-
load_key(path)[source]¶ Load key and secret from file.
Expected file format is key and secret on separate lines.
Parameters: path (str) – path to keyfile Returns: None
-
query_private(method, data=None, timeout=None)[source]¶ Performs an API query that requires a valid key/secret pair.
Parameters: - method (str) – API method name
- data (dict) – (optional) API request parameters
- timeout (int or float) – (optional) if not
None, arequests.HTTPErrorwill be thrown aftertimeoutseconds if a response has not been received
Returns: requests.Response.json()-deserialised Python object
-
query_public(method, data=None, timeout=None)[source]¶ Performs an API query that does not require a valid key/secret pair.
Parameters: - method (str) – API method name
- data (dict) – (optional) API request parameters
- timeout (int or float) – (optional) if not
None, arequests.HTTPErrorwill be thrown aftertimeoutseconds if a response has not been received
Returns: requests.Response.json()-deserialised Python object
-