Skip to content

TestNet ​

Available environments ​

Gate.io provides production services and TestNet. The SDK defaults to production. Select TestNet with useTestnet: true; there is no separate demoTrading option.

Connect to TestNet ​

Create API credentials in Gate's TestNet environment and keep them separate from live credentials. Set useTestnet: true on every REST, subscription and WebSocket API client you use:

ts
import { RestClient, WebsocketAPIClient, WebsocketClient } from 'gateio-api';

const options = {
  apiKey: process.env.GATEIO_TESTNET_API_KEY,
  apiSecret: process.env.GATEIO_TESTNET_API_SECRET,
  useTestnet: true,
};

const rest = new RestClient(options);
const streams = new WebsocketClient(options);
const commands = new WebsocketAPIClient(options);

The example constructs clients without sending requests. The SDK selects the TestNet REST host and the matching WebSocket endpoint for each connection key. Spot and USDT perpetual futures have TestNet routes; check current product coverage in Gate's REST reference and the Spot WebSocket reference.

For this documentation's private examples, set GATEIO_USE_TESTNET=true in .env and supply TestNet credentials in GATEIO_API_KEY and GATEIO_API_SECRET. The shared helper passes the same setting to each client.

Coverage and limitations ​

Check Gate’s current TestNet documentation for the products and operations available to your account. Announcements WebSockets are production-only.

Avoid overriding baseUrl or baseUrlKey when using automatic REST TestNet routing: those overrides take precedence over useTestnet. Keep the environment consistent for placement, status queries and private subscriptions.

What these environments can prove ​

Use test environments to check request formats, credentials, order handling and reconnect recovery within the features they support. Testnet liquidity, prices, fills, fees and availability can differ substantially from production. Accounts, balances and order history may also be reset.

Testnet is not a reliable place to evaluate strategy performance. Demo trading may use production market data, but simulated fills do not establish live profitability, slippage, execution quality or capacity. Treat both as integration tests, not evidence that a strategy will succeed with real funds. See the CEX testnet overview for the distinction between testnet and demo trading.

Before switching environments ​

  • Keep credentials and configuration separate for each account, product and environment. Never fall back to live credentials when a test key is missing.
  • Configure every REST, subscription and WebSocket API client separately. Changing one client does not reconfigure another.
  • Check the selected environment's supported endpoints and instruments before sending a request. Similar method signatures do not imply identical availability.
  • Keep authenticated requests on your server. Confirm the destination and account before enabling any write operation.

Production remains the default. Selecting a test environment is an explicit choice for each client; it is not a global SDK setting.

Configuration · Authentication · Production usage

Built by Siebly. Open source SDKs for exchange APIs.