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

Inconsistent behavior, some API methods returning {'error': ['EAPI:Invalid key']} from API #104

Closed
mark-antony1 opened this issue Dec 5, 2018 · 9 comments
Labels

Comments

@mark-antony1
Copy link

mark-antony1 commented Dec 5, 2018

Versions

OS:       Mac Mojave
Python:   3.6
krakenex: Latest

What are you trying to achieve?

using the query orders function from the kraken api

# code sample *trade variable defined properly above*
import krakenex
self.client = krakenex.API(config['public_api_key'], config['private_api_key'])
trades = self.client.query_private(TRADES_HISTORY)[RESULT][TRADES]
order_info = self.client.query_private(QUERY_ORDERS, {'oflags': 'viqc', 'txid': [trade['orderId']]})
print('trades', trades)
print('order_info', order_info)

What do you expect to happen?

For the first api call to return the trade history on the account.
For the second api call to return the relevant information for the requested order.

What happens instead?

The first api call returns the requested trades normally.
The second api call returns an error

{'error': ['EAPI:Invalid key']}
# error message
@veox
Copy link
Owner

veox commented Dec 5, 2018

You have a mix-up in API method names and arguments for them.

Since you don't show what QUERY_ORDERS is, I'll just point you to the docs.

@veox veox added the invalid label Dec 5, 2018
@veox
Copy link
Owner

veox commented Dec 5, 2018

If I understand correctly, you'll want to drop the oflags.

@mark-antony1
Copy link
Author

mark-antony1 commented Dec 6, 2018

Thanks for the response @veox !

  1. I believe the API method names is correct. Straight from the docs "Query orders info
    URL: https://api.kraken.com/0/private/QueryOrders"

The QUERY_ORDERS is an internal variable that resolves to 'QueryOrders' which is correct to my knowledge.

  1. Dropping the oflags so the code is
    order_info = self.client.query_private(QUERY_ORDERS, {'txid': [trade['orderId']]})
    produces the same result as before

Any ideas on how to solve this issue?

@veox
Copy link
Owner

veox commented Dec 6, 2018

Dropping the oflags so the code is (...)

The oflags is still present in the line you quote. Did you or did you not drop it?..

As you may see from the docs, 'QueryOrders' does not have an oflags parameter - which why I suggested dropping it. However - just checked - adding/removing the parameter has no effect - the response always has 'oflags': 'fciq' set. In other words, this is not the cause of your issue.


The error is therefore likely in your self.client implementation. I am not clairvoyant, but you are likely overriding the session, resetting the key, or doing something of the sort.

Any ideas on how to solve this issue?

Simplify your example into a copy-pastable script.

@veox veox closed this as completed Dec 6, 2018
@veox
Copy link
Owner

veox commented Dec 6, 2018

Reopen if you can demonstrate that the issue is with krakenex.

@mark-antony1
Copy link
Author

I have isolated and reproduced the problem with 6 lines of code. I am fairly certain this is specific to krakenex.

import krakenex
client = krakenex.API('OYX...', 'QWR...')
trades = client.query_private('TradesHistory')['result']['trades']
order_info = client.query_private('QueryOrders', {'trades': 'true', 'txid': ['O..']})
print('orderinfo', order_info2)
print('trades', trades)

I am getting the same behavior as before where the variable trades is defined and returning correctly, however the order_info from QueryOrders is still returning {'error': ['EAPI:Invalid key']}.

There is no possibility of the client getting reset, or overriding the session in this case. It appears to be an issue with Krakenex or that Kraken has changed what it returns. The most likely scenarios that I can think of are as followed.

  1. Krakenex is returning the incorrect error message for my request
  2. Kraken is returning the incorrect error message for my request
  3. Krakenex is returning an error message that is a catch all for unknown errors

@veox veox reopened this Dec 6, 2018
@veox
Copy link
Owner

veox commented Dec 6, 2018

You are still not copying the actual code that you're using. :/

This works perfectly fine for me:

#!/usr/bin/env python
# https://github.com/veox/python3-krakenex/issues/104#issuecomment-444894546

import krakenex

client = krakenex.API('foo...', 'bar...')

trades = client.query_private('TradesHistory')['result']['trades']
print('trades', trades)

print('-'*72)

order_info = client.query_private('QueryOrders', {'trades': 'true', 'txid': 'O...'})
print('orderinfo', order_info)

So, this is not specific to krakenex.

It could be something about Mac, or the krakenex version you're using, although both are unlikely. (BTW, Latest is not helpful. If it's git master, then specify a commit with git describe --always, because master could have drifted. If it's a stable installed through pip, then specify through pip freeze | grep krakenex.)

But more probably, since we've eliminated it being something in your code, it's your key not having permissions for the action. For example, you could've disallowed querying closed orders, or something like that.

@philippose
Copy link

Hi,
The first thought that went through my mind when I saw this issue is that maybe the API key does not have the required permissions.

I would suggest that you first verify on the Kraken website whether you have supplied your API key with the right permissions.

Regards,
Philippose

@veox veox added the stale label Dec 21, 2018
@veox
Copy link
Owner

veox commented Jul 13, 2019

Closing as stale.

@veox veox closed this as completed Jul 13, 2019
@veox veox removed the invalid label Sep 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants