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

Authenticated client returns invalid API key #1

Open
sandybradley opened this issue Jun 7, 2019 · 4 comments
Open

Authenticated client returns invalid API key #1

sandybradley opened this issue Jun 7, 2019 · 4 comments

Comments

@sandybradley
Copy link

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.

@craustin
Copy link
Contributor

craustin commented Jun 7, 2019 via email

@sandybradley
Copy link
Author

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

@PavelPetukhov
Copy link

Hi, do you still have that issue? If so, can you please post your updated script (without private info of course)?

@sandybradley
Copy link
Author

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants