Configuration and environments
RestClient accepts SDK options first and Axios request options second. WebsocketClient and WebsocketAPIClient accept WebSocket options in their first argument.
import { RestClient } from 'gateio-api';
const client = new RestClient({ keepAlive: true }, { timeout: 10000 });Live and TestNet services
Clients use live services by default. Set useTestnet: true separately on each REST and WebSocket client for TestNet. Use keys created for that environment. The option is useTestnet, not testnet or demoTrading.
Product availability can differ between live and TestNet services.
Timeouts and connections
Set Axios timeout in milliseconds in the second REST constructor argument. The SDK's default is five minutes, so choose a timeout suitable for your application. A timeout during an order command leaves the outcome uncertain; check its status before retrying.
keepAlive belongs in the first argument. Leave it false when using a custom HTTPS proxy agent, because enabling it creates a new HTTPS agent.
WebSocket options include pingInterval, pongTimeout, reconnectTimeout and wsOptions. Keep heartbeat handling enabled and avoid extremely short timeouts. Configure proxies separately for each transport.
The REST parseExceptions option controls error post-processing. See Error handling before logging failures.
Proxies · RestClient reference · WebsocketClientOptions reference