Open sandybradley opened 5 years ago
EMX API keys are environment specific. Are you using a testnet API key? When you’re looking at your API key settings, does the browser address bar say testnet.emx.com?
Thanks for trying the API!
On Jun 7, 2019, at 10:10, sandybradley notifications@github.com wrote:
Following the online guide, I was able to use the publicClient effectively but the authenticated client returns:
HTTP 400 Error: invalid api key
I used the following code excerpt:
const EMX = require('emx'); const authedClient = new EMX.AuthenticatedClient( '---*-', '*****', 'https://api.testnet.emx.com', );
let buyParams = { contractCode: 'BTCM19', side: 'buy', size: '0.0001', // BTC price: '7500', // USD type: 'limit', }; authedClient.placeOrder(buyParams, callback);
function callback(error, response, data){ if (error) { // handle the error console.log(error.message); } else { // work with data console.log(data); } }
Key and secret are correctly copied from EMX account. Does it have something to do with testnet for API requests?
Similarly for the authenticated websocket, I got the following error:
not authenticated for trading channel (upstream)
Code: const EMX = require('emx'); const websocket = new EMX.WebSocketClient( '', '','https://api.testnet.emx.com', ); websocket.on('open', () => { websocket.subscribe({ contractCodes: [], channels: [ "trading"] }); });
let buyParams = { contractCode: 'BTCM19', side: 'buy', size: '0.0001', // BTC price: '7500', // USD type: 'limit', }; websocket.placeOrder(buyParams);
Appreciate any help. Thanks.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.
Hi. Thank you for your response. I am trying to trade on my real account. API settings are from there. Accordingly, I adjusted the apiURI. Now I am getting a different error:
HTTP 400 Error: invalid signature
Hi, do you still have that issue? If so, can you please post your updated script (without private info of course)?
Hi. Thanks for your response. Yes I do still have this issue. I have been unable to sumbit an API order.
Here's the code:
const EMX = require('emx'); const publicClient = new EMX.PublicClient();
const authedClient = new EMX.AuthenticatedClient( 'key', 'secret', 'https://api.emx.com', );
function callback(error, response, data){ if (error) { // handle the error console.log(error.message); } else { // work with data console.log(data); } } // set buy order let buyParams = { contractCode: 'BTCM19', side: 'buy', size: '0.0001', // BTC price: '7500.00', // USD type: 'limit', }; authedClient.placeOrder(buyParams, callback);
Here's the error:
HTTP 400 Error: invalid signature
Key and secret were copied directly from the mainnet trading account on EMX. I tried with two different keys. Same response. Also the python client gives the same result. Any advice?
Following the online guide, I was able to use the publicClient effectively but the authenticated client returns:
HTTP 400 Error: invalid api key
I used the following code excerpt:
const EMX = require('emx'); const authedClient = new EMX.AuthenticatedClient( '*---**-***', '**', 'https://api.testnet.emx.com', );
let buyParams = { contractCode: 'BTCM19', side: 'buy', size: '0.0001', // BTC price: '7500', // USD type: 'limit', }; authedClient.placeOrder(buyParams, callback);
function callback(error, response, data){ if (error) { // handle the error console.log(error.message); } else { // work with data console.log(data); } }
Key and secret are correctly copied from EMX account. Does it have something to do with testnet for API requests?
Similarly for the authenticated websocket, I got the following error:
not authenticated for trading channel (upstream)
Code: const EMX = require('emx'); const websocket = new EMX.WebSocketClient( '', '','https://api.testnet.emx.com', );
websocket.on('open', () => { websocket.subscribe({ contractCodes: [], channels: [ "trading"] }); });
let buyParams = { contractCode: 'BTCM19', side: 'buy', size: '0.0001', // BTC price: '7500', // USD type: 'limit', }; websocket.placeOrder(buyParams);
Appreciate any help. Thanks.