New Order V1
Endpoint
POST /new-order
Parameters
Parameter | Type | Required | Description |
---|---|---|---|
symbol | string | Yes | Symbol name (e.g., BTC_USDT ). |
action | int32 | Yes | Order Action. |
order_type | int32 | Yes | Order Type. |
price | string | Optional (send "" if null) | Price of the order. Required for LIMIT orders. The number of decimal places must be less than or equal to the field k as defined in the API Symbol Configs. |
size | string | Optional (send "" if null) | Amount of the base currency (e.g., BTC in BTC/USDT). Required for SELL orders. The number of decimal places must be less than or equal to the field m as defined in the API Symbol Configs. |
budget | string | Optional (send "" if null) | Amount of the quote currency (e.g., USDT in BTC/USDT). Required for BUY orders. The number of decimal places must be less than or equal to the field c as defined in the API Symbol Configs. |
Headers
Header | Type | Required | Description |
---|---|---|---|
session-token | string | Yes | Authorization token. |
api-key | string | Yes | API key for user authentication. |
Note: You must provide either session-token
or api-key
in the headers for authentication.
Request Rules
Market Order
- BUY:
- Required:
budget
- Optional:
size
- Without
size
: Match up tobudget
or until orderbook is exhausted. - With
size
: Match up tobudget
orsize
, or until orderbook is exhausted.
- Without
- Required:
- SELL:
- Required:
size
- Optional:
budget
- Without
budget
: Match up tosize
or until orderbook is exhausted. - With
budget
: Match up tosize
orbudget
, or until orderbook is exhausted.
- Without
- Required:
Other Orders
- Required:
price
,size
- Ignored:
budget
Response
JSON Object
Response Fields
Field | Type | Description |
---|---|---|
orderId | string | The ID of the created order. |
Example Usage
- cURL
- ReactJS
- React Native
- Python
- Node.js
- Java
- C#
- Go
- Rust
curl --location 'https://spot-markets.goonus.io/new-order' \
--header 'session-token: xxx' \
--data '{
"symbol": "BTC_USDT",
"action": 0,
"order_type": 1,
"price": "",
"size": "0.1",
"budget": ""
}'
import React, { useState } from 'react';
function CreateOrder() {
const [response, setResponse] = useState(null);
const handleCreateOrder = async () => {
try {
const res = await fetch('https://spot-markets.goonus.io/new-order', {
method: 'POST',
headers: {
'session-token': 'xxx'
},
body: JSON.stringify({
symbol: 'BTC_USDT',
action: 0,
order_type: 1,
price: '',
size: '0.1',
budget: ''
})
});
const data = await res.json();
setResponse(data);
} catch (error) {
console.error('Error:', error);
}
};
return (
<div>
<button onClick={handleCreateOrder}>Create Order</button>
{response && <pre>{JSON.stringify(response, null, 2)}</pre>}
</div>
);
}
export default CreateOrder;
import React from 'react';
import { Button, View, Alert } from 'react-native';
const CreateOrder = () => {
const handleCreateOrder = async () => {
try {
const response = await fetch('https://spot-markets.goonus.io/new-order', {
method: 'POST',
headers: {
'session-token': 'xxx'
},
body: JSON.stringify({
symbol: 'BTC_USDT',
action: 0,
order_type: 1,
price: '',
size: '0.1',
budget: ''
})
});
const data = await response.json();
Alert.alert('Order Created', JSON.stringify(data));
} catch (error) {
Alert.alert('Error', error.message);
}
};
return (
<View>
<Button title="Create Order" onPress={handleCreateOrder} />
</View>
);
};
export default CreateOrder;
import requests
url = "https://spot-markets.goonus.io/new-order"
headers = {
"session-token": "xxx"
}
data = {
"symbol": "BTC_USDT",
"action": 0,
"order_type": 1,
"price": "",
"size": "0.1",
"budget": ""
}
response = requests.post(url, json=data, headers=headers)
if response.status_code == 200:
print("Order created successfully", response.json())
else:
print("Error:", response.text)
const axios = require('axios');
axios.post('https://spot-markets.goonus.io/new-order', {
symbol: 'BTC_USDT',
action: 0,
order_type: 1,
price: '',
size: '0.1',
budget: ''
}, {
headers: {
'session-token': 'xxx'
}
})
.then(response => console.log('Order created:', response.data))
.catch(error => console.error('Error:', error.response.data));
import java.net.http.*;
import java.net.URI;
public class CreateOrder {
public static void main(String[] args) throws Exception {
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://spot-markets.goonus.io/new-order"))
.header("session-token", "xxx")
.POST(HttpRequest.BodyPublishers.ofString(
"{\"symbol\":\"BTC_USDT\",\"action\":0,\"order_type\":1,\"price\":\"\",\"size\":\"0.1\",\"budget\":\"\"}"))
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
if (response.statusCode() == 200) {
System.out.println("Order created: " + response.body());
} else {
System.err.println("Error: " + response.body());
}
}
}
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
class Program {
static async Task Main(string[] args) {
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("session-token", "xxx");
var content = new StringContent(
"{\"symbol\":\"BTC_USDT\",\"action\":0,\"order_type\":1,\"price\":\"\",\"size\":\"0.1\",\"budget\":\"\"}",
Encoding.UTF8, "application/json");
var response = await client.PostAsync("https://spot-markets.goonus.io/new-order", content);
if (response.IsSuccessStatusCode) {
Console.WriteLine("Order created: " + await response.Content.ReadAsStringAsync());
} else {
Console.WriteLine("Error: " + await response.Content.ReadAsStringAsync());
}
}
}
package main
import (
"bytes"
"fmt"
"net/http"
)
func main() {
url := "https://spot-markets.goonus.io/new-order"
jsonBody := []byte(`{"symbol":"BTC_USDT","action":0,"order_type":1,"price":"","size":"0.1","budget":""}`)
req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonBody))
req.Header.Set("session-token", "xxx")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
if resp.StatusCode == 200 {
fmt.Println("Order created successfully")
} else {
fmt.Println("Error:", resp.Status)
}
}
use reqwest;
use tokio;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = reqwest::Client::new();
let response = client
.post("https://spot-markets.goonus.io/new-order")
.header("session-token", "xxx")
.body(r#"{"symbol":"BTC_USDT","action":0,"order_type":1,"price":"","size":"0.1","budget":""}"#)
.send()
.await?;
if response.status().is_success() {
println!("Order created successfully");
} else {
println!("Error: {}", response.text().await?);
}
Ok(())
}
Response Example
{
"orderId": "3609592669673907047"
}