You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jul 16, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Jul 16, 2026. It is now read-only.
On Wed, May 11, 2022 at 9:09 PM comnerd23 ***@***.***> wrote:
Unfortunately, there are only examples written in python and go on the
gate.io page. And again unfortunately some of the go examples are missing.
Anyway, first you need to connect to v4 websocket api.
Then you have to look at the code of which feature you want to use on the
web page.
https://www.gate.io/docs/developers/apiv4/ws/en/
Now let's continue with the sample authentication code on the web page.
const crypto = require('crypto');
const WebSocket = require('ws');
const GateApi = require('gate-api');
let wsclient = new WebSocket('wss://api.gateio.ws/ws/v4/');
wsclient["on"]('message', data => {
const obj = JSON.parse(data);
// enjoy with data
});
wsclient["on"]('open', () => {
console.log("Connected to Service");
subscribe2Orders();
});
function subscribe2Orders() {
const time = parseInt((new Date().getTime()) / 1000);
const message = `channel=${"spot.orders"}&event=${"subscribe"}&time=${time}`;
const hash = crypto.createHmac('sha512', API_SECRET)
.update(message)
.digest('hex');
const request = {
'id': (time * 1e6),
'time': time,
'channel': 'spot.orders',
'event': 'subscribe',
'payload': ["BTC_USDT"],
'auth': { 'method': 'api_key', 'KEY': API_KEY, 'SIGN': hash }
}
wsclient.send(JSON.stringify(request));
}
Attention!
1 - npm i ws
2 - npm i-gate-api
don't forget to install
3 - Please do the necessary warnings and precautions for *ApiKey* and
*ApiSecret* by following and checking the gate.io documentation link
<https://www.gate.io/docs/developers/apiv4/ws/en/> I gave above!
—
Reply to this email directly, view it on GitHub
<#10 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACIX6NJKC7BXTQDT4BX7LADVJQAXVANCNFSM5QAI5OIA>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
Activity
sghoul commentedon May 24, 2022