DeltaDeFi
  • About
    • 👋Introduction
    • 📖Learn
      • Architecture
        • Account
        • App Vault
        • Hydra
        • Intent and Process
        • Order Book
      • Trade
        • Order Types
      • Whitepaper
  • Start Trading
    • ⚡Getting Started
      • Create Account
      • Deposit
      • Place Order
      • Cancel Order
      • Withdrawal
      • API Key / Dashboard
    • ⚙️Developers
      • Introduction
        • Base Url
        • Auth
        • Assets
      • Getting started
        • Deposit funds
        • Place a new order
        • Cancel an order
        • Withdraw funds
      • API Documentation
        • Account
          • Create new api key
          • Build deposit transaction
          • Submit deposit transaction
          • Deposit records
          • Withdrawal records
          • Order records
          • Build withdrawal transaction
          • Submit withdrawal transaction
          • Balances
        • App
          • Get mock USDX (testnet only)
          • Submit USDX transaction (testnet only)
        • Market
          • Market Price
          • Market Depth
          • Aggregated trades
        • Order
          • Build order transaction
          • Submit order Transaction
          • Build cancel Order Transaction
          • Submit cancel order transaction
      • Websocket Endpoints
        • Account streams
        • Market price streams
        • Market depth streams
      • SDK
        • Typescript
        • Python
  • FAQ
    • General
    • Product
    • Cardano
    • Disclaimer
Powered by GitBook
On this page
  1. Start Trading
  2. Developers
  3. Getting started

Cancel an order

PreviousPlace a new orderNextWithdraw funds

Last updated 1 month ago

1

Build a cancel order transaction

To build a cancel order transaction, simply include its order's ID in the path param payload.

For in-depth API details Build cancel Order Transaction

curl --location --request DELETE 'https://api-staging.deltadefi.io/order/fdcd1b64-504f-4504-8000-61b3306f345b/build' \
--header 'x-api-key: <your_api_key>' \
--data ''
const axios = require('axios');
let data = '';

let config = {
  method: 'delete',
  maxBodyLength: Infinity,
  url: 'https://api-staging.deltadefi.io/order/fdcd1b64-504f-4504-8000-61b3306f345b/build',
  headers: { 
    'x-api-key': '<your_api_key>'
  },
  data : data
};

axios.request(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});

package main

import (
  "fmt"
  "strings"
  "net/http"
  "io"
)

func main() {

  url := "https://api-staging.deltadefi.io/order/fdcd1b64-504f-4504-8000-61b3306f345b/build"
  method := "DELETE"

  payload := strings.NewReader(``)

  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, payload)

  if err != nil {
    fmt.Println(err)
    return
  }
  req.Header.Add("x-api-key", "<your_api_key>")

  res, err := client.Do(req)
  if err != nil {
    fmt.Println(err)
    return
  }
  defer res.Body.Close()

  body, err := io.ReadAll(res.Body)
  if err != nil {
    fmt.Println(err)
    return
  }
  fmt.Println(string(body))
}

2

Submit a cancel order transaction

With the returned tx_hex from step 1, you will need to before submitting it.

For in-depth API details Submit cancel order transaction

curl --location --request DELETE 'https://api-staging.deltadefi.io/order/submit' \
--header 'x-api-key: <your_api_key>' \
--header 'Content-Type: application/json' \
--data '{
    "signed_tx": "<your_api_key>"
}'
const axios = require('axios');
let data = JSON.stringify({
  "signed_tx": "<your_api_key>"
});

let config = {
  method: 'delete',
  maxBodyLength: Infinity,
  url: 'https://api-staging.deltadefi.io/order/submit',
  headers: { 
    'x-api-key': '<your_api_key>', 
    'Content-Type': 'application/json'
  },
  data : data
};

axios.request(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});

package main

import (
  "fmt"
  "strings"
  "net/http"
  "io"
)

func main() {

  url := "https://api-staging.deltadefi.io/order/submit"
  method := "DELETE"

  payload := strings.NewReader(`{
    "signed_tx": "<your_api_key>"
}`)

  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, payload)

  if err != nil {
    fmt.Println(err)
    return
  }
  req.Header.Add("x-api-key", "<your_api_key>")
  req.Header.Add("Content-Type", "application/json")

  res, err := client.Do(req)
  if err != nil {
    fmt.Println(err)
    return
  }
  defer res.Body.Close()

  body, err := io.ReadAll(res.Body)
  if err != nil {
    fmt.Println(err)
    return
  }
  fmt.Println(string(body))
}


Related FAQ

⚙️
sign it
How can I sign a Cardano transaction?