---
title: "Gate Submit Market Order JavaScript SDK Example | Siebly"
description: "Gate REST Spot submit market order JavaScript example for the Siebly Gate SDK, covering exchange REST API and WebSocket integration, setup, and production SDK docs."
canonical: "https://siebly.io/examples/Gate/Rest/spot/submitMarketOrder"
robots: "index,follow"
---

# Gate Submit Market Order JavaScript SDK Example

Gate REST Spot submit market order JavaScript example for the Siebly Gate SDK, covering exchange REST API and WebSocket integration, setup, and production SDK docs.

**Path:** [Home](/) / [Examples](/examples) / [Gate](/examples/Gate) / [Rest](/examples/Gate/Rest) / [spot](/examples/Gate/Rest/spot) / [submitMarketOrder.ts](/examples/Gate/Rest/spot/submitMarketOrder)

[View source on GitHub](https://github.com/sieblyio/crypto-api-examples/blob/master/examples/Gate/Rest/spot/submitMarketOrder.ts)

[Open the Gate JavaScript SDK guide](/sdk/gate/javascript)

## submitMarketOrder.ts

```typescript
import { RestClient } from 'gateio-api';

// Define the account object with API key and secret
const account = {
  key: process.env.API_KEY || 'yourApiHere', // Replace 'yourApiHere' with your actual API key
  secret: process.env.API_SECRET || 'yourSecretHere', // Replace 'yourSecretHere' with your actual API secret
};

// Initialize the RestClient with the API credentials
const gateRestClient = new RestClient({
  apiKey: 'yourkeyhere',
  apiSecret: 'yoursecrethere',
});

async function submitSpotOrder() {
  try {
    console.log('Using API keys:', account);

    // Submit a market order for spot trading
    const result = await gateRestClient.submitSpotOrder({
      currency_pair: 'BTC_USDT', // Specify the currency pair
      side: 'buy', // Specify the order side: 'buy' or 'sell'
      type: 'market', // Specify the order type: 'market'
      amount: '10', // Specify the amount to buy
      time_in_force: 'ioc', // Time in force: 'ioc' (Immediate Or Cancel)
    });

    console.log('Response: ', result); // Log the response to the console
  } catch (e) {
    console.error('Error in execution: ', e); // Log any errors that occur
  }
}

// Execute the function to submit a spot order
submitSpotOrder();
```
