question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Invalid API Key Bitmex

See original GitHub issue
  • OS: Windows 10
  • Programming Language version: Python 2.7.14
  • CCXT version: 1.10.1265
  • Exchange: Bitmex
  • Method: Authentication error
print bitmex.fetch_balance()
  File "C:\Python27\lib\site-packages\ccxt\bitmex.py", line 18
3, in fetch_balance
    response = self.privateGetUserMargin({'currency': 'all'})
  File "C:\Python27\lib\site-packages\ccxt\base\exchange.py",
line 291, in request
    return self.fetch2(path, api, method, params, headers, bod
y)
  File "C:\Python27\lib\site-packages\ccxt\base\exchange.py",
line 288, in fetch2
    return self.fetch(request['url'], request['method'], reque
st['headers'], request['body'])
  File "C:\Python27\lib\site-packages\ccxt\base\exchange.py",
line 361, in fetch
    self.handle_errors(response.status_code, response.reason,
url, method, self.last_response_headers, self.last_http_respon
se)
  File "C:\Python27\lib\site-packages\ccxt\bitmex.py", line 48
0, in handle_errors
    raise AuthenticationError(self.id + ' ' + self.json(respon
se))
ccxt.base.errors.AuthenticationError: bitmex {"error":{"messag
e":"Invalid API Key.","name":"HTTPError"}}

I’m getting this error, I deleted the old api and generated a new one but still the same error. The code is below :

import ccxt

bitmex = ccxt.bitmex({'apiKey':'keyhere', 'secret':'secrethere'})

print bitmex.fetch_balance()

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

12reactions
kroitorcommented, Mar 3, 2018

@kk3nny

Is there a way that I can run the testnet keys?

Yes, there is:

import ccxt
exchange = ccxt.bitmex({
    'apiKey': 'YOUR_TESTNET_KEY',
    'secret': 'YOUR_TESTNET_SECRET',
})
if 'test' in exchange.urls:
    exchange.urls['api'] = exchange.urls['test'] # ←----- switch the base URL to testnet
print(exchange.fetch_balance())

Let us know if this does not help. Closing it for now, if you don’t mind. Feel free to reopen it or just ask questions if you have any. Thx!

6reactions
kk3nnycommented, Apr 1, 2018

Thank you so much! I’m very grateful that you created such an amazing library which helps people like me to achieve their desired goal.

Read more comments on GitHub >

github_iconTop Results From Across the Web

API Keys Usage - BitMEX
API Key Permissions ... By default, API Keys can only read basic data, such as positions, margin, orders, and executions. They cannot submit...
Read more >
Bitmex api explorer. Only KYC verified accounts can ... - Unoeste
Bitmex api explorer. Only KYC verified accounts can access the BitMEX API. Sync and crank sensors can be a combination of Hall effect,...
Read more >
Fix exchange connection errors - 3Commas Help Center
"API keys are no longer valid or incorrect" is the most frequent error when you can't connect the exchange account. It's impossible to...
Read more >
BITMEX TRADING BOT - How to get API Key from ... - YouTube
bitmexbot #bitmexTradingBot #bitmexAiBotBITMEXCopy trading has never been so easy, thanks to our Autopilot Crypto Trading Bots !
Read more >
python - Bitmex Signature Not Valid - Stack Overflow
What is wrong in this code? Please assume that correct api key and secret provided. I am getting the following response. 401 {"error":{"message" ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found