Get a Bearer Token

Obtain a JWT that you can pass as Authorization: Bearer <token> on every request in this document, and to enable the Try It action on each endpoint below. The token expires together with the API key; sign in again to get a new one. Don't have an API key? Create one in your OUINEX account settings.

Bearer access token

          

Introduction

The OUINEX API is a GraphQL API. All requests are sent as POST to the /graphql endpoint of the appropriate host with a JSON body containing query and variables, and an Authorization: Bearer <token> header. Obtain the token with service_signin or service_signin_v2.

Hosts

https://live-api.ouinex.com/graphql for spot trading, wallets, conversions, deposits/withdrawals, vaults, API keys
https://live-margin-api.ouinex.com/graphql for derivatives

The same bearer token is accepted on both hosts. GraphQL subscriptions are delivered over WebSocket on the same hosts with the wss:// scheme. See the WebSocket transport guide and the Subscriptions group below.

Demo

Demo runs the same API with demo funds, on https://demo-api.ouinex.com/graphql and https://demo-margin-api.ouinex.com/graphql (subscriptions on the same hosts with wss://). Create Demo API keys in your Demo account (Settings → API Keys at demo.ouinex.com); a key works only on the environment that issued it. Demo can run a different platform version from Live, and Earn (vaults) is not offered there. This reference describes Live; pick Demo in Get a Bearer Token to try operations against Demo.

Version

This reference describes platform version 4.35.5. The unauthenticated query { version } on the spot host returns the version Live runs. Changes to this reference are listed in the Changelog.

Request shape

POST /graphql HTTP/1.1
Host: live-api.ouinex.com
Authorization: Bearer <token>
Content-Type: application/json

{
  "query": "query { instruments { instrument_id name } }",
  "variables": {}
}

On the spot host a single request may contain at most 9 aliased fields; larger documents are rejected.

Errors

Errors are returned in the errors array of the response body. extensions.code carries the machine-readable code (for example GQL_ERR.THROTTLE.SOFT_LOCK when a rate limit is exceeded); the message ends with a request reference in parentheses. Errors carry their real HTTP status (4xx for client errors): route on the HTTP status and extensions.code, and do not parse other details of the error.

Account requirements

Payment operations (deposits, withdrawals) and API-key operations require a KYC-approved, active account.

Authentication

Exchange an API key and secret for a bearer token, and manage your sessions.

mutationservice_signinSign in with an API key and secret; returns the bearer JWT.
Endpoint: POST https://live-api.ouinex.com/graphql
Type: Mutation
Returns: SignInResult!
Rate limit: 10 requests / 60 s, min. 2000 ms between calls

Public: no Authorization header. Send the returned jwt as Authorization: Bearer <jwt> on both the spot and margin hosts. The token is valid until the API key's own expires_at; there is no refresh call — sign in again to obtain a new token.

Still supported. service_signin_v2 issues a server-side session instead, which can be listed and revoked.

Inputs

NameTypeRequiredDescription
service_api_keyString!requiredAPI key ID (api_key_id returned by create_api_key).
service_api_secretString!requiredAPI secret (api_key_secret returned by create_api_key; shown only once).

Response

Fields of SignInResult selected in the operation below.

FieldTypeDescription
jwtString!Bearer token (RS256-signed JWT).
expires_atFloat!Token expiry, Unix time in milliseconds.

GraphQL Operation

mutation service_signin($service_api_key: String!, $service_api_secret: String!) {
  service_signin(service_api_key: $service_api_key, service_api_secret: $service_api_secret) {
    jwt expires_at
  }
}

Code Examples

curl -X POST 'https://live-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"mutation service_signin($service_api_key: String!, $service_api_secret: String!) { service_signin(service_api_key: $service_api_key, service_api_secret: $service_api_secret) { jwt expires_at } }","variables":{"service_api_key":"YOUR_API_KEY","service_api_secret":"YOUR_API_SECRET"}}'
import requests

url = "https://live-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """mutation service_signin($service_api_key: String!, $service_api_secret: String!) { service_signin(service_api_key: $service_api_key, service_api_secret: $service_api_secret) { jwt expires_at } }""",
    "variables": {
        "service_api_key": "YOUR_API_KEY",
        "service_api_secret": "YOUR_API_SECRET"
    },
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `mutation service_signin($service_api_key: String!, $service_api_secret: String!) { service_signin(service_api_key: $service_api_key, service_api_secret: $service_api_secret) { jwt expires_at } }`,
    variables: {
      "service_api_key": "YOUR_API_KEY",
      "service_api_secret": "YOUR_API_SECRET"
    },
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this

The Get a Bearer Token form at the top of this page calls this mutation.

mutationservice_signin_v2Sign in with an API key and secret; returns a server-side session token.
Endpoint: POST https://live-api.ouinex.com/graphql
Type: Mutation
Returns: LocalSessionResult!

Public: no Authorization header. Send the returned session_token as Authorization: Bearer <token>. The session is bound to the API key's expiry and can be revoked server-side (revoke_current_session, revoke_session, revoke_other_sessions).

Unlike service_signin, expires_at is Unix time in seconds, and it slides: the expiry moves forward while the session is used.

Inputs

NameTypeRequiredDescription
service_api_keyString!requiredAPI key ID (api_key_id returned by create_api_key).
service_api_secretString!requiredAPI secret (api_key_secret returned by create_api_key; shown only once).

Response

Fields of LocalSessionResult selected in the operation below.

FieldTypeDescription
session_tokenString!Opaque session token. Send it as Authorization: Bearer <token>.
session_idString!Session ID, as listed by user_sessions.
expires_atFloat!Current session expiry, Unix time in seconds (sliding).

GraphQL Operation

mutation service_signin_v2($service_api_key: String!, $service_api_secret: String!) {
  service_signin_v2(service_api_key: $service_api_key, service_api_secret: $service_api_secret) {
    session_token session_id expires_at
  }
}

Code Examples

curl -X POST 'https://live-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"mutation service_signin_v2($service_api_key: String!, $service_api_secret: String!) { service_signin_v2(service_api_key: $service_api_key, service_api_secret: $service_api_secret) { session_token session_id expires_at } }","variables":{"service_api_key":"YOUR_API_KEY","service_api_secret":"YOUR_API_SECRET"}}'
import requests

url = "https://live-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """mutation service_signin_v2($service_api_key: String!, $service_api_secret: String!) { service_signin_v2(service_api_key: $service_api_key, service_api_secret: $service_api_secret) { session_token session_id expires_at } }""",
    "variables": {
        "service_api_key": "YOUR_API_KEY",
        "service_api_secret": "YOUR_API_SECRET"
    },
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `mutation service_signin_v2($service_api_key: String!, $service_api_secret: String!) { service_signin_v2(service_api_key: $service_api_key, service_api_secret: $service_api_secret) { session_token session_id expires_at } }`,
    variables: {
      "service_api_key": "YOUR_API_KEY",
      "service_api_secret": "YOUR_API_SECRET"
    },
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this
queryuser_sessionsList your active sessions (devices).
Endpoint: POST https://live-api.ouinex.com/graphql
Type: Query
Returns: [UserSessionInfo!]!

Tokens from service_signin carry no session and are not listed.

Response

Fields of UserSessionInfo selected in the operation below.

FieldTypeDescription
session_idString!Session ID (use it with revoke_session).
device_labelStringDevice label.
countryStringCountry of the last use.
cityStringCity of the last use.
created_atString!Session start.
last_used_atString!Last use.
is_currentBoolean!true for the session this request was made with.

GraphQL Operation

query user_sessions {
  user_sessions { session_id device_label country city created_at last_used_at is_current }
}

Code Examples

curl -X POST 'https://live-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"query user_sessions { user_sessions { session_id device_label country city created_at last_used_at is_current } }","variables":{}}'
import requests

url = "https://live-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """query user_sessions { user_sessions { session_id device_label country city created_at last_used_at is_current } }""",
    "variables": {},
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `query user_sessions { user_sessions { session_id device_label country city created_at last_used_at is_current } }`,
    variables: {},
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this
mutationrevoke_current_sessionRevoke the session this request was made with (server-side logout).
Endpoint: POST https://live-api.ouinex.com/graphql
Type: Mutation
Returns: Boolean!

Returns false for tokens from service_signin (legacy JWTs), which carry no session.

GraphQL Operation

mutation revoke_current_session {
  revoke_current_session
}

Code Examples

curl -X POST 'https://live-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"mutation revoke_current_session { revoke_current_session }","variables":{}}'
import requests

url = "https://live-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """mutation revoke_current_session { revoke_current_session }""",
    "variables": {},
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `mutation revoke_current_session { revoke_current_session }`,
    variables: {},
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this
mutationrevoke_sessionRevoke one of your own sessions. Takes effect immediately.
Endpoint: POST https://live-api.ouinex.com/graphql
Type: Mutation
Returns: Boolean!

Inputs

NameTypeRequiredDescription
session_idString!requiredSession to revoke (session_id from user_sessions).

GraphQL Operation

mutation revoke_session($session_id: String!) {
  revoke_session(session_id: $session_id)
}

Code Examples

curl -X POST 'https://live-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"mutation revoke_session($session_id: String!) { revoke_session(session_id: $session_id) }","variables":{"session_id":"session123"}}'
import requests

url = "https://live-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """mutation revoke_session($session_id: String!) { revoke_session(session_id: $session_id) }""",
    "variables": {
        "session_id": "session123"
    },
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `mutation revoke_session($session_id: String!) { revoke_session(session_id: $session_id) }`,
    variables: {
      "session_id": "session123"
    },
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this
mutationrevoke_other_sessionsRevoke all your sessions except the current one.
Endpoint: POST https://live-api.ouinex.com/graphql
Type: Mutation
Returns: Int!

Returns the number of sessions revoked.

GraphQL Operation

mutation revoke_other_sessions {
  revoke_other_sessions
}

Code Examples

curl -X POST 'https://live-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"mutation revoke_other_sessions { revoke_other_sessions }","variables":{}}'
import requests

url = "https://live-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """mutation revoke_other_sessions { revoke_other_sessions }""",
    "variables": {},
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `mutation revoke_other_sessions { revoke_other_sessions }`,
    variables: {},
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this

Accounts & Balances

Read wallets, balances and ledger entries for the authenticated user.

querywalletsList the user's wallets (use the returned wallet_id in wallet-scoped operations).
Endpoint: POST https://live-api.ouinex.com/graphql
Type: Query
Returns: WalletsResult!
Permission: wallets

The MAIN wallet is always returned first (it is not stored as a row, so do not select serial_id on it). Mutations that take a wallet_id default to MAIN when it is omitted; list queries without wallet_id return all wallets.

Inputs

NameTypeRequiredDescription
wallet_idStringoptionalWallet filter.
nameStringoptionalFilter by name.
descriptionStringoptionalFilter by description.
is_activeStringoptionalWallet status filter. Defaults to on; the synthetic MAIN wallet is included only when filtering for active wallets.
typeStringoptionalFilter by type.
pagerPagerInputoptional
default {limit: 30, offset: 0}
Pagination (limit, offset).
sortSortInputoptional
default {direction: DESC}
Sort order.
dateRangeDateRangeInputoptional
default {}
Filter by wallet creation date.

Response

Fields of WalletsResult selected in the operation below.

FieldTypeDescription
wallets[Wallet!]!Wallets of the user, MAIN first.
personal_wallets_limitFloat!Maximum number of personal wallets the user may create.

GraphQL Operation

query wallets {
  wallets {
    wallets { wallet_id name type is_active created_at }
    personal_wallets_limit
  }
}

Code Examples

curl -X POST 'https://live-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"query wallets { wallets { wallets { wallet_id name type is_active created_at } personal_wallets_limit } }","variables":{}}'
import requests

url = "https://live-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """query wallets { wallets { wallets { wallet_id name type is_active created_at } personal_wallets_limit } }""",
    "variables": {},
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `query wallets { wallets { wallets { wallet_id name type is_active created_at } personal_wallets_limit } }`,
    variables: {},
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this
mutationcreate_walletCreate a personal sub-wallet.
Endpoint: POST https://live-api.ouinex.com/graphql
Type: Mutation
Returns: Wallet!
Permission: create_wallet

Wallet names are unique per user, and the number of wallets per user is limited.

Inputs

NameTypeRequiredDescription
nameString!requiredWallet name, unique for the user.
descriptionStringoptionalFree-text description.

Response

Fields of Wallet selected in the operation below.

FieldTypeDescription
wallet_idString!
nameString!Type of the wallet (will become enum in future)
descriptionString
typeWalletType
created_atString!

GraphQL Operation

mutation create_wallet($name: String!) {
  create_wallet(name: $name) { wallet_id name description type created_at }
}

Code Examples

curl -X POST 'https://live-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"mutation create_wallet($name: String!) { create_wallet(name: $name) { wallet_id name description type created_at } }","variables":{"name":"Bot wallet"}}'
import requests

url = "https://live-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """mutation create_wallet($name: String!) { create_wallet(name: $name) { wallet_id name description type created_at } }""",
    "variables": {
        "name": "Bot wallet"
    },
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `mutation create_wallet($name: String!) { create_wallet(name: $name) { wallet_id name description type created_at } }`,
    variables: {
      "name": "Bot wallet"
    },
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this
mutationupdate_walletRename a wallet or change its description.
Endpoint: POST https://live-api.ouinex.com/graphql
Type: Mutation
Returns: Wallet!
Permission: update_wallet

Inputs

NameTypeRequiredDescription
wallet_idString!requiredWallet to update.
nameStringoptionalNew name.
descriptionStringoptionalNew description.

Response

Fields of Wallet selected in the operation below.

FieldTypeDescription
wallet_idString!
nameString!Type of the wallet (will become enum in future)
descriptionString

GraphQL Operation

mutation update_wallet($wallet_id: String!, $name: String) {
  update_wallet(wallet_id: $wallet_id, name: $name) { wallet_id name description }
}

Code Examples

curl -X POST 'https://live-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"mutation update_wallet($wallet_id: String!, $name: String) { update_wallet(wallet_id: $wallet_id, name: $name) { wallet_id name description } }","variables":{"wallet_id":"wallet123","name":"Bot wallet 2"}}'
import requests

url = "https://live-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """mutation update_wallet($wallet_id: String!, $name: String) { update_wallet(wallet_id: $wallet_id, name: $name) { wallet_id name description } }""",
    "variables": {
        "wallet_id": "wallet123",
        "name": "Bot wallet 2"
    },
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `mutation update_wallet($wallet_id: String!, $name: String) { update_wallet(wallet_id: $wallet_id, name: $name) { wallet_id name description } }`,
    variables: {
      "wallet_id": "wallet123",
      "name": "Bot wallet 2"
    },
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this
mutationcreate_wallet_transferMove funds between two of the user's own wallets.
Endpoint: POST https://live-api.ouinex.com/graphql
Type: Mutation
Returns: WalletTransfer!
Permission: create_wallet_transfer

Inputs

NameTypeRequiredDescription
from_wallet_idString!requiredSource wallet.
to_wallet_idString!requiredDestination wallet.
currency_idString!requiredCurrency to move.
amountFloat!requiredAmount to move.
descriptionStringoptionalFree-text description.

Response

Fields of WalletTransfer selected in the operation below.

FieldTypeDescription
serial_idInt!
transfer_idString!
from_wallet_idString!
to_wallet_idString!
currency_idString!
amountFloat!
created_atString!
from_post_balanceFloat!
to_post_balanceFloat!
descriptionString

GraphQL Operation

mutation create_wallet_transfer($from_wallet_id: String!, $to_wallet_id: String!, $currency_id: String!, $amount: Float!) {
  create_wallet_transfer(from_wallet_id: $from_wallet_id, to_wallet_id: $to_wallet_id, currency_id: $currency_id, amount: $amount) { serial_id transfer_id from_wallet_id to_wallet_id currency_id amount created_at from_post_balance to_post_balance description }
}

Code Examples

curl -X POST 'https://live-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"mutation create_wallet_transfer($from_wallet_id: String!, $to_wallet_id: String!, $currency_id: String!, $amount: Float!) { create_wallet_transfer(from_wallet_id: $from_wallet_id, to_wallet_id: $to_wallet_id, currency_id: $currency_id, amount: $amount) { serial_id transfer_id from_wallet_id to_wallet_id currency_id amount created_at from_post_balance to_post_balance description } }","variables":{"from_wallet_id":"MAIN","to_wallet_id":"wallet123","currency_id":"USDT","amount":100}}'
import requests

url = "https://live-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """mutation create_wallet_transfer($from_wallet_id: String!, $to_wallet_id: String!, $currency_id: String!, $amount: Float!) { create_wallet_transfer(from_wallet_id: $from_wallet_id, to_wallet_id: $to_wallet_id, currency_id: $currency_id, amount: $amount) { serial_id transfer_id from_wallet_id to_wallet_id currency_id amount created_at from_post_balance to_post_balance description } }""",
    "variables": {
        "from_wallet_id": "MAIN",
        "to_wallet_id": "wallet123",
        "currency_id": "USDT",
        "amount": 100
    },
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `mutation create_wallet_transfer($from_wallet_id: String!, $to_wallet_id: String!, $currency_id: String!, $amount: Float!) { create_wallet_transfer(from_wallet_id: $from_wallet_id, to_wallet_id: $to_wallet_id, currency_id: $currency_id, amount: $amount) { serial_id transfer_id from_wallet_id to_wallet_id currency_id amount created_at from_post_balance to_post_balance description } }`,
    variables: {
      "from_wallet_id": "MAIN",
      "to_wallet_id": "wallet123",
      "currency_id": "USDT",
      "amount": 100
    },
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this
queryaccounts_balancesRead current balances per currency (free, total, exposed, margin exposure).
Endpoint: POST https://live-api.ouinex.com/graphql
Type: Query
Returns: [AccountBalance!]!
Permission: accounts_balances
Rate limit: 60 requests / 60 s

Inputs

NameTypeRequiredDescription
currency_idStringoptionalCurrency filter.
hide_zero_balancesToggleSwitchoptional
default off
With on, rows whose total_balance is 0 are removed.
wallet_idStringoptionalWallet to read. When omitted, balances of all the user's wallets are returned.
omit_currencies[String!]optionalCurrencies to exclude from the result.
respect_limit_groupToggleSwitchoptional
default on
Excludes currencies disabled by the user's limit group. Pass off to return all balances regardless of limit group.

Response

Fields of AccountBalance selected in the operation below.

FieldTypeDescription
currency_idString!Currency ID
total_balanceFloat!Total balance
exposed_balanceFloat!Exposed (reserved) balance.
margin_exposureFloat!Margin exposure.
free_balanceFloat!Available balance for trading

GraphQL Operation

query accounts_balances {
  accounts_balances {
    currency_id total_balance exposed_balance margin_exposure free_balance
  }
}

Code Examples

curl -X POST 'https://live-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"query accounts_balances { accounts_balances { currency_id total_balance exposed_balance margin_exposure free_balance } }","variables":{}}'
import requests

url = "https://live-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """query accounts_balances { accounts_balances { currency_id total_balance exposed_balance margin_exposure free_balance } }""",
    "variables": {},
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `query accounts_balances { accounts_balances { currency_id total_balance exposed_balance margin_exposure free_balance } }`,
    variables: {},
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this
queryaccount_transactionsRead account ledger (trades, fees, deposits, withdrawals, transfers).
Endpoint: POST https://live-api.ouinex.com/graphql
Type: Query
Returns: [AccountTransaction!]!
Permission: account_transactions
Rate limit: 60 requests / 60 s

Inputs

NameTypeRequiredDescription
account_transaction_idStringoptionalFilter by account_transaction_id.
parent_transaction_idStringoptionalFilter by parent_transaction_id.
client_transaction_idStringoptionalFilter by client_transaction_id.
account_idStringoptionalFilter by account_id.
payment_idStringoptionalFilter by payment_id.
currency_idStringoptionalCurrency filter.
transaction_classAccountTransactionClassoptionalFilter by transaction_class.
typeAccountTransactionTypeoptionalFilter by debit / credit.
order_idStringoptionalFilter by order_id.
trade_idStringoptionalFilter by trade_id.
conversion_idStringoptionalFilter by conversion_id.
margin_trade_idStringoptionalFilter by margin_trade_id.
commentStringoptionalPrefix match on the transaction comment.
searchStringoptionalSearch term.
instrument_idStringoptionalInstrument filter.
pagerPagerInputoptional
default {limit: 30, offset: 0}
Pagination (limit, offset).
sortSortInputoptional
default {direction: DESC}
Sort order.
dateRangeDateRangeInputoptional
default {}
Date-time window (time_from, time_to). When omitted the server applies a default window (14 days back from now in the default platform settings); a range wider than the configured maximum (1 year for user-scoped queries by default) is rejected. Pass it explicitly to read older history.
serialIdRangeSerialIdRangeInputoptional
default {}
Filter by serial ID range.
wallet_idStringoptionalWallet filter.
referenceStringoptionalClient reference.

Response

Fields of AccountTransaction selected in the operation below.

FieldTypeDescription
account_transaction_idString!Transaction ID
currency_idString!Currency.
typeAccountTransactionType!debit or credit.
amountFloat!Amount.
post_balanceFloat!Account balance after this transaction.
created_at_isoString!Creation time (ISO 8601).

GraphQL Operation

query account_transactions($wallet_id: String) {
  account_transactions(wallet_id: $wallet_id) {
    account_transaction_id currency_id type amount post_balance created_at_iso
  }
}

Code Examples

curl -X POST 'https://live-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"query account_transactions($wallet_id: String) { account_transactions(wallet_id: $wallet_id) { account_transaction_id currency_id type amount post_balance created_at_iso } }","variables":{"wallet_id":"wallet123"}}'
import requests

url = "https://live-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """query account_transactions($wallet_id: String) { account_transactions(wallet_id: $wallet_id) { account_transaction_id currency_id type amount post_balance created_at_iso } }""",
    "variables": {
        "wallet_id": "wallet123"
    },
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `query account_transactions($wallet_id: String) { account_transactions(wallet_id: $wallet_id) { account_transaction_id currency_id type amount post_balance created_at_iso } }`,
    variables: {
      "wallet_id": "wallet123"
    },
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this
queryportfolio_history_v2Portfolio value history over a period, with PNL and ROI.
Endpoint: POST https://live-api.ouinex.com/graphql
Type: Query
Returns: PortfolioHistoryResult!

Inputs

NameTypeRequiredDescription
periodPortfolioHistoryInterval!requiredPeriod to cover.
wallet_idStringoptionalWallet filter.
currency_idStringoptionalCurrency the values are expressed in. When omitted, the user's primary market currency is used, which is not necessarily USD; the response's currency_id says which.

Response

Fields of PortfolioHistoryResult selected in the operation below.

FieldTypeDescription
points[PortfolioHistoryPoint!]!Portfolio value over time (ts, value).
pnlFloat!PNL over the period.
roiFloat!ROI over the period.
currency_idStringCurrency every value and pnl is denominated in.
backfill_in_progressBooleantrue while the all history is still being backfilled; refetch until it clears.

GraphQL Operation

query portfolio_history_v2($period: PortfolioHistoryInterval!) {
  portfolio_history_v2(period: $period) {
    points { ts value }
    pnl roi currency_id backfill_in_progress
  }
}

Code Examples

curl -X POST 'https://live-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"query portfolio_history_v2($period: PortfolioHistoryInterval!) { portfolio_history_v2(period: $period) { points { ts value } pnl roi currency_id backfill_in_progress } }","variables":{"period":"month"}}'
import requests

url = "https://live-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """query portfolio_history_v2($period: PortfolioHistoryInterval!) { portfolio_history_v2(period: $period) { points { ts value } pnl roi currency_id backfill_in_progress } }""",
    "variables": {
        "period": "month"
    },
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `query portfolio_history_v2($period: PortfolioHistoryInterval!) { portfolio_history_v2(period: $period) { points { ts value } pnl roi currency_id backfill_in_progress } }`,
    variables: {
      "period": "month"
    },
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this
queryuser_trading_pnlCumulative unrealized trading PNL over a period, with ROI; deposits and withdrawals are excluded.
Endpoint: POST https://live-api.ouinex.com/graphql
Type: Query
Returns: TradingPnlResult!

Inputs

NameTypeRequiredDescription
periodPortfolioHistoryInterval!requiredPeriod to cover.
wallet_idStringoptionalWallet filter.
currency_idStringoptionalCurrency the values are expressed in. When omitted, the user's primary market currency is used, which is not necessarily USD; the response's currency_id says which.

Response

Fields of TradingPnlResult selected in the operation below.

FieldTypeDescription
points[TradingPnlPoint!]!Cumulative PNL over time (ts, pnl).
pnlFloat!PNL over the period.
roiFloat!ROI over the period.
currency_idStringCurrency every value and pnl is denominated in.
start_valueFloat!Portfolio value at the start of the period.
portfolio_values[Float!]!Portfolio values over the period.

GraphQL Operation

query user_trading_pnl($period: PortfolioHistoryInterval!) {
  user_trading_pnl(period: $period) {
    points { ts pnl }
    pnl roi currency_id start_value portfolio_values
  }
}

Code Examples

curl -X POST 'https://live-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"query user_trading_pnl($period: PortfolioHistoryInterval!) { user_trading_pnl(period: $period) { points { ts pnl } pnl roi currency_id start_value portfolio_values } }","variables":{"period":"month"}}'
import requests

url = "https://live-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """query user_trading_pnl($period: PortfolioHistoryInterval!) { user_trading_pnl(period: $period) { points { ts pnl } pnl roi currency_id start_value portfolio_values } }""",
    "variables": {
        "period": "month"
    },
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `query user_trading_pnl($period: PortfolioHistoryInterval!) { user_trading_pnl(period: $period) { points { ts pnl } pnl roi currency_id start_value portfolio_values } }`,
    variables: {
      "period": "month"
    },
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this

API Keys

Create and manage API keys for programmatic access to the exchange. API keys are created and managed in the OUINEX web app (account settings): these operations require a signed-in user session and cannot be called with an API key.

API key permissions

The permissions argument of create_api_key / update_api_key takes a list of the lowercase identifiers below, for example ["accounts_balances", "create_order", "cancel_order"]. Operations that require a specific permission show it. Identifiers that are not part of the trader permission set are dropped silently when the key is saved.

Vault operations additionally require vaults to be enabled on the platform; derivatives operations require derivatives to be enabled for the user's limit group.

Accounts and balances

PermissionDescription
accounts_balancesRead current balances per currency (free, total, exposed, margin exposure).
daily_balances_reportRead end-of-day balance snapshots / history.
account_transactionsRead account ledger (trades, fees, deposits, withdrawals, transfers).
accountsList the user's accounts and metadata.
walletsList the user's wallets (wallets).
create_walletCreate a personal sub-wallet.
update_walletRename a wallet or change its description.
create_wallet_transferMove funds between the user's own wallets.

API keys

An API key cannot hold API-key management permissions. Keys are created and managed from your OUINEX account in the web app, not with an API key. A trader key requires an IP allow-list of 1 to 3 addresses (ip_address).

Conversions and payments

PermissionDescription
create_conversion_quoteGet a locked exchange-rate quote between two currencies.
conversion_quotesList previously generated quotes.
create_conversion_orderExecute a conversion against a quote.
conversionsList conversion history.
payments_feesRead fee schedule for deposits / withdrawals.
trading_feesRead trading fee tiers per instrument.
payments_limitsPayment limits.
paymentsList deposit / withdrawal history.
payments_routesList available deposit / withdrawal methods and bank details.
create_withdrawal_cryptoInitiate a crypto withdrawal to an external address.
create_withdrawal_fiatInitiate a fiat withdrawal via bank transfer.
deposit_bank_details_fiatRead bank account details for fiat deposits.
deposit_addresses_cryptoGenerate / read crypto deposit addresses.
estimate_network_feeEstimate the on-chain network fee for a pending withdrawal.

Orders and trades

PermissionDescription
create_orderPlace spot orders (market, limit, stop).
cancel_orderCancel a single open order or all orders.
open_ordersList currently open spot orders.
closed_ordersList filled / cancelled spot orders.
estimate_orderPreview cost, fees, and slippage before placing an order.
tradesList executed trades / fills.
instrumentsList trading pairs with metadata and current prices.
currenciesList supported currencies.
trading_limitsRead user's per-instrument trading limits.

Vaults

PermissionDescription
vaultsList available yield vaults.
vaults_accountsRead user's vault account balances.
vaults_transactionsRead vault deposit / withdrawal history.
create_vault_depositDeposit funds into a vault.
create_vault_withdrawalWithdraw funds from a vault.
vaults_transactions_requestsList pending vault transactions.
cancel_vault_transaction_requestCancel a pending vault transaction.
estimate_vault_interestsEstimate yield on a planned vault deposit.

Derivatives

PermissionDescription
derivatives_instrumentsList perpetual swap contracts.
open_derivatives_ordersList currently open margin orders.
closed_derivatives_ordersList filled / cancelled margin orders.
create_derivatives_orderPlace a margin / perpetual order.
cancel_derivatives_orderCancel a margin order.
estimate_derivatives_orderPreview a margin order before placing.
open_derivatives_positionsList currently open margin positions.
closed_derivatives_positionsList historical (closed) margin positions.
update_open_derivatives_positionAdjust take-profit / stop-loss / leverage on an open position.
derivatives_funding_historyRead funding fees paid / earned over time.
mutationcreate_api_keyCreate a new API key.
Endpoint: POST https://live-api.ouinex.com/graphql
Type: Mutation
Returns: CreateApiKeyResult!

Inputs

NameTypeRequiredDescription
nameStringoptionalKey name. Letters and digits, optionally separated by single spaces, - or _.
expires_atString!requiredExpiry date-time; must be in the future. Tokens issued by service_signin for this key expire at the same moment.
is_activeToggleSwitch!requiredWhether the key is active.
typeApiKeyTypes!requiredKey type. A trader can only create trader keys.
ip_address[String!]optionalIP allow-list: 1 to 3 IP addresses. A trader key requires a non-empty list.
permissions[Permission!]!requiredPermission identifiers (lowercase, see API key permissions). Permissions outside the trader set are dropped silently; API-key management permissions cannot be granted to a key.
hmac_requiredToggleSwitchoptionalWhen on, signed requests are required for create_order, create_conversion_order, create_withdrawal_crypto and create_withdrawal_fiat: send X-Nonce (unique per request) and X-Signature = lowercase hex HMAC-SHA256 of raw request body + nonce, keyed with hex(HMAC-SHA256(key = api_key_id, message = api_secret)). A nonce cannot be reused. Defaults to off.

Response

Fields of CreateApiKeyResult selected in the operation below.

FieldTypeDescription
api_key_idString!Newly created API key (public key)
api_key_secretString!API key secret (shown only once, store securely)

GraphQL Operation

mutation create_api_key($name: String, $expires_at: String!, $is_active: ToggleSwitch!, $type: ApiKeyTypes!, $ip_address: [String!], $permissions: [Permission!]!, $hmac_required: ToggleSwitch) {
  create_api_key(name: $name, expires_at: $expires_at, is_active: $is_active, type: $type, ip_address: $ip_address, permissions: $permissions, hmac_required: $hmac_required) {
    api_key_id api_key_secret
  }
}

Code Examples

curl -X POST 'https://live-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"mutation create_api_key($name: String, $expires_at: String!, $is_active: ToggleSwitch!, $type: ApiKeyTypes!, $ip_address: [String!], $permissions: [Permission!]!, $hmac_required: ToggleSwitch) { create_api_key(name: $name, expires_at: $expires_at, is_active: $is_active, type: $type, ip_address: $ip_address, permissions: $permissions, hmac_required: $hmac_required) { api_key_id api_key_secret } }","variables":{"name":"Trading Bot","expires_at":"2027-12-31T23:59:59Z","is_active":"on","type":"trader","ip_address":["203.0.113.10"],"permissions":["accounts_balances","create_order","cancel_order"],"hmac_required":"off"}}'
import requests

url = "https://live-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """mutation create_api_key($name: String, $expires_at: String!, $is_active: ToggleSwitch!, $type: ApiKeyTypes!, $ip_address: [String!], $permissions: [Permission!]!, $hmac_required: ToggleSwitch) { create_api_key(name: $name, expires_at: $expires_at, is_active: $is_active, type: $type, ip_address: $ip_address, permissions: $permissions, hmac_required: $hmac_required) { api_key_id api_key_secret } }""",
    "variables": {
        "name": "Trading Bot",
        "expires_at": "2027-12-31T23:59:59Z",
        "is_active": "on",
        "type": "trader",
        "ip_address": [
            "203.0.113.10"
        ],
        "permissions": [
            "accounts_balances",
            "create_order",
            "cancel_order"
        ],
        "hmac_required": "off"
    },
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `mutation create_api_key($name: String, $expires_at: String!, $is_active: ToggleSwitch!, $type: ApiKeyTypes!, $ip_address: [String!], $permissions: [Permission!]!, $hmac_required: ToggleSwitch) { create_api_key(name: $name, expires_at: $expires_at, is_active: $is_active, type: $type, ip_address: $ip_address, permissions: $permissions, hmac_required: $hmac_required) { api_key_id api_key_secret } }`,
    variables: {
      "name": "Trading Bot",
      "expires_at": "2027-12-31T23:59:59Z",
      "is_active": "on",
      "type": "trader",
      "ip_address": [
        "203.0.113.10"
      ],
      "permissions": [
        "accounts_balances",
        "create_order",
        "cancel_order"
      ],
      "hmac_required": "off"
    },
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this
mutationupdate_api_keyRename, expire, enable/disable, change permissions of an existing key.
Endpoint: POST https://live-api.ouinex.com/graphql
Type: Mutation
Returns: Boolean!

Inputs

NameTypeRequiredDescription
nameStringoptionalNew key name.
expires_atStringoptionalNew expiration date
is_activeToggleSwitchoptionalEnable or disable the key
api_key_idString!requiredID of the API key to update
ip_address[String!]optionalReplacement IP allow-list: 1 to 3 IP addresses.
permissions[Permission!]optionalReplacement permission list (lowercase identifiers).
hmac_requiredToggleSwitchoptionalEnable / disable request signing (see create_api_key).

GraphQL Operation

mutation update_api_key($name: String, $is_active: ToggleSwitch, $api_key_id: String!, $permissions: [Permission!]) {
  update_api_key(name: $name, is_active: $is_active, api_key_id: $api_key_id, permissions: $permissions)
}

Code Examples

curl -X POST 'https://live-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"mutation update_api_key($name: String, $is_active: ToggleSwitch, $api_key_id: String!, $permissions: [Permission!]) { update_api_key(name: $name, is_active: $is_active, api_key_id: $api_key_id, permissions: $permissions) }","variables":{"name":"Updated Name","is_active":"on","api_key_id":"key123","permissions":["accounts_balances","open_orders"]}}'
import requests

url = "https://live-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """mutation update_api_key($name: String, $is_active: ToggleSwitch, $api_key_id: String!, $permissions: [Permission!]) { update_api_key(name: $name, is_active: $is_active, api_key_id: $api_key_id, permissions: $permissions) }""",
    "variables": {
        "name": "Updated Name",
        "is_active": "on",
        "api_key_id": "key123",
        "permissions": [
            "accounts_balances",
            "open_orders"
        ]
    },
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `mutation update_api_key($name: String, $is_active: ToggleSwitch, $api_key_id: String!, $permissions: [Permission!]) { update_api_key(name: $name, is_active: $is_active, api_key_id: $api_key_id, permissions: $permissions) }`,
    variables: {
      "name": "Updated Name",
      "is_active": "on",
      "api_key_id": "key123",
      "permissions": [
        "accounts_balances",
        "open_orders"
      ]
    },
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this
mutationdelete_api_keyRevoke an API key.
Endpoint: POST https://live-api.ouinex.com/graphql
Type: Mutation
Returns: Boolean!

Inputs

NameTypeRequiredDescription
api_key_idString!requiredID of the API key to delete

GraphQL Operation

mutation delete_api_key($api_key_id: String!) {
  delete_api_key(api_key_id: $api_key_id)
}

Code Examples

curl -X POST 'https://live-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"mutation delete_api_key($api_key_id: String!) { delete_api_key(api_key_id: $api_key_id) }","variables":{"api_key_id":"key123"}}'
import requests

url = "https://live-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """mutation delete_api_key($api_key_id: String!) { delete_api_key(api_key_id: $api_key_id) }""",
    "variables": {
        "api_key_id": "key123"
    },
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `mutation delete_api_key($api_key_id: String!) { delete_api_key(api_key_id: $api_key_id) }`,
    variables: {
      "api_key_id": "key123"
    },
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this

Subscriptions

Real-time GraphQL subscriptions delivered over a WebSocket connection. Subscribe once, receive a stream of next messages until you unsubscribe or the server closes the channel.

WebSocket transport

Subscriptions use the graphql-ws protocol over secure WebSocket (wss://). Both hosts also still accept the legacy subscriptions-transport-ws protocol; the frames shown below are graphql-ws.

Endpoint

wss://live-api.ouinex.com/graphql for spot subscriptions
wss://live-margin-api.ouinex.com/graphql for derivatives / margin subscriptions

The host you connect to determines which subscriptions are reachable: a spot subscription must be opened against live-api, a margin subscription against live-margin-api. To subscribe to streams from more than one host, open one WebSocket connection per host.

Authentication

Send your bearer token in connectionParams on the initial connection_init frame, under the key authorization (lowercase). The spot host also accepts Authorization there or as a header on the HTTP upgrade request; the margin host requires the lowercase key with graphql-ws.

{
  "type": "connection_init",
  "payload": {
    "authorization": "Bearer <JWT_TOKEN>"
  }
}

The server replies with {"type": "connection_ack"} when authentication succeeds.

Opening a subscription

After connection_ack, send a subscribe frame with a unique id you choose; every next message the server sends back will carry that same id:

{
  "type": "subscribe",
  "id": "1",
  "payload": {
    "query": "subscription instrument_price($instrument_id: String) { instrument_price(instrument_id: $instrument_id) { instrument_id ask bid price_24h_change ts_iso } }",
    "variables": { "instrument_id": "BTCUSDT" }
  }
}

Each update arrives as a next frame:

{
  "type": "next",
  "id": "1",
  "payload": { "data": { "instrument_price": { "instrument_id": "BTCUSDT", "ask": 43210.5, "bid": 43208.0, "price_24h_change": 1.23, "ts_iso": "2026-04-08T12:00:00Z" } } }
}

The server signals end-of-stream with {"type": "complete", "id": "1"}; an error frame with the same shape is sent if the subscription fails. To stop receiving updates yourself, send {"type": "complete", "id": "1"}.

Keeping the connection open

WebSocket connections will still drop occasionally, whether from transient network issues, load-balancer rotations, or an expired bearer token. The recommended pattern is to let the client library reconnect automatically and re-issue every active subscription on the new connection. A reference client uses these settings:

import { createClient } from "graphql-ws";

const client = createClient({
  url: "wss://live-api.ouinex.com/graphql",
  connectionParams: { authorization: `Bearer ${token}` },
  shouldRetry: () => true,
  retryAttempts: 8,
});

client.subscribe(
  {
    query: `subscription instrument_price($instrument_id: String) {
      instrument_price(instrument_id: $instrument_id) { instrument_id ask bid price_24h_change ts_iso }
    }`,
    variables: { instrument_id: "BTCUSDT" },
  },
  {
    next: (msg) => console.log(msg.data),
    error: (err) => console.error(err),
    complete: () => console.log("server closed the stream"),
  }
);

shouldRetry: () => true with retryAttempts: 8 means the library will reconnect up to eight times after a drop, with exponential backoff between attempts; after a successful reconnect it automatically re-issues every active subscribe. If your token has expired by then, sign in again (service_signin) and update connectionParams before reconnecting.

Operational tips:

  • One connection per host. Multiplex many subscriptions on the same WebSocket instead of opening a connection per subscription. The id field on every frame keeps streams separated.
  • Sign in again before the token expires. A token expires together with its API key (expires_at returned by service_signin); reconnect with a fresh token rather than letting the connection close on auth failure.
  • Resume cleanly. When reconnecting, snapshot the latest state via the equivalent query (e.g. call open_orders after reconnecting all_orders) so you do not miss updates that occurred while disconnected.
subscriptionorderbookReal-time spot order book.
Endpoint: WSS wss://live-api.ouinex.com/graphql
Type: Subscription
Returns: OrderbookUpdateResult!

Inputs

NameTypeRequiredDescription
instrument_idString!requiredInstrument to subscribe to.

Each update

Fields of OrderbookUpdateResult selected in the operation below.

FieldTypeDescription
instrument_idString!Instrument for this book
buy[OrderbookItem!]!Buy side of the book
sell[OrderbookItem!]!Sell side of the book

GraphQL Operation

subscription orderbook($instrument_id: String!) {
  orderbook(instrument_id: $instrument_id) {
    instrument_id
    buy { quantity price }
    sell { quantity price }
  }
}
subscriptionall_ordersReal-time updates for the user's spot orders.
Endpoint: WSS wss://live-api.ouinex.com/graphql
Type: Subscription
Returns: Order!

Inputs

NameTypeRequiredDescription
instruments[String!]optionalInstrument IDs to follow; omit for all.

Each update

Fields of Order selected in the operation below.

FieldTypeDescription
order_idString!Order whose status changed.
statusOrderStatus!New order status.
updated_atString!Update timestamp.

GraphQL Operation

subscription all_orders {
  all_orders {
    order_id status updated_at
  }
}
subscriptioninstrument_priceReal-time price ticks for spot instruments.
Endpoint: WSS wss://live-api.ouinex.com/graphql
Type: Subscription
Returns: InstrumentPrice!

Inputs

NameTypeRequiredDescription
instrument_idStringoptionalInstrument to follow; omit for all instruments.

Each update

Fields of InstrumentPrice selected in the operation below.

FieldTypeDescription
instrument_idString!The instrument this tick is for.
askFloatBest ask price.
bidFloatBest bid price.
price_24h_changeFloatPercent change over the last 24 hours.
ts_isoString!Tick timestamp (ISO-8601).

GraphQL Operation

subscription instrument_price {
  instrument_price {
    instrument_id ask bid price_24h_change ts_iso
  }
}
subscriptioninstrument_price_barReal-time OHLC candle stream for a spot instrument.
Endpoint: WSS wss://live-api.ouinex.com/graphql
Type: Subscription
Returns: InstrumentPriceHistory!

Inputs

NameTypeRequiredDescription
instrument_idString!requiredInstrument to subscribe to.
periodicityInstrumentHistoryPeriodicity!requiredBar interval.

Each update

Fields of InstrumentPriceHistory selected in the operation below.

FieldTypeDescription
instrument_idString!Instrument the bar applies to.
openFloat!Open price.
highFloat!High price.
lowFloat!Low price.
closeFloat!Close price.
ts_isoString!Bar timestamp (ISO-8601).

GraphQL Operation

subscription instrument_price_bar($instrument_id: String!, $periodicity: InstrumentHistoryPeriodicity!) {
  instrument_price_bar(instrument_id: $instrument_id, periodicity: $periodicity) {
    instrument_id open high low close ts_iso
  }
}
subscriptionmargin_orderbookReal-time derivatives order book (full snapshot on every message).
Endpoint: WSS wss://live-margin-api.ouinex.com/graphql
Type: Subscription
Returns: OrderbookUpdateResult!

Every message is a full snapshot of the book (not a delta). ts is the UTC timestamp in milliseconds, as a string.

Inputs

NameTypeRequiredDescription
instrument_idString!requiredInstrument to subscribe to.

Each update

Fields of OrderbookUpdateResult selected in the operation below.

FieldTypeDescription
instrument_idString!Instrument for this book
tsString!UTC timestamp in milliseconds
buy[OrderbookItem!]!Buy side of the book
sell[OrderbookItem!]!Sell side of the book

GraphQL Operation

subscription margin_orderbook($instrument_id: String!) {
  margin_orderbook(instrument_id: $instrument_id) {
    instrument_id ts
    buy { price quantity exchange }
    sell { price quantity exchange }
  }
}
subscriptionmargin_instrument_price_barReal-time OHLC candle stream for a derivatives instrument.
Endpoint: WSS wss://live-margin-api.ouinex.com/graphql
Type: Subscription
Returns: MarginInstrumentPriceHistory!

Inputs

NameTypeRequiredDescription
instrument_idString!requiredInstrument to subscribe to.
periodicityMarginInstrumentHistoryPeriodicity!requiredBar interval.

Each update

Fields of MarginInstrumentPriceHistory selected in the operation below.

FieldTypeDescription
margin_instrument_idString!Contract this bar applies to.
openFloatOpen price.
highFloatHigh price.
lowFloatLow price.
closeFloatClose price.
updated_at_isoString!Bar timestamp (ISO-8601).

GraphQL Operation

subscription margin_instrument_price_bar($instrument_id: String!, $periodicity: MarginInstrumentHistoryPeriodicity!) {
  margin_instrument_price_bar(instrument_id: $instrument_id, periodicity: $periodicity) {
    margin_instrument_id open high low close updated_at_iso
  }
}
subscriptionmargin_order_updateReal-time updates for the user's margin orders.
Endpoint: WSS wss://live-margin-api.ouinex.com/graphql
Type: Subscription
Returns: MarginOrder!
Permission: open_derivatives_orders

Inputs

NameTypeRequiredDescription
wallet_idStringoptionalWallet to follow. Defaults to MAIN.

Each update

Fields of MarginOrder selected in the operation below.

FieldTypeDescription
margin_order_idString!The order whose state changed.
margin_position_idStringLinked position, if any.
instrument_idString!Contract symbol.
sideMarginPositionSide!buy or sell.
typeMarginOrderType!market or limit.
statusMarginOrderStatus!New order status.
leverageInt!Leverage applied.
quantityFloat!Order quantity.
executed_quantityFloat!Quantity filled so far.
priceFloatOrder price.
limit_priceFloatLimit / stop price.
stop_lossFloatStop-loss price.
take_profitFloatTake-profit price.
fee_amountFloatFee charged so far.
time_in_forceMarginOrderTimeInForce!Time in force (fok, ioc, gtc, gtd).
updated_at_isoString!Update timestamp (ISO-8601).
wallet_idStringWallet the order belongs to.

GraphQL Operation

subscription margin_order_update {
  margin_order_update {
    margin_order_id margin_position_id instrument_id side type status leverage quantity executed_quantity price limit_price stop_loss take_profit fee_amount time_in_force updated_at_iso wallet_id
  }
}
subscriptionopen_margin_position_updateReal-time updates for the user's open margin positions.
Endpoint: WSS wss://live-margin-api.ouinex.com/graphql
Type: Subscription
Returns: MarginPosition!
Permission: open_derivatives_positions

Inputs

NameTypeRequiredDescription
wallet_idStringoptionalWallet to follow. Defaults to MAIN.

Each update

Fields of MarginPosition selected in the operation below.

FieldTypeDescription
margin_position_idString!Position the update applies to.
instrument_idString!Contract symbol.
sideMarginPositionSide!buy (long) or sell (short).
amountFloat!Current position size.
leverageInt!Leverage on the position.
entry_priceFloat!Average entry price.
exit_priceFloatRealised exit price (for closed legs).
pnlFloat!Unrealised P&L.
total_pnlFloat!Realised + unrealised P&L.
marginFloatMargin allocated to the position.
margin_currency_idString!Currency of the margin.
funding_fee_amountFloat!Funding fee paid / received.
stop_lossFloatStop-loss price.
take_profitFloatTake-profit price.
close_reasonStringClose reason text (when closing).
close_reason_codeStringClose reason machine code.
updated_at_isoString!Update timestamp (ISO-8601).
wallet_idStringWallet the position belongs to.

GraphQL Operation

subscription open_margin_position_update {
  open_margin_position_update {
    margin_position_id instrument_id side amount leverage entry_price exit_price pnl total_pnl margin margin_currency_id funding_fee_amount stop_loss take_profit close_reason close_reason_code updated_at_iso wallet_id
  }
}
subscriptionuser_balance_positionReal-time margin account balance, equity and risk metrics.
Endpoint: WSS wss://live-margin-api.ouinex.com/graphql
Type: Subscription
Returns: UserBalanceDetails!
Permission: open_derivatives_positions

Inputs

NameTypeRequiredDescription
wallet_idStringoptionalWallet to follow. Defaults to MAIN.

Each update

Fields of UserBalanceDetails selected in the operation below.

FieldTypeDescription
free_balanceFloat!Available balance.
equityFloat!Total equity (balance + unrealised P&L).
currently_used_marginFloat!Margin currently locked by open positions.
margin_call_left_marginFloat!Margin remaining before margin call.
liquidation_left_marginFloat!Margin remaining before liquidation.
margin_ratio_percentageFloatCurrent margin ratio %.
pnlFloat!Unrealised P&L.
total_pnlFloat!Realised + unrealised P&L.
unsettled_balanceFloatBalance pending settlement.

GraphQL Operation

subscription user_balance_position {
  user_balance_position {
    free_balance equity currently_used_margin margin_call_left_margin liquidation_left_margin margin_ratio_percentage pnl total_pnl unsettled_balance
  }
}
subscriptionmargin_user_updateMargin notifications: margin calls, liquidation warnings, trading-status changes.
Endpoint: WSS wss://live-margin-api.ouinex.com/graphql
Type: Subscription
Returns: MarginUserUpdate!
Permission: open_derivatives_positions

Inputs

NameTypeRequiredDescription
wallet_idStringoptionalWallet to follow. Defaults to MAIN.

Each update

Fields of MarginUserUpdate selected in the operation below.

FieldTypeDescription
notificationMarginUserUpdateNotification!Notification payload.

GraphQL Operation

subscription margin_user_update {
  margin_user_update {
    notification { title body trigger }
  }
}
subscriptionstop_preset_updateUpdates to the user's stop presets.
Endpoint: WSS wss://live-margin-api.ouinex.com/graphql
Type: Subscription
Returns: MarginPositionStopPreset!

Inputs

NameTypeRequiredDescription
wallet_idStringoptionalWallet filter.

Each update

Fields of MarginPositionStopPreset selected in the operation below.

FieldTypeDescription
preset_idString!
margin_position_idString
order_idStringSet for presets configured at order creation, before the position exists
instrument_idString!
preset_typeStopPresetType!
statusStopPresetStatus!
trigger_priceFloat!
target_sl_priceFloat
created_atString!
updated_atString!

GraphQL Operation

subscription stop_preset_update {
  stop_preset_update { preset_id margin_position_id order_id instrument_id preset_type status trigger_price target_sl_price created_at updated_at }
}
subscriptionstop_order_updateUpdates to the user's stop orders.
Endpoint: WSS wss://live-margin-api.ouinex.com/graphql
Type: Subscription
Returns: StopMarginOrder!

Inputs

NameTypeRequiredDescription
wallet_idStringoptionalWallet filter.

Each update

Fields of StopMarginOrder selected in the operation below.

FieldTypeDescription
stop_order_idString!
instrument_idString!
sideMarginPositionSide!
stop_order_typeStopOrderType!
statusStopOrderStatus!
termination_reasonAdvancedOrderTerminationReason
termination_detailString
quantityFloat!
leverageInt!
wallet_idString!
trigger_priceFloat
trigger_directionStopOrderTriggerDirection
limit_priceFloat
retracement_typeTrailingStopRetracementType
callback_rateFloat
callback_distanceFloat
activation_priceFloat
best_priceFloat
is_activatedBoolean
take_profitFloat
stop_lossFloat
autoscale_tp_slBoolean!
created_atString!
updated_atString!

GraphQL Operation

subscription stop_order_update {
  stop_order_update { stop_order_id instrument_id side stop_order_type status termination_reason termination_detail quantity leverage wallet_id trigger_price trigger_direction limit_price retracement_type callback_rate callback_distance activation_price best_price is_activated take_profit stop_loss autoscale_tp_sl created_at updated_at }
}
subscriptionoco_order_updateUpdates to the user's OCO orders.
Endpoint: WSS wss://live-margin-api.ouinex.com/graphql
Type: Subscription
Returns: OcoMarginOrder!

Inputs

NameTypeRequiredDescription
wallet_idStringoptionalWallet filter.

Each update

Fields of OcoMarginOrder selected in the operation below.

FieldTypeDescription
oco_order_idString!
instrument_idString!
sideMarginPositionSide!
statusOcoOrderStatus!
termination_reasonAdvancedOrderTerminationReason
termination_detailString
quantityFloat!
leverageInt!
wallet_idString!
tp_trigger_priceFloat!
tp_trigger_directionStopOrderTriggerDirection!
tp_order_typeMarginOrderType!
tp_limit_priceFloat
sl_trigger_priceFloat!
sl_trigger_directionStopOrderTriggerDirection!
sl_order_typeMarginOrderType!
sl_limit_priceFloat
triggered_legOcoTriggeredLeg
created_atString!
updated_atString!

GraphQL Operation

subscription oco_order_update {
  oco_order_update { oco_order_id instrument_id side status termination_reason termination_detail quantity leverage wallet_id tp_trigger_price tp_trigger_direction tp_order_type tp_limit_price sl_trigger_price sl_trigger_direction sl_order_type sl_limit_price triggered_leg created_at updated_at }
}
subscriptionoto_order_updateUpdates to the user's OTO orders.
Endpoint: WSS wss://live-margin-api.ouinex.com/graphql
Type: Subscription
Returns: OtoMarginOrder!

Inputs

NameTypeRequiredDescription
wallet_idStringoptionalWallet filter.

Each update

Fields of OtoMarginOrder selected in the operation below.

FieldTypeDescription
oto_order_idString!
instrument_idString!
sideMarginPositionSide!
statusOtoOrderStatus!
leverageInt!
wallet_idString!
primary_order_typeMarginOrderType!
primary_priceFloat
primary_quantityFloat!
secondary_sideMarginPositionSide!
secondary_order_typeMarginOrderType!
secondary_priceFloat
secondary_quantityFloat!
primary_order_idString
secondary_order_idString
termination_reasonAdvancedOrderTerminationReason
termination_detailString
created_atString!
updated_atString!

GraphQL Operation

subscription oto_order_update {
  oto_order_update { oto_order_id instrument_id side status leverage wallet_id primary_order_type primary_price primary_quantity secondary_side secondary_order_type secondary_price secondary_quantity primary_order_id secondary_order_id termination_reason termination_detail created_at updated_at }
}
subscriptiontwap_order_updateUpdates to the user's TWAP orders.
Endpoint: WSS wss://live-margin-api.ouinex.com/graphql
Type: Subscription
Returns: TWAPMarginOrder!

Inputs

NameTypeRequiredDescription
wallet_idStringoptionalWallet filter.

Each update

Fields of TWAPMarginOrder selected in the operation below.

FieldTypeDescription
twap_order_idString!
instrument_idString!
sideMarginPositionSide!
statusTWAPOrderStatus!
termination_reasonAdvancedOrderTerminationReason
termination_detailString
total_quantityFloat!
executed_quantityFloat!
frequencyTWAPFrequency!
durationInt!
total_slicesInt!
execution_strategyTWAPExecutionStrategy!
slice_order_typeMarginOrderType!
start_timeString!
end_timeString!
next_execution_timeString
limit_priceFloat
price_tolerance_percentFloat
slices_executedInt!
slices_failedInt!
average_execution_priceFloat
leverageInt!
wallet_idString!
created_atString!
updated_atString!
progress_percentFloat!

GraphQL Operation

subscription twap_order_update {
  twap_order_update { twap_order_id instrument_id side status termination_reason termination_detail total_quantity executed_quantity frequency duration total_slices execution_strategy slice_order_type start_time end_time next_execution_time limit_price price_tolerance_percent slices_executed slices_failed average_execution_price leverage wallet_id created_at updated_at progress_percent }
}
subscriptioniceberg_order_updateUpdates to the user's iceberg orders.
Endpoint: WSS wss://live-margin-api.ouinex.com/graphql
Type: Subscription
Returns: IcebergMarginOrder!

Inputs

NameTypeRequiredDescription
wallet_idStringoptionalWallet filter.

Each update

Fields of IcebergMarginOrder selected in the operation below.

FieldTypeDescription
iceberg_order_idString!
instrument_idString!
sideMarginPositionSide!
statusIcebergOrderStatus!
termination_reasonAdvancedOrderTerminationReason
termination_detailString
total_quantityFloat!
executed_quantityFloat!
display_quantityFloat!
placement_typeIcebergPlacementType!
limit_priceFloat
leverageInt!
wallet_idString!
average_execution_priceFloat
created_atString!
updated_atString!

GraphQL Operation

subscription iceberg_order_update {
  iceberg_order_update { iceberg_order_id instrument_id side status termination_reason termination_detail total_quantity executed_quantity display_quantity placement_type limit_price leverage wallet_id average_execution_price created_at updated_at }
}
subscriptionscaled_order_updateUpdates to the user's scaled orders.
Endpoint: WSS wss://live-margin-api.ouinex.com/graphql
Type: Subscription
Returns: ScaledMarginOrder!

Inputs

NameTypeRequiredDescription
wallet_idStringoptionalWallet filter.

Each update

Fields of ScaledMarginOrder selected in the operation below.

FieldTypeDescription
scaled_order_idString!
instrument_idString!
sideMarginPositionSide!
statusScaledOrderStatus!
termination_reasonAdvancedOrderTerminationReason
termination_detailString
total_quantityFloat!
executed_quantityFloat!
number_of_ordersInt!
price_range_startFloat!
price_range_endFloat!
leverageInt!
wallet_idString!
average_execution_priceFloat
orders_executedInt!
orders_failedInt!
created_atString!
updated_atString!

GraphQL Operation

subscription scaled_order_update {
  scaled_order_update { scaled_order_id instrument_id side status termination_reason termination_detail total_quantity executed_quantity number_of_orders price_range_start price_range_end leverage wallet_id average_execution_price orders_executed orders_failed created_at updated_at }
}

Conversions & Payments

Quote and execute currency conversions, inspect payment fees and limits, and manage crypto / fiat deposits and withdrawals.

mutationcreate_conversion_quoteGet a locked exchange-rate quote between two currencies.
Endpoint: POST https://live-api.ouinex.com/graphql
Type: Mutation
Returns: CreateConversionQuoteResult!
Permission: create_conversion_quote
Rate limit: 120 requests / 60 s

Inputs

NameTypeRequiredDescription
source_currency_idString!requiredSource currency ID
target_currency_idString!requiredTarget currency ID
source_currency_amountFloatoptionalAmount to convert from source
target_currency_amountFloatoptionalAmount to receive in target
instrument_idStringoptionalRestrict the quote to this instrument.
fees_in_priceBooleanoptional
default true
When true (default), the user's taker fee is included in the quoted price.
referenceStringoptionalClient reference.
ttlIntoptionalQuote lifetime in seconds. Defaults to, and may not exceed, the instrument's maximum quote TTL.
dry_runToggleSwitchoptional
default off
With on the quote is returned but not stored, so it cannot be executed.

Response

Fields of CreateConversionQuoteResult selected in the operation below.

FieldTypeDescription
conversion_quote_idString!Unique quote ID
priceFloat!Exchange rate
expires_at_isoString!Expiry time (ISO 8601).
source_currency_amountFloat!Amount in the source currency.
target_currency_amountFloat!Amount in the target currency.
fees[EstimateOrderFee!]!Fees.

GraphQL Operation

mutation create_conversion_quote($source_currency_id: String!, $target_currency_id: String!, $source_currency_amount: Float, $ttl: Int) {
  create_conversion_quote(source_currency_id: $source_currency_id, target_currency_id: $target_currency_id, source_currency_amount: $source_currency_amount, ttl: $ttl) {
    conversion_quote_id price expires_at_iso source_currency_amount target_currency_amount
    fees { currency_id amount }
  }
}

Code Examples

curl -X POST 'https://live-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"mutation create_conversion_quote($source_currency_id: String!, $target_currency_id: String!, $source_currency_amount: Float, $ttl: Int) { create_conversion_quote(source_currency_id: $source_currency_id, target_currency_id: $target_currency_id, source_currency_amount: $source_currency_amount, ttl: $ttl) { conversion_quote_id price expires_at_iso source_currency_amount target_currency_amount fees { currency_id amount } } }","variables":{"source_currency_id":"BTC","target_currency_id":"USDT","source_currency_amount":1,"ttl":60}}'
import requests

url = "https://live-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """mutation create_conversion_quote($source_currency_id: String!, $target_currency_id: String!, $source_currency_amount: Float, $ttl: Int) { create_conversion_quote(source_currency_id: $source_currency_id, target_currency_id: $target_currency_id, source_currency_amount: $source_currency_amount, ttl: $ttl) { conversion_quote_id price expires_at_iso source_currency_amount target_currency_amount fees { currency_id amount } } }""",
    "variables": {
        "source_currency_id": "BTC",
        "target_currency_id": "USDT",
        "source_currency_amount": 1,
        "ttl": 60
    },
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `mutation create_conversion_quote($source_currency_id: String!, $target_currency_id: String!, $source_currency_amount: Float, $ttl: Int) { create_conversion_quote(source_currency_id: $source_currency_id, target_currency_id: $target_currency_id, source_currency_amount: $source_currency_amount, ttl: $ttl) { conversion_quote_id price expires_at_iso source_currency_amount target_currency_amount fees { currency_id amount } } }`,
    variables: {
      "source_currency_id": "BTC",
      "target_currency_id": "USDT",
      "source_currency_amount": 1,
      "ttl": 60
    },
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this
mutationcreate_conversion_orderExecute a conversion against a quote.
Endpoint: POST https://live-api.ouinex.com/graphql
Type: Mutation
Returns: Conversion!
Permission: create_conversion_order
Rate limit: 120 requests / 60 s
Optional header: x-idempotency-key: a repeated key within 5 minutes is rejected with ERR_DUPLICATE_REQUEST.
Signed request: X-Signature + X-Nonce required when the API key has hmac_required: on (see create_api_key).

Inputs

NameTypeRequiredDescription
conversion_quote_idString!requiredConversion quote ID from create_conversion_quote
referenceStringoptionalClient reference.
source_currency_amountFloatoptionalExecute only part of the quote (give at most one of the two amounts). When neither is given, the remaining quote amount is executed.
target_currency_amountFloatoptionalExecute only part of the quote (give at most one of the two amounts).
return_on_completeBooleanoptional
default true
When true (default), the response is returned once the conversion has completed; with false it is returned immediately.
wallet_idStringoptionalWallet ID.

Response

Fields of Conversion selected in the operation below.

FieldTypeDescription
conversion_idString!Conversion ID.
statusConversionStatus!Conversion status.
created_atString!Creation time.
priceFloat!Price.
source_currency_idString!Currency converted from.
target_currency_idString!Currency converted to.
source_currency_amountFloat!Amount in the source currency.
target_currency_amountFloat!Amount in the target currency.

GraphQL Operation

mutation create_conversion_order($conversion_quote_id: String!, $wallet_id: String) {
  create_conversion_order(conversion_quote_id: $conversion_quote_id, wallet_id: $wallet_id) {
    conversion_id status created_at price source_currency_id target_currency_id source_currency_amount target_currency_amount
  }
}

Code Examples

curl -X POST 'https://live-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"mutation create_conversion_order($conversion_quote_id: String!, $wallet_id: String) { create_conversion_order(conversion_quote_id: $conversion_quote_id, wallet_id: $wallet_id) { conversion_id status created_at price source_currency_id target_currency_id source_currency_amount target_currency_amount } }","variables":{"conversion_quote_id":"quote789","wallet_id":"wallet123"}}'
import requests

url = "https://live-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """mutation create_conversion_order($conversion_quote_id: String!, $wallet_id: String) { create_conversion_order(conversion_quote_id: $conversion_quote_id, wallet_id: $wallet_id) { conversion_id status created_at price source_currency_id target_currency_id source_currency_amount target_currency_amount } }""",
    "variables": {
        "conversion_quote_id": "quote789",
        "wallet_id": "wallet123"
    },
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `mutation create_conversion_order($conversion_quote_id: String!, $wallet_id: String) { create_conversion_order(conversion_quote_id: $conversion_quote_id, wallet_id: $wallet_id) { conversion_id status created_at price source_currency_id target_currency_id source_currency_amount target_currency_amount } }`,
    variables: {
      "conversion_quote_id": "quote789",
      "wallet_id": "wallet123"
    },
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this
queryconversionsList conversion history.
Endpoint: POST https://live-api.ouinex.com/graphql
Type: Query
Returns: [Conversion!]!
Permission: conversions
Rate limit: 120 requests / 60 s

Inputs

NameTypeRequiredDescription
searchStringoptionalSearch term.
referenceStringoptionalClient reference.
status_in[ConversionStatus!]optionalFilter: status in list.
conversion_quote_idStringoptionalFilter by conversion_quote_id.
source_currency_idStringoptionalFilter by source_currency_id.
target_currency_idStringoptionalFilter by target_currency_id.
pagerPagerInputoptional
default {limit: 30, offset: 0}
Pagination (limit, offset).
sortSortInputoptional
default {direction: DESC}
Sort order.
dateRangeDateRangeInputoptional
default {}
Date-time window (time_from, time_to). When omitted the server applies a default window (14 days back from now in the default platform settings); a range wider than the configured maximum (1 year for user-scoped queries by default) is rejected. Pass it explicitly to read older history.
serialIdRangeSerialIdRangeInputoptional
default {}
Filter by serial ID range.
wallet_idStringoptionalWallet filter.
instrument_idStringoptionalInstrument filter.
currency_idStringoptionalCurrency filter.

Response

Fields of Conversion selected in the operation below.

FieldTypeDescription
conversion_idString!Conversion ID
source_currency_idString!Currency converted from.
source_currency_amountFloat!Amount in the source currency.
target_currency_idString!Currency converted to.
target_currency_amountFloat!Amount in the target currency.
priceFloat!Price.
statusConversionStatus!Status.
created_at_isoString!Creation time (ISO 8601).

GraphQL Operation

query conversions($wallet_id: String) {
  conversions(wallet_id: $wallet_id) {
    conversion_id source_currency_id source_currency_amount target_currency_id target_currency_amount price status created_at_iso
  }
}

Code Examples

curl -X POST 'https://live-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"query conversions($wallet_id: String) { conversions(wallet_id: $wallet_id) { conversion_id source_currency_id source_currency_amount target_currency_id target_currency_amount price status created_at_iso } }","variables":{"wallet_id":"wallet123"}}'
import requests

url = "https://live-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """query conversions($wallet_id: String) { conversions(wallet_id: $wallet_id) { conversion_id source_currency_id source_currency_amount target_currency_id target_currency_amount price status created_at_iso } }""",
    "variables": {
        "wallet_id": "wallet123"
    },
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `query conversions($wallet_id: String) { conversions(wallet_id: $wallet_id) { conversion_id source_currency_id source_currency_amount target_currency_id target_currency_amount price status created_at_iso } }`,
    variables: {
      "wallet_id": "wallet123"
    },
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this
querypayments_feesRead fee schedule for deposits / withdrawals.
Endpoint: POST https://live-api.ouinex.com/graphql
Type: Query
Returns: [PaymentFee!]!
Permission: payments_fees
Rate limit: 30 requests / 60 s

Inputs

NameTypeRequiredDescription
payment_route_idStringoptionalFilter by payment_route_id.
currency_idStringoptionalCurrency filter.
pagerPagerInputoptional
default {limit: 30, offset: 0}
Pagination (limit, offset).
sortSortInputoptional
default {direction: DESC}
Sort order.
calculation_typeFeeCalculationTypeoptionalFilter by calculation_type.

Response

Fields of PaymentFee selected in the operation below.

FieldTypeDescription
currency_idString!Currency code (BTC, ETH, USD, etc.)
deposit_flat_feeFloatFixed fee for deposits
deposit_progressive_feeFloatPercentage-based deposit fee
payment_route_idStringPayment processor route identifier
calculation_typeFeeCalculationTypeHow flat and progressive fees combine (sum or max).

GraphQL Operation

query payments_fees($currency_id: String) {
  payments_fees(currency_id: $currency_id) {
    currency_id deposit_flat_fee deposit_progressive_fee payment_route_id calculation_type
  }
}

Code Examples

curl -X POST 'https://live-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"query payments_fees($currency_id: String) { payments_fees(currency_id: $currency_id) { currency_id deposit_flat_fee deposit_progressive_fee payment_route_id calculation_type } }","variables":{"currency_id":"BTC"}}'
import requests

url = "https://live-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """query payments_fees($currency_id: String) { payments_fees(currency_id: $currency_id) { currency_id deposit_flat_fee deposit_progressive_fee payment_route_id calculation_type } }""",
    "variables": {
        "currency_id": "BTC"
    },
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `query payments_fees($currency_id: String) { payments_fees(currency_id: $currency_id) { currency_id deposit_flat_fee deposit_progressive_fee payment_route_id calculation_type } }`,
    variables: {
      "currency_id": "BTC"
    },
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this
querytrading_feesRead trading fees per instrument.
Endpoint: POST https://live-api.ouinex.com/graphql
Type: Query
Returns: [TradingFee!]!
Permission: trading_fees
Rate limit: 30 requests / 60 s

Inputs

NameTypeRequiredDescription
instrument_idStringoptionalInstrument filter.
pagerPagerInputoptional
default {limit: 30, offset: 0}
Pagination (limit, offset).
sortSortInputoptional
default {direction: DESC}
Sort order.

Response

Fields of TradingFee selected in the operation below.

FieldTypeDescription
instrument_idString!Instrument.
maker_flatFloat!Maker fee, flat part.
maker_progressiveFloat!Maker fee, proportional part.
taker_flatFloat!Taker fee, flat part.
taker_progressiveFloat!Taker fee, proportional part.

GraphQL Operation

query trading_fees($instrument_id: String) {
  trading_fees(instrument_id: $instrument_id) {
    instrument_id maker_flat maker_progressive taker_flat taker_progressive
  }
}

Code Examples

curl -X POST 'https://live-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"query trading_fees($instrument_id: String) { trading_fees(instrument_id: $instrument_id) { instrument_id maker_flat maker_progressive taker_flat taker_progressive } }","variables":{"instrument_id":"BTCUSDT"}}'
import requests

url = "https://live-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """query trading_fees($instrument_id: String) { trading_fees(instrument_id: $instrument_id) { instrument_id maker_flat maker_progressive taker_flat taker_progressive } }""",
    "variables": {
        "instrument_id": "BTCUSDT"
    },
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `query trading_fees($instrument_id: String) { trading_fees(instrument_id: $instrument_id) { instrument_id maker_flat maker_progressive taker_flat taker_progressive } }`,
    variables: {
      "instrument_id": "BTCUSDT"
    },
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this
mutationcalculate_payments_limitsCalculate the user's daily / weekly / monthly payment limits.
Endpoint: POST https://live-api.ouinex.com/graphql
Type: Mutation
Returns: LimitsStatus!

Declared as a mutation even though it only reads data.

Inputs

NameTypeRequiredDescription
notion_currencyString!requiredCurrency the limits are expressed in.
currency_idString!requiredCurrency of the payment.
typePaymentType!requireddeposit or withdrawal.

Response

Fields of LimitsStatus selected in the operation below.

FieldTypeDescription
paymentsLimitsStatusPeriods!Payment limits by period (daily, weekly, monthly)
aggregatedLimitsStatusPeriodsAggregated withdrawal limits by period

GraphQL Operation

mutation calculate_payments_limits($notion_currency: String!, $currency_id: String!, $type: PaymentType!) {
  calculate_payments_limits(notion_currency: $notion_currency, currency_id: $currency_id, type: $type) {
    payments {
      daily { limit filled remaining }
      weekly { limit filled remaining }
      monthly { limit filled remaining }
    }
    aggregated {
      daily { limit filled remaining }
      weekly { limit filled remaining }
      monthly { limit filled remaining }
    }
  }
}

Code Examples

curl -X POST 'https://live-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"mutation calculate_payments_limits($notion_currency: String!, $currency_id: String!, $type: PaymentType!) { calculate_payments_limits(notion_currency: $notion_currency, currency_id: $currency_id, type: $type) { payments { daily { limit filled remaining } weekly { limit filled remaining } monthly { limit filled remaining } } aggregated { daily { limit filled remaining } weekly { limit filled remaining } monthly { limit filled remaining } } } }","variables":{"notion_currency":"USD","currency_id":"BTC","type":"deposit"}}'
import requests

url = "https://live-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """mutation calculate_payments_limits($notion_currency: String!, $currency_id: String!, $type: PaymentType!) { calculate_payments_limits(notion_currency: $notion_currency, currency_id: $currency_id, type: $type) { payments { daily { limit filled remaining } weekly { limit filled remaining } monthly { limit filled remaining } } aggregated { daily { limit filled remaining } weekly { limit filled remaining } monthly { limit filled remaining } } } }""",
    "variables": {
        "notion_currency": "USD",
        "currency_id": "BTC",
        "type": "deposit"
    },
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `mutation calculate_payments_limits($notion_currency: String!, $currency_id: String!, $type: PaymentType!) { calculate_payments_limits(notion_currency: $notion_currency, currency_id: $currency_id, type: $type) { payments { daily { limit filled remaining } weekly { limit filled remaining } monthly { limit filled remaining } } aggregated { daily { limit filled remaining } weekly { limit filled remaining } monthly { limit filled remaining } } } }`,
    variables: {
      "notion_currency": "USD",
      "currency_id": "BTC",
      "type": "deposit"
    },
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this
querypaymentsList deposit / withdrawal history.
Endpoint: POST https://live-api.ouinex.com/graphql
Type: Query
Returns: [Payment!]!
Permission: payments
Rate limit: 60 requests / 60 s

Inputs

NameTypeRequiredDescription
payment_idStringoptionalFilter by payment_id.
remote_txidStringoptionalFilter by remote_txid.
currency_idStringoptionalCurrency filter.
typePaymentTypeoptionalFilter by payment type (deposit, withdrawal)
payment_id_in[String!]optionalFilter: payment_id in list.
payment_id_not_in[String!]optionalFilter: payment_id not in list.
searchStringoptionalSearch term.
status[PaymentStatus!]optionalFilter by payment status
pagerPagerInputoptional
default {limit: 30, offset: 0}
Pagination (limit, offset).
sortSortInputoptional
default {direction: DESC}
Sort order.
dateRangeDateRangeInputoptional
default {}
Date-time window (time_from, time_to). When omitted the server applies a default window (14 days back from now in the default platform settings); a range wider than the configured maximum (1 year for user-scoped queries by default) is rejected. Pass it explicitly to read older history.
serialIdRangeSerialIdRangeInputoptional
default {}
Filter by serial ID range.
currency_typeCurrencyTypeoptionalFilter by currency_type.
quote_currency_idStringoptionalFilter by quote_currency_id.
referenceStringoptionalClient reference.
wallet_idStringoptionalWallet filter.

Response

Fields of Payment selected in the operation below.

FieldTypeDescription
payment_idString!Payment ID
currency_idString!Currency.
amountFloat!Amount.
typePaymentType!Deposit or withdrawal
statusPaymentStatus!Status.
crypto_transaction_idStringOn-chain transaction hash.
crypto_addressStringDestination (withdrawal) or deposit address.
fee_amountFloatFee amount.
created_atString!Creation time.

GraphQL Operation

query payments($type: PaymentType) {
  payments(type: $type) {
    payment_id currency_id amount type status crypto_transaction_id crypto_address fee_amount created_at
  }
}

Code Examples

curl -X POST 'https://live-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"query payments($type: PaymentType) { payments(type: $type) { payment_id currency_id amount type status crypto_transaction_id crypto_address fee_amount created_at } }","variables":{"type":"deposit"}}'
import requests

url = "https://live-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """query payments($type: PaymentType) { payments(type: $type) { payment_id currency_id amount type status crypto_transaction_id crypto_address fee_amount created_at } }""",
    "variables": {
        "type": "deposit"
    },
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `query payments($type: PaymentType) { payments(type: $type) { payment_id currency_id amount type status crypto_transaction_id crypto_address fee_amount created_at } }`,
    variables: {
      "type": "deposit"
    },
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this
querypayments_routesList available deposit / withdrawal methods.
Endpoint: POST https://live-api.ouinex.com/graphql
Type: Query
Returns: [PaymentRoute!]!
Permission: payments_routes
Rate limit: 60 requests / 60 s

Inputs

NameTypeRequiredDescription
payment_route_idStringoptionalFilter by payment_route_id.
currency_idStringoptionalCurrency filter.
crypto_networkStringoptionalFilter by network.
verification_typeVerificationTypeoptionalFilter by verification_type.
currency_typeCurrencyTypeoptionalFilter by currency_type.
pagerPagerInputoptional
default {limit: 30, offset: 0}
Pagination (limit, offset).
sortSortInputoptional
default {direction: DESC}
Sort order.

Response

Fields of PaymentRoute selected in the operation below.

FieldTypeDescription
payment_route_idString!Unique payment route identifier
currency_idString!Currency code
nameStringPayment route name (e.g., Bank Transfer, Crypto Network)
crypto_networkStringNetwork.
crypto_address_generate_newToggleSwitchDeposit-address generation setting of the route (on / off).
crypto_address_tag_typeCryptoAddressTagTypeAddress tag type used on this route.
fiat_iframe_deposit_urlStringHosted deposit page URL, for routes that use one.
fiat_iframe_withdrawal_urlStringHosted withdrawal page URL, for routes that use one.
fiat_transfer_typeStringFiat transfer type.
is_activeToggleSwitch!Whether this route is currently available
extend_network_feeToggleSwitchWhen on, the estimated network fee is added to the withdrawal fee.
verification_typeVerificationTypeVerification required for withdrawals on this route.
deposit_enabledToggleSwitchIndicates if deposits enabled on this route
withdrawal_enabledToggleSwitchIndicates if withdrawals enabled on this route
is_crypto_to_fiatToggleSwitchIndicates if that route allows crypto to fiat feature

GraphQL Operation

query payments_routes {
  payments_routes {
    payment_route_id currency_id name crypto_network crypto_address_generate_new crypto_address_tag_type fiat_iframe_deposit_url fiat_iframe_withdrawal_url fiat_transfer_type is_active extend_network_fee verification_type deposit_enabled withdrawal_enabled is_crypto_to_fiat
  }
}

Code Examples

curl -X POST 'https://live-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"query payments_routes { payments_routes { payment_route_id currency_id name crypto_network crypto_address_generate_new crypto_address_tag_type fiat_iframe_deposit_url fiat_iframe_withdrawal_url fiat_transfer_type is_active extend_network_fee verification_type deposit_enabled withdrawal_enabled is_crypto_to_fiat } }","variables":{}}'
import requests

url = "https://live-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """query payments_routes { payments_routes { payment_route_id currency_id name crypto_network crypto_address_generate_new crypto_address_tag_type fiat_iframe_deposit_url fiat_iframe_withdrawal_url fiat_transfer_type is_active extend_network_fee verification_type deposit_enabled withdrawal_enabled is_crypto_to_fiat } }""",
    "variables": {},
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `query payments_routes { payments_routes { payment_route_id currency_id name crypto_network crypto_address_generate_new crypto_address_tag_type fiat_iframe_deposit_url fiat_iframe_withdrawal_url fiat_transfer_type is_active extend_network_fee verification_type deposit_enabled withdrawal_enabled is_crypto_to_fiat } }`,
    variables: {},
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this
mutationcreate_withdrawal_cryptoInitiate a crypto withdrawal to an external address.
Endpoint: POST https://live-api.ouinex.com/graphql
Type: Mutation
Returns: Payment!
Permission: create_withdrawal_crypto
Rate limit: 30 requests / 60 s
Optional header: x-idempotency-key: a repeated key within 5 minutes is rejected with ERR_DUPLICATE_REQUEST.
Signed request: X-Signature + X-Nonce required when the API key has hmac_required: on (see create_api_key).

Inputs

NameTypeRequiredDescription
payment_route_idStringoptionalPayment route to use. If omitted, the route is resolved from currency_id (+ optional crypto_network).
currency_idStringoptionalCurrency ID.
crypto_networkStringoptionalNetwork to withdraw on (used to resolve the route when payment_route_id is omitted).
amountFloat!requiredAmount to withdraw
crypto_addressString!requiredRecipient wallet address
crypto_address_tag_typeCryptoAddressTagTypeoptionalTag type (memo, destination tag)
crypto_address_tag_valueStringoptionalTag value (memo or destination tag)
crypto_network_fee_preferenceCryptoNetworkFeePreferenceoptional
default medium
Network fee level (low, medium, high). Defaults to medium.
referenceStringoptionalClient reference.
mfa_tokenStringoptionalMFA code, when the account requires one.
fees_includedToggleSwitchoptional
default on
Include fees in withdrawal amount
bank_id_sessionStringoptionalBankID session, when the payment route requires BankID verification.
passkey_responseJSONObjectoptionalPasskey assertion, when the payment route requires passkey verification.
commentStringoptionalFree-text comment stored with the payment.
messageStringoptionalOptional note stored with the withdrawal.
travel_rule_propertiesTravelRulePropertiesArgsoptionalTravel-rule data; used only when travel rule is enabled on the platform.
wallet_idString!optional
default "MAIN"
Source wallet. Defaults to MAIN.
vasp_idStringoptionalBeneficiary VASP; applied only together with travel_rule_properties.

Response

Fields of Payment selected in the operation below.

FieldTypeDescription
payment_idString!Payment/withdrawal ID
currency_idString!Currency.
amountFloat!Amount.
statusPaymentStatus!Withdrawal status
crypto_transaction_idStringOn-chain transaction hash.
crypto_addressStringDestination (withdrawal) or deposit address.
fee_amountFloatFee amount.
created_atString!Creation time.

GraphQL Operation

mutation create_withdrawal_crypto($payment_route_id: String, $amount: Float!, $crypto_address: String!) {
  create_withdrawal_crypto(payment_route_id: $payment_route_id, amount: $amount, crypto_address: $crypto_address) {
    payment_id currency_id amount status crypto_transaction_id crypto_address fee_amount created_at
  }
}

Code Examples

curl -X POST 'https://live-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"mutation create_withdrawal_crypto($payment_route_id: String, $amount: Float!, $crypto_address: String!) { create_withdrawal_crypto(payment_route_id: $payment_route_id, amount: $amount, crypto_address: $crypto_address) { payment_id currency_id amount status crypto_transaction_id crypto_address fee_amount created_at } }","variables":{"payment_route_id":"route123","amount":0.5,"crypto_address":"YOUR_BTC_ADDRESS"}}'
import requests

url = "https://live-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """mutation create_withdrawal_crypto($payment_route_id: String, $amount: Float!, $crypto_address: String!) { create_withdrawal_crypto(payment_route_id: $payment_route_id, amount: $amount, crypto_address: $crypto_address) { payment_id currency_id amount status crypto_transaction_id crypto_address fee_amount created_at } }""",
    "variables": {
        "payment_route_id": "route123",
        "amount": 0.5,
        "crypto_address": "YOUR_BTC_ADDRESS"
    },
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `mutation create_withdrawal_crypto($payment_route_id: String, $amount: Float!, $crypto_address: String!) { create_withdrawal_crypto(payment_route_id: $payment_route_id, amount: $amount, crypto_address: $crypto_address) { payment_id currency_id amount status crypto_transaction_id crypto_address fee_amount created_at } }`,
    variables: {
      "payment_route_id": "route123",
      "amount": 0.5,
      "crypto_address": "YOUR_BTC_ADDRESS"
    },
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this
mutationcreate_withdrawal_fiatInitiate a fiat withdrawal via bank transfer.
Endpoint: POST https://live-api.ouinex.com/graphql
Type: Mutation
Returns: Payment!
Permission: create_withdrawal_fiat
Rate limit: 30 requests / 60 s
Optional header: x-idempotency-key: a repeated key within 5 minutes is rejected with ERR_DUPLICATE_REQUEST.
Signed request: X-Signature + X-Nonce required when the API key has hmac_required: on (see create_api_key).

Inputs

NameTypeRequiredDescription
amountFloat!requiredAmount to withdraw
payment_route_idStringoptionalPayment route to use. If omitted, the route is resolved from currency_id.
currency_idStringoptionalCurrency ID.
mfa_tokenStringoptionalMFA code, when the account requires one.
passkey_responseJSONObjectoptionalPasskey assertion, when the payment route requires passkey verification.
properties[FiatDepositPropertyInput!]!optional
default []
Bank and beneficiary details as { name, value } pairs; which names a route requires depends on the route. Accepted names: fiat_bank_name, fiat_bank_bic, fiat_bank_iban, fiat_beneficiary_name, fiat_beneficiary_email, fiat_beneficiary_account_number, fiat_beneficiary_address_line_1, fiat_beneficiary_address_line_2, fiat_bank_address, fiat_routing_number, fiat_reference, fiat_notes, fiat_transfer_type, fiat_bank_country, fiat_bank_region, fiat_bank_city, fiat_bank_postal_code, fiat_beneficiary_country, fiat_beneficiary_region, fiat_beneficiary_city, fiat_beneficiary_postal_code, fiat_bank_swift, intermediary_bank_name, intermediary_bank_postal_code, intermediary_iban, intermediary_country, intermediary_street_address, intermediary_city, intermediary_region, intermediary_bic.
wallet_idString!optional
default "MAIN"
Source wallet. Defaults to MAIN.
vasp_idStringoptionalBeneficiary VASP.
messageStringoptionalFree-text message stored on the payment.

Response

Fields of Payment selected in the operation below.

FieldTypeDescription
payment_idString!Payment/withdrawal ID
amountFloat!Amount.
statusPaymentStatus!Status.
created_atString!Creation time.

GraphQL Operation

mutation create_withdrawal_fiat($amount: Float!, $payment_route_id: String, $properties: [FiatDepositPropertyInput!]) {
  create_withdrawal_fiat(amount: $amount, payment_route_id: $payment_route_id, properties: $properties) {
    payment_id amount status created_at
  }
}

Code Examples

curl -X POST 'https://live-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"mutation create_withdrawal_fiat($amount: Float!, $payment_route_id: String, $properties: [FiatDepositPropertyInput!]) { create_withdrawal_fiat(amount: $amount, payment_route_id: $payment_route_id, properties: $properties) { payment_id amount status created_at } }","variables":{"amount":1000,"payment_route_id":"route456","properties":[{"name":"fiat_beneficiary_account_number","value":"12345678"}]}}'
import requests

url = "https://live-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """mutation create_withdrawal_fiat($amount: Float!, $payment_route_id: String, $properties: [FiatDepositPropertyInput!]) { create_withdrawal_fiat(amount: $amount, payment_route_id: $payment_route_id, properties: $properties) { payment_id amount status created_at } }""",
    "variables": {
        "amount": 1000,
        "payment_route_id": "route456",
        "properties": [
            {
                "name": "fiat_beneficiary_account_number",
                "value": "12345678"
            }
        ]
    },
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `mutation create_withdrawal_fiat($amount: Float!, $payment_route_id: String, $properties: [FiatDepositPropertyInput!]) { create_withdrawal_fiat(amount: $amount, payment_route_id: $payment_route_id, properties: $properties) { payment_id amount status created_at } }`,
    variables: {
      "amount": 1000,
      "payment_route_id": "route456",
      "properties": [
        {
          "name": "fiat_beneficiary_account_number",
          "value": "12345678"
        }
      ]
    },
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this
querydeposit_address_cryptoGet (or generate, if none exists) a crypto deposit address.
Endpoint: POST https://live-api.ouinex.com/graphql
Type: Query
Returns: DepositAddressCrypto!
Permission: deposit_addresses_crypto
Rate limit: 10 requests / 60 s, min. 3000 ms between calls

Declared as a query, but generates a new address when none exists yet.

Inputs

NameTypeRequiredDescription
currency_idString!requiredCurrency filter.
networkStringoptionalNetwork of the address.
referenceStringoptionalClient reference.
address_typeStringoptionalAddress type.
payment_route_idStringoptionalPayment route ID for the currency

Response

Fields of DepositAddressCrypto selected in the operation below.

FieldTypeDescription
deposit_address_crypto_idString!Deposit address ID.
currency_idString!Currency.
addressStringDeposit wallet address
address_tag_typeCryptoAddressTagTypeTag type (memo, destination tag, etc.)
address_tag_valueStringAddress tag / memo value, for networks that use one.
networkStringBlockchain network
created_atString!Creation time.

GraphQL Operation

query deposit_address_crypto($currency_id: String!, $payment_route_id: String) {
  deposit_address_crypto(currency_id: $currency_id, payment_route_id: $payment_route_id) {
    deposit_address_crypto_id currency_id address address_tag_type address_tag_value network created_at
  }
}

Code Examples

curl -X POST 'https://live-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"query deposit_address_crypto($currency_id: String!, $payment_route_id: String) { deposit_address_crypto(currency_id: $currency_id, payment_route_id: $payment_route_id) { deposit_address_crypto_id currency_id address address_tag_type address_tag_value network created_at } }","variables":{"currency_id":"BTC","payment_route_id":"route123"}}'
import requests

url = "https://live-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """query deposit_address_crypto($currency_id: String!, $payment_route_id: String) { deposit_address_crypto(currency_id: $currency_id, payment_route_id: $payment_route_id) { deposit_address_crypto_id currency_id address address_tag_type address_tag_value network created_at } }""",
    "variables": {
        "currency_id": "BTC",
        "payment_route_id": "route123"
    },
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `query deposit_address_crypto($currency_id: String!, $payment_route_id: String) { deposit_address_crypto(currency_id: $currency_id, payment_route_id: $payment_route_id) { deposit_address_crypto_id currency_id address address_tag_type address_tag_value network created_at } }`,
    variables: {
      "currency_id": "BTC",
      "payment_route_id": "route123"
    },
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this

Orders & Trades

Place and manage spot orders, browse instruments, and preview order cost before placement.

mutationcreate_orderPlace a spot order (market, limit, stop).
Endpoint: POST https://live-api.ouinex.com/graphql
Type: Mutation
Returns: Order!
Permission: create_order
Rate limit: 600 requests / 60 s, min. 100 ms between calls
Optional header: x-idempotency-key: a repeated key within 5 minutes is rejected with ERR_DUPLICATE_REQUEST.
Signed request: X-Signature + X-Nonce required when the API key has hmac_required: on (see create_api_key).

Inputs

NameTypeRequiredDescription
wallet_idString!optional
default "MAIN"
Wallet to trade from. Defaults to MAIN.
client_order_idStringoptionalClient-supplied order identifier.
instrument_idString!requiredInstrument ID.
quantityFloat!requiredOrder quantity in base currency
quantity_modeOrderQuantityModeoptional
default base
base (default) or quote; quote is allowed only with fok / ioc.
typeOrderType!requiredmarket, limit, stop_market or stop_limit.
sideOrderSide!requiredOrder side: buy or sell
time_in_forceOrderTimeInForce!requiredRequired. market: fok or ioc. limit / stop_market / stop_limit: any value; gtd requires expires_at.
priceFloatoptionalOrder price (limit / stop_limit orders).
expires_atStringoptionalISO date-time; required when time_in_force is gtd (at least 5 s in the future), ignored otherwise.
notesStringoptionalFree-text note. Cannot be combined with post_only.
stop_priceFloatoptionalRequired and positive for stop_limit / stop_market.
post_onlyToggleSwitchoptionalApplies to limit orders only.
take_profitConditionalOrderLegInputoptionalTake-profit leg attached to this order, armed once the order fills. Fields: trigger_price, execution_type (market / limit), limit_price (limit), price_reference (orderbook / last_trade), slippage_bps (market, 100 = 1%), time_in_force (limit). See ConditionalOrderLegInput.
stop_lossConditionalOrderLegInputoptionalStop-loss leg attached to this order, armed once the order fills. Fields: trigger_price, execution_type (market / limit), limit_price (limit), price_reference (orderbook / last_trade), slippage_bps (market, 100 = 1%), time_in_force (limit). See ConditionalOrderLegInput.

Response

Fields of Order selected in the operation below.

FieldTypeDescription
order_idString!Unique order ID
typeOrderType!Type.
sideOrderSide!Side (buy / sell).
statusOrderStatus!Order status.
priceFloatPrice.
stop_priceFloatTrigger price for stop orders.
quantityFloat!Quantity.
executed_quantityFloat!Executed quantity.
remaining_quantityFloat!Quantity not yet executed.
quantity_modeOrderQuantityMode!base or quote: which currency quantity is expressed in.
instrument_idString!Instrument.
messageStringStatus / rejection message.
updated_atString!Last update time.
created_atString!Order creation timestamp
expires_atStringExpiry time.
expires_at_isoStringExpiry time (ISO 8601).
time_in_forceOrderTimeInForce!Time in force.
vwapFloatVolume-weighted average execution price.
wallet_idStringWallet.
instrumentInstrumentInstrument details.
fees[AccountTransaction!]!Fees charged on the order.

GraphQL Operation

mutation create_order($wallet_id: String, $instrument_id: String!, $quantity: Float!, $type: OrderType!, $side: OrderSide!, $time_in_force: OrderTimeInForce!, $price: Float) {
  create_order(wallet_id: $wallet_id, instrument_id: $instrument_id, quantity: $quantity, type: $type, side: $side, time_in_force: $time_in_force, price: $price) {
    order_id type side status price stop_price quantity executed_quantity remaining_quantity quantity_mode instrument_id message updated_at created_at expires_at expires_at_iso time_in_force vwap wallet_id
    instrument {
      quote_currency_id name base_currency_id quantity_decimals quote_quantity_decimals price_decimals
    }
    fees { currency_id amount type }
  }
}

Code Examples

curl -X POST 'https://live-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"mutation create_order($wallet_id: String, $instrument_id: String!, $quantity: Float!, $type: OrderType!, $side: OrderSide!, $time_in_force: OrderTimeInForce!, $price: Float) { create_order(wallet_id: $wallet_id, instrument_id: $instrument_id, quantity: $quantity, type: $type, side: $side, time_in_force: $time_in_force, price: $price) { order_id type side status price stop_price quantity executed_quantity remaining_quantity quantity_mode instrument_id message updated_at created_at expires_at expires_at_iso time_in_force vwap wallet_id instrument { quote_currency_id name base_currency_id quantity_decimals quote_quantity_decimals price_decimals } fees { currency_id amount type } } }","variables":{"wallet_id":"MAIN","instrument_id":"BTCUSDT","quantity":0.01,"type":"limit","side":"buy","time_in_force":"gtc","price":65000}}'
import requests

url = "https://live-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """mutation create_order($wallet_id: String, $instrument_id: String!, $quantity: Float!, $type: OrderType!, $side: OrderSide!, $time_in_force: OrderTimeInForce!, $price: Float) { create_order(wallet_id: $wallet_id, instrument_id: $instrument_id, quantity: $quantity, type: $type, side: $side, time_in_force: $time_in_force, price: $price) { order_id type side status price stop_price quantity executed_quantity remaining_quantity quantity_mode instrument_id message updated_at created_at expires_at expires_at_iso time_in_force vwap wallet_id instrument { quote_currency_id name base_currency_id quantity_decimals quote_quantity_decimals price_decimals } fees { currency_id amount type } } }""",
    "variables": {
        "wallet_id": "MAIN",
        "instrument_id": "BTCUSDT",
        "quantity": 0.01,
        "type": "limit",
        "side": "buy",
        "time_in_force": "gtc",
        "price": 65000
    },
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `mutation create_order($wallet_id: String, $instrument_id: String!, $quantity: Float!, $type: OrderType!, $side: OrderSide!, $time_in_force: OrderTimeInForce!, $price: Float) { create_order(wallet_id: $wallet_id, instrument_id: $instrument_id, quantity: $quantity, type: $type, side: $side, time_in_force: $time_in_force, price: $price) { order_id type side status price stop_price quantity executed_quantity remaining_quantity quantity_mode instrument_id message updated_at created_at expires_at expires_at_iso time_in_force vwap wallet_id instrument { quote_currency_id name base_currency_id quantity_decimals quote_quantity_decimals price_decimals } fees { currency_id amount type } } }`,
    variables: {
      "wallet_id": "MAIN",
      "instrument_id": "BTCUSDT",
      "quantity": 0.01,
      "type": "limit",
      "side": "buy",
      "time_in_force": "gtc",
      "price": 65000
    },
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this
mutationcancel_orderCancel a single open spot order.
Endpoint: POST https://live-api.ouinex.com/graphql
Type: Mutation
Returns: Boolean!
Permission: cancel_order
Rate limit: 600 requests / 60 s, min. 100 ms between calls

Inputs

NameTypeRequiredDescription
order_idString!requiredOrder ID to cancel
messageStringoptionalOptional cancellation note (1-255 characters).

GraphQL Operation

mutation cancel_order($order_id: String!) {
  cancel_order(order_id: $order_id)
}

Code Examples

curl -X POST 'https://live-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"mutation cancel_order($order_id: String!) { cancel_order(order_id: $order_id) }","variables":{"order_id":"order456"}}'
import requests

url = "https://live-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """mutation cancel_order($order_id: String!) { cancel_order(order_id: $order_id) }""",
    "variables": {
        "order_id": "order456"
    },
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `mutation cancel_order($order_id: String!) { cancel_order(order_id: $order_id) }`,
    variables: {
      "order_id": "order456"
    },
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this
mutationupdate_open_orderAmend an open spot order's quantity, price, stop price or expiry.
Endpoint: POST https://live-api.ouinex.com/graphql
Type: Mutation
Returns: Order!
Permission: create_order

Inputs

NameTypeRequiredDescription
order_idString!requiredOrder to amend.
quantityFloat!requiredNew quantity (required, restate it if unchanged).
priceFloatoptionalNew limit price.
stop_priceFloatoptionalNew stop price.
expires_atStringoptionalNew expiry for gtd orders.

Response

Fields of Order selected in the operation below.

FieldTypeDescription
order_idString!
statusOrderStatus!
priceFloat
stop_priceFloat
quantityFloat!
expires_atString

GraphQL Operation

mutation update_open_order($order_id: String!, $quantity: Float!, $price: Float) {
  update_open_order(order_id: $order_id, quantity: $quantity, price: $price) { order_id status price stop_price quantity expires_at }
}

Code Examples

curl -X POST 'https://live-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"mutation update_open_order($order_id: String!, $quantity: Float!, $price: Float) { update_open_order(order_id: $order_id, quantity: $quantity, price: $price) { order_id status price stop_price quantity expires_at } }","variables":{"order_id":"order123","quantity":0.5,"price":61000}}'
import requests

url = "https://live-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """mutation update_open_order($order_id: String!, $quantity: Float!, $price: Float) { update_open_order(order_id: $order_id, quantity: $quantity, price: $price) { order_id status price stop_price quantity expires_at } }""",
    "variables": {
        "order_id": "order123",
        "quantity": 0.5,
        "price": 61000
    },
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `mutation update_open_order($order_id: String!, $quantity: Float!, $price: Float) { update_open_order(order_id: $order_id, quantity: $quantity, price: $price) { order_id status price stop_price quantity expires_at } }`,
    variables: {
      "order_id": "order123",
      "quantity": 0.5,
      "price": 61000
    },
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this
mutationcancel_multiple_ordersCancel several open spot orders in one call.
Endpoint: POST https://live-api.ouinex.com/graphql
Type: Mutation
Returns: Boolean!
Permission: cancel_order

Inputs

NameTypeRequiredDescription
order_ids[String!]!requiredOrders to cancel.
messageStringoptionalOptional cancellation note.

GraphQL Operation

mutation cancel_multiple_orders($order_ids: [String!]!) {
  cancel_multiple_orders(order_ids: $order_ids)
}

Code Examples

curl -X POST 'https://live-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"mutation cancel_multiple_orders($order_ids: [String!]!) { cancel_multiple_orders(order_ids: $order_ids) }","variables":{"order_ids":["order123","order456"]}}'
import requests

url = "https://live-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """mutation cancel_multiple_orders($order_ids: [String!]!) { cancel_multiple_orders(order_ids: $order_ids) }""",
    "variables": {
        "order_ids": [
            "order123",
            "order456"
        ]
    },
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `mutation cancel_multiple_orders($order_ids: [String!]!) { cancel_multiple_orders(order_ids: $order_ids) }`,
    variables: {
      "order_ids": [
        "order123",
        "order456"
      ]
    },
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this
mutationcancel_all_ordersCancel all of the user's open spot orders.
Endpoint: POST https://live-api.ouinex.com/graphql
Type: Mutation
Returns: Boolean!
Permission: cancel_order

Inputs

NameTypeRequiredDescription
wallet_idStringoptionalOnly cancel orders in this wallet.

GraphQL Operation

mutation cancel_all_orders($wallet_id: String) {
  cancel_all_orders(wallet_id: $wallet_id)
}

Code Examples

curl -X POST 'https://live-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"mutation cancel_all_orders($wallet_id: String) { cancel_all_orders(wallet_id: $wallet_id) }","variables":{"wallet_id":"MAIN"}}'
import requests

url = "https://live-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """mutation cancel_all_orders($wallet_id: String) { cancel_all_orders(wallet_id: $wallet_id) }""",
    "variables": {
        "wallet_id": "MAIN"
    },
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `mutation cancel_all_orders($wallet_id: String) { cancel_all_orders(wallet_id: $wallet_id) }`,
    variables: {
      "wallet_id": "MAIN"
    },
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this
mutationcreate_conditional_orderPlace a standalone spot take-profit, stop-loss or OCO (both legs) on a quantity you hold.
Endpoint: POST https://live-api.ouinex.com/graphql
Type: Mutation
Returns: ConditionalOrder!

Give take_profit, stop_loss or both (OCO: the first leg to execute cancels the other). The quantity is reserved from your balance until the condition completes or is cancelled. Limits per instrument (slippage range, execution types, max open conditions) come from conditional_order_policy.

Inputs

NameTypeRequiredDescription
wallet_idString!optional
default "MAIN"
Wallet to act on; defaults to MAIN.
client_conditional_order_idStringoptionalYour own id for this condition.
instrument_idString!requiredSpot instrument.
sideOrderSide!requiredOrder side.
quantityFloat!requiredQuantity to protect.
quantity_modeOrderQuantityMode!optional
default base
Whether quantity is in base or quote currency.
take_profitConditionalOrderLegInputoptionalTake-profit leg. Fields: trigger_price, execution_type (market / limit), limit_price (limit), price_reference (orderbook / last_trade), slippage_bps (market, 100 = 1%), time_in_force (limit). See ConditionalOrderLegInput.
stop_lossConditionalOrderLegInputoptionalStop-loss leg. Fields: trigger_price, execution_type (market / limit), limit_price (limit), price_reference (orderbook / last_trade), slippage_bps (market, 100 = 1%), time_in_force (limit). See ConditionalOrderLegInput.
expires_atDateTimeoptionalOptional expiry (ISO 8601).

Response

Fields of ConditionalOrder selected in the operation below.

FieldTypeDescription
serial_idIntInternal monotonically increasing database identifier.
conditional_order_idString!Globally unique conditional-order identifier.
client_conditional_order_idStringOptional ID supplied by the client for reconciliation.
wallet_idString!Wallet that owns the collateral reservation.
instrument_idString!Instrument monitored by the trigger engine.
entry_order_idStringOrdinary entry order that activates this condition as it fills.
attachment_typeConditionalOrderAttachmentType!Whether this condition is standalone or attached to an entry order.
typeConditionalOrderType!Derived shape: Take Profit, Stop Loss, or OCO.
sideOrderSide!Side of each spot child order created by a triggered leg.
quantity_modeOrderQuantityMode!Unit used by the quantity fields.
requested_quantityFloat!Total quantity originally requested by the client.
activated_quantityFloat!Entry-order quantity currently activated for protection; equals requested_quantity for standalone orders.
executed_quantityFloat!Cumulative quantity executed by conditional child orders.
remaining_quantityFloat!Activated quantity that still requires protection or execution.
statusConditionalOrderStatus!Current parent lifecycle status.
status_reasonStringMachine-readable or diagnostic reason for the current status.
expires_atDateTimeExpiry passed to a future GTD limit child order.
created_atDateTime!Time at which the conditional order was created.
updated_atDateTime!Time of the latest persisted state change.

GraphQL Operation

mutation create_conditional_order($instrument_id: String!, $side: OrderSide!, $quantity: Float!, $take_profit: ConditionalOrderLegInput, $stop_loss: ConditionalOrderLegInput) {
  create_conditional_order(instrument_id: $instrument_id, side: $side, quantity: $quantity, take_profit: $take_profit, stop_loss: $stop_loss) { serial_id conditional_order_id client_conditional_order_id wallet_id instrument_id entry_order_id attachment_type type side quantity_mode requested_quantity activated_quantity executed_quantity remaining_quantity status status_reason expires_at created_at updated_at }
}

Code Examples

curl -X POST 'https://live-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"mutation create_conditional_order($instrument_id: String!, $side: OrderSide!, $quantity: Float!, $take_profit: ConditionalOrderLegInput, $stop_loss: ConditionalOrderLegInput) { create_conditional_order(instrument_id: $instrument_id, side: $side, quantity: $quantity, take_profit: $take_profit, stop_loss: $stop_loss) { serial_id conditional_order_id client_conditional_order_id wallet_id instrument_id entry_order_id attachment_type type side quantity_mode requested_quantity activated_quantity executed_quantity remaining_quantity status status_reason expires_at created_at updated_at } }","variables":{"instrument_id":"BTCUSDT","side":"sell","quantity":0.1,"take_profit":{"trigger_price":68000},"stop_loss":{"trigger_price":58000}}}'
import requests

url = "https://live-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """mutation create_conditional_order($instrument_id: String!, $side: OrderSide!, $quantity: Float!, $take_profit: ConditionalOrderLegInput, $stop_loss: ConditionalOrderLegInput) { create_conditional_order(instrument_id: $instrument_id, side: $side, quantity: $quantity, take_profit: $take_profit, stop_loss: $stop_loss) { serial_id conditional_order_id client_conditional_order_id wallet_id instrument_id entry_order_id attachment_type type side quantity_mode requested_quantity activated_quantity executed_quantity remaining_quantity status status_reason expires_at created_at updated_at } }""",
    "variables": {
        "instrument_id": "BTCUSDT",
        "side": "sell",
        "quantity": 0.1,
        "take_profit": {
            "trigger_price": 68000
        },
        "stop_loss": {
            "trigger_price": 58000
        }
    },
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `mutation create_conditional_order($instrument_id: String!, $side: OrderSide!, $quantity: Float!, $take_profit: ConditionalOrderLegInput, $stop_loss: ConditionalOrderLegInput) { create_conditional_order(instrument_id: $instrument_id, side: $side, quantity: $quantity, take_profit: $take_profit, stop_loss: $stop_loss) { serial_id conditional_order_id client_conditional_order_id wallet_id instrument_id entry_order_id attachment_type type side quantity_mode requested_quantity activated_quantity executed_quantity remaining_quantity status status_reason expires_at created_at updated_at } }`,
    variables: {
      "instrument_id": "BTCUSDT",
      "side": "sell",
      "quantity": 0.1,
      "take_profit": {
        "trigger_price": 68000
      },
      "stop_loss": {
        "trigger_price": 58000
      }
    },
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this
mutationcancel_conditional_orderCancel an untriggered conditional order and release its reserved quantity.
Endpoint: POST https://live-api.ouinex.com/graphql
Type: Mutation
Returns: ConditionalOrder!

Inputs

NameTypeRequiredDescription
conditional_order_idString!requiredConditional order.

Response

Fields of ConditionalOrder selected in the operation below.

FieldTypeDescription
serial_idIntInternal monotonically increasing database identifier.
conditional_order_idString!Globally unique conditional-order identifier.
client_conditional_order_idStringOptional ID supplied by the client for reconciliation.
wallet_idString!Wallet that owns the collateral reservation.
instrument_idString!Instrument monitored by the trigger engine.
entry_order_idStringOrdinary entry order that activates this condition as it fills.
attachment_typeConditionalOrderAttachmentType!Whether this condition is standalone or attached to an entry order.
typeConditionalOrderType!Derived shape: Take Profit, Stop Loss, or OCO.
sideOrderSide!Side of each spot child order created by a triggered leg.
quantity_modeOrderQuantityMode!Unit used by the quantity fields.
requested_quantityFloat!Total quantity originally requested by the client.
activated_quantityFloat!Entry-order quantity currently activated for protection; equals requested_quantity for standalone orders.
executed_quantityFloat!Cumulative quantity executed by conditional child orders.
remaining_quantityFloat!Activated quantity that still requires protection or execution.
statusConditionalOrderStatus!Current parent lifecycle status.
status_reasonStringMachine-readable or diagnostic reason for the current status.
expires_atDateTimeExpiry passed to a future GTD limit child order.
created_atDateTime!Time at which the conditional order was created.
updated_atDateTime!Time of the latest persisted state change.

GraphQL Operation

mutation cancel_conditional_order($conditional_order_id: String!) {
  cancel_conditional_order(conditional_order_id: $conditional_order_id) { serial_id conditional_order_id client_conditional_order_id wallet_id instrument_id entry_order_id attachment_type type side quantity_mode requested_quantity activated_quantity executed_quantity remaining_quantity status status_reason expires_at created_at updated_at }
}

Code Examples

curl -X POST 'https://live-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"mutation cancel_conditional_order($conditional_order_id: String!) { cancel_conditional_order(conditional_order_id: $conditional_order_id) { serial_id conditional_order_id client_conditional_order_id wallet_id instrument_id entry_order_id attachment_type type side quantity_mode requested_quantity activated_quantity executed_quantity remaining_quantity status status_reason expires_at created_at updated_at } }","variables":{"conditional_order_id":"cond123"}}'
import requests

url = "https://live-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """mutation cancel_conditional_order($conditional_order_id: String!) { cancel_conditional_order(conditional_order_id: $conditional_order_id) { serial_id conditional_order_id client_conditional_order_id wallet_id instrument_id entry_order_id attachment_type type side quantity_mode requested_quantity activated_quantity executed_quantity remaining_quantity status status_reason expires_at created_at updated_at } }""",
    "variables": {
        "conditional_order_id": "cond123"
    },
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `mutation cancel_conditional_order($conditional_order_id: String!) { cancel_conditional_order(conditional_order_id: $conditional_order_id) { serial_id conditional_order_id client_conditional_order_id wallet_id instrument_id entry_order_id attachment_type type side quantity_mode requested_quantity activated_quantity executed_quantity remaining_quantity status status_reason expires_at created_at updated_at } }`,
    variables: {
      "conditional_order_id": "cond123"
    },
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this
queryconditional_ordersList the user's spot conditional orders.
Endpoint: POST https://live-api.ouinex.com/graphql
Type: Query
Returns: [ConditionalOrder!]!

Inputs

NameTypeRequiredDescription
instrument_idStringoptionalInstrument filter.
wallet_idStringoptionalWallet filter.
status[ConditionalOrderStatus!]optionalStatus filter (several allowed).
pagerPagerInputoptional
default {limit: 30, offset: 0}
Pagination (limit, offset).

Response

Fields of ConditionalOrder selected in the operation below.

FieldTypeDescription
serial_idIntInternal monotonically increasing database identifier.
conditional_order_idString!Globally unique conditional-order identifier.
client_conditional_order_idStringOptional ID supplied by the client for reconciliation.
wallet_idString!Wallet that owns the collateral reservation.
instrument_idString!Instrument monitored by the trigger engine.
entry_order_idStringOrdinary entry order that activates this condition as it fills.
attachment_typeConditionalOrderAttachmentType!Whether this condition is standalone or attached to an entry order.
typeConditionalOrderType!Derived shape: Take Profit, Stop Loss, or OCO.
sideOrderSide!Side of each spot child order created by a triggered leg.
quantity_modeOrderQuantityMode!Unit used by the quantity fields.
requested_quantityFloat!Total quantity originally requested by the client.
activated_quantityFloat!Entry-order quantity currently activated for protection; equals requested_quantity for standalone orders.
executed_quantityFloat!Cumulative quantity executed by conditional child orders.
remaining_quantityFloat!Activated quantity that still requires protection or execution.
statusConditionalOrderStatus!Current parent lifecycle status.
status_reasonStringMachine-readable or diagnostic reason for the current status.
expires_atDateTimeExpiry passed to a future GTD limit child order.
created_atDateTime!Time at which the conditional order was created.
updated_atDateTime!Time of the latest persisted state change.

GraphQL Operation

query conditional_orders {
  conditional_orders { serial_id conditional_order_id client_conditional_order_id wallet_id instrument_id entry_order_id attachment_type type side quantity_mode requested_quantity activated_quantity executed_quantity remaining_quantity status status_reason expires_at created_at updated_at }
}

Code Examples

curl -X POST 'https://live-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"query conditional_orders { conditional_orders { serial_id conditional_order_id client_conditional_order_id wallet_id instrument_id entry_order_id attachment_type type side quantity_mode requested_quantity activated_quantity executed_quantity remaining_quantity status status_reason expires_at created_at updated_at } }","variables":{}}'
import requests

url = "https://live-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """query conditional_orders { conditional_orders { serial_id conditional_order_id client_conditional_order_id wallet_id instrument_id entry_order_id attachment_type type side quantity_mode requested_quantity activated_quantity executed_quantity remaining_quantity status status_reason expires_at created_at updated_at } }""",
    "variables": {},
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `query conditional_orders { conditional_orders { serial_id conditional_order_id client_conditional_order_id wallet_id instrument_id entry_order_id attachment_type type side quantity_mode requested_quantity activated_quantity executed_quantity remaining_quantity status status_reason expires_at created_at updated_at } }`,
    variables: {},
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this
queryconditional_order_policyConditional-order rules for an instrument: enabled, execution types, slippage range, max open conditions.
Endpoint: POST https://live-api.ouinex.com/graphql
Type: Query
Returns: ConditionalOrderPolicy

Inputs

NameTypeRequiredDescription
instrument_idString!requiredSpot instrument.

Response

Fields of ConditionalOrderPolicy selected in the operation below.

FieldTypeDescription
enabledToggleSwitch!
allow_market_executionToggleSwitch!
allow_limit_executionToggleSwitch!
default_price_referenceConditionalOrderPriceReference!
default_slippage_bpsInt!
min_slippage_bpsInt!
max_slippage_bpsInt!
max_open_orders_per_userInt!
trigger_confirmation_msInt!

GraphQL Operation

query conditional_order_policy($instrument_id: String!) {
  conditional_order_policy(instrument_id: $instrument_id) { enabled allow_market_execution allow_limit_execution default_price_reference default_slippage_bps min_slippage_bps max_slippage_bps max_open_orders_per_user trigger_confirmation_ms }
}

Code Examples

curl -X POST 'https://live-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"query conditional_order_policy($instrument_id: String!) { conditional_order_policy(instrument_id: $instrument_id) { enabled allow_market_execution allow_limit_execution default_price_reference default_slippage_bps min_slippage_bps max_slippage_bps max_open_orders_per_user trigger_confirmation_ms } }","variables":{"instrument_id":"BTCUSDT"}}'
import requests

url = "https://live-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """query conditional_order_policy($instrument_id: String!) { conditional_order_policy(instrument_id: $instrument_id) { enabled allow_market_execution allow_limit_execution default_price_reference default_slippage_bps min_slippage_bps max_slippage_bps max_open_orders_per_user trigger_confirmation_ms } }""",
    "variables": {
        "instrument_id": "BTCUSDT"
    },
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `query conditional_order_policy($instrument_id: String!) { conditional_order_policy(instrument_id: $instrument_id) { enabled allow_market_execution allow_limit_execution default_price_reference default_slippage_bps min_slippage_bps max_slippage_bps max_open_orders_per_user trigger_confirmation_ms } }`,
    variables: {
      "instrument_id": "BTCUSDT"
    },
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this
queryopen_ordersList currently open spot orders.
Endpoint: POST https://live-api.ouinex.com/graphql
Type: Query
Returns: [Order!]!
Permission: open_orders
Rate limit: 120 requests / 60 s

Inputs

NameTypeRequiredDescription
order_idStringoptionalFilter by order_id.
client_order_idStringoptionalFilter by client_order_id.
time_in_forceOrderTimeInForceoptionalFilter by time_in_force.
typeOrderTypeoptionalFilter by type.
sideOrderSideoptionalFilter by side (buy or sell)
instrument_idStringoptionalInstrument filter.
messageStringoptionalPrefix match on the order message.
parent_order_idStringoptionalFilter by parent_order_id.
searchStringoptionalSearch term.
status[OrderStatus!]optionalFilter by order statuses
pagerPagerInputoptional
default {limit: 30, offset: 0}
Pagination (limit, offset).
sortSortInputoptional
default {direction: DESC}
Sort order.
dateRangeDateRangeInputoptionalFilter by creation date (time_from, time_to).
serialIdRangeSerialIdRangeInputoptional
default {}
Filter by serial ID range.
wallet_idStringoptionalWallet filter.
currency_idStringoptionalCurrency filter.

Response

Fields of Order selected in the operation below.

FieldTypeDescription
order_idString!Order ID
typeOrderType!Type.
sideOrderSide!Side (buy / sell).
statusOrderStatus!Current order status
priceFloatPrice.
stop_priceFloatTrigger price for stop orders.
quantityFloat!Quantity.
executed_quantityFloat!Executed quantity.
remaining_quantityFloat!Quantity not yet executed.
instrument_idString!Instrument.
created_atString!Creation time.
updated_atString!Last update time.
time_in_forceOrderTimeInForce!Time in force.
wallet_idStringWallet.

GraphQL Operation

query open_orders($wallet_id: String) {
  open_orders(wallet_id: $wallet_id) {
    order_id type side status price stop_price quantity executed_quantity remaining_quantity instrument_id created_at updated_at time_in_force wallet_id
  }
}

Code Examples

curl -X POST 'https://live-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"query open_orders($wallet_id: String) { open_orders(wallet_id: $wallet_id) { order_id type side status price stop_price quantity executed_quantity remaining_quantity instrument_id created_at updated_at time_in_force wallet_id } }","variables":{"wallet_id":"wallet123"}}'
import requests

url = "https://live-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """query open_orders($wallet_id: String) { open_orders(wallet_id: $wallet_id) { order_id type side status price stop_price quantity executed_quantity remaining_quantity instrument_id created_at updated_at time_in_force wallet_id } }""",
    "variables": {
        "wallet_id": "wallet123"
    },
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `query open_orders($wallet_id: String) { open_orders(wallet_id: $wallet_id) { order_id type side status price stop_price quantity executed_quantity remaining_quantity instrument_id created_at updated_at time_in_force wallet_id } }`,
    variables: {
      "wallet_id": "wallet123"
    },
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this
queryclosed_ordersList completed / cancelled / rejected / expired spot orders.
Endpoint: POST https://live-api.ouinex.com/graphql
Type: Query
Returns: [Order!]!
Permission: closed_orders
Rate limit: 60 requests / 60 s

Inputs

NameTypeRequiredDescription
order_idStringoptionalFilter by order_id.
client_order_idStringoptionalFilter by client_order_id.
time_in_forceOrderTimeInForceoptionalFilter by time_in_force.
typeOrderTypeoptionalFilter by type.
sideOrderSideoptionalFilter by side (buy or sell)
instrument_idStringoptionalInstrument filter.
messageStringoptionalPrefix match on the order message.
parent_order_idStringoptionalFilter by parent_order_id.
searchStringoptionalSearch term.
status[OrderStatus!]optionalFilter by order statuses
pagerPagerInputoptional
default {limit: 30, offset: 0}
Pagination (limit, offset).
sortSortInputoptional
default {direction: DESC}
Sort order.
dateRangeDateRangeInputoptionalDate-time window (time_from, time_to). When omitted the server applies a default window (14 days back from now in the default platform settings); a range wider than the configured maximum (1 year for user-scoped queries by default) is rejected. Pass it explicitly to read older history.
serialIdRangeSerialIdRangeInputoptional
default {}
Filter by serial ID range.
wallet_idStringoptionalWallet filter.
currency_idStringoptionalCurrency filter.

Response

Fields of Order selected in the operation below.

FieldTypeDescription
order_idString!Order ID
typeOrderType!Type.
sideOrderSide!Side (buy / sell).
statusOrderStatus!Final order status
priceFloatPrice.
quantityFloat!Quantity.
executed_quantityFloat!Executed quantity.
instrument_idString!Instrument.
created_atString!Creation time.
updated_atString!Last update time.
totalFloatGet total for closed order

GraphQL Operation

query closed_orders($wallet_id: String) {
  closed_orders(wallet_id: $wallet_id) {
    order_id type side status price quantity executed_quantity instrument_id created_at updated_at total
  }
}

Code Examples

curl -X POST 'https://live-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"query closed_orders($wallet_id: String) { closed_orders(wallet_id: $wallet_id) { order_id type side status price quantity executed_quantity instrument_id created_at updated_at total } }","variables":{"wallet_id":"wallet123"}}'
import requests

url = "https://live-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """query closed_orders($wallet_id: String) { closed_orders(wallet_id: $wallet_id) { order_id type side status price quantity executed_quantity instrument_id created_at updated_at total } }""",
    "variables": {
        "wallet_id": "wallet123"
    },
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `query closed_orders($wallet_id: String) { closed_orders(wallet_id: $wallet_id) { order_id type side status price quantity executed_quantity instrument_id created_at updated_at total } }`,
    variables: {
      "wallet_id": "wallet123"
    },
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this
querytradesList the user's spot trades (executions).
Endpoint: POST https://live-api.ouinex.com/graphql
Type: Query
Returns: [Trade!]!
Permission: trades

Without dateRange only a short recent window is returned, with no error; pass dateRange: { time_from, time_to } (YYYY-MM-DD HH:mm:ss, at most 1 year per request) to read older history.

Inputs

NameTypeRequiredDescription
trade_idStringoptionalTrade filter.
instrument_idStringoptionalInstrument filter.
order_idStringoptionalOnly trades of this order.
sideOrderSideoptionalSide filter.
searchStringoptionalSearch term.
pagerPagerInputoptional
default {limit: 30, offset: 0}
Pagination (limit, offset).
sortSortInputoptional
default {direction: DESC}
Sort order.
dateRangeDateRangeInputoptional
default {}
Date range; see the note above.
serialIdRangeSerialIdRangeInputoptional
default {}
Serial id range.
wallet_idStringoptionalWallet filter.

Response

Fields of Trade selected in the operation below.

FieldTypeDescription
trade_idString!
order_idString!
instrument_idString!
sideOrderSide
quantityFloat!
priceFloat!
created_at_isoString!
wallet_idString

GraphQL Operation

query trades($dateRange: DateRangeInput, $wallet_id: String) {
  trades(dateRange: $dateRange, wallet_id: $wallet_id) { trade_id order_id instrument_id side quantity price created_at_iso wallet_id }
}

Code Examples

curl -X POST 'https://live-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"query trades($dateRange: DateRangeInput, $wallet_id: String) { trades(dateRange: $dateRange, wallet_id: $wallet_id) { trade_id order_id instrument_id side quantity price created_at_iso wallet_id } }","variables":{"wallet_id":"MAIN","dateRange":{"time_from":"2026-09-01 00:00:00","time_to":"2026-10-01 00:00:00"}}}'
import requests

url = "https://live-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """query trades($dateRange: DateRangeInput, $wallet_id: String) { trades(dateRange: $dateRange, wallet_id: $wallet_id) { trade_id order_id instrument_id side quantity price created_at_iso wallet_id } }""",
    "variables": {
        "wallet_id": "MAIN",
        "dateRange": {
            "time_from": "2026-09-01 00:00:00",
            "time_to": "2026-10-01 00:00:00"
        }
    },
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `query trades($dateRange: DateRangeInput, $wallet_id: String) { trades(dateRange: $dateRange, wallet_id: $wallet_id) { trade_id order_id instrument_id side quantity price created_at_iso wallet_id } }`,
    variables: {
      "wallet_id": "MAIN",
      "dateRange": {
        "time_from": "2026-09-01 00:00:00",
        "time_to": "2026-10-01 00:00:00"
      }
    },
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this
queryestimate_orderPreview price, quantity and fees before placing an order.
Endpoint: POST https://live-api.ouinex.com/graphql
Type: Query
Returns: EstimateOrderResult!
Permission: estimate_order

Inputs

NameTypeRequiredDescription
source_currency_idString!requiredSource currency ID (the one being spent)
source_currency_amountFloatoptionalAmount in source currency
target_currency_idString!requiredTarget currency ID (the one being received)
target_currency_amountFloatoptionalAmount in target currency
priceFloatoptionalExpected price
instrument_idStringoptionalInstrument filter.

Response

Fields of EstimateOrderResult selected in the operation below.

FieldTypeDescription
typeOrderType!Estimated order type
priceFloat!Estimated price
quantityFloat!Quantity.
sideOrderSide!Side (buy / sell).
quantity_modeOrderQuantityMode!base or quote: which currency quantity is expressed in.
fees[EstimateOrderFee!]!Fee breakdown by currency

GraphQL Operation

query estimate_order($source_currency_id: String!, $source_currency_amount: Float, $target_currency_id: String!) {
  estimate_order(source_currency_id: $source_currency_id, source_currency_amount: $source_currency_amount, target_currency_id: $target_currency_id) {
    type price quantity side quantity_mode
    fees { currency_id amount }
  }
}

Code Examples

curl -X POST 'https://live-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"query estimate_order($source_currency_id: String!, $source_currency_amount: Float, $target_currency_id: String!) { estimate_order(source_currency_id: $source_currency_id, source_currency_amount: $source_currency_amount, target_currency_id: $target_currency_id) { type price quantity side quantity_mode fees { currency_id amount } } }","variables":{"source_currency_id":"BTC","source_currency_amount":0.01,"target_currency_id":"USDT"}}'
import requests

url = "https://live-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """query estimate_order($source_currency_id: String!, $source_currency_amount: Float, $target_currency_id: String!) { estimate_order(source_currency_id: $source_currency_id, source_currency_amount: $source_currency_amount, target_currency_id: $target_currency_id) { type price quantity side quantity_mode fees { currency_id amount } } }""",
    "variables": {
        "source_currency_id": "BTC",
        "source_currency_amount": 0.01,
        "target_currency_id": "USDT"
    },
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `query estimate_order($source_currency_id: String!, $source_currency_amount: Float, $target_currency_id: String!) { estimate_order(source_currency_id: $source_currency_id, source_currency_amount: $source_currency_amount, target_currency_id: $target_currency_id) { type price quantity side quantity_mode fees { currency_id amount } } }`,
    variables: {
      "source_currency_id": "BTC",
      "source_currency_amount": 0.01,
      "target_currency_id": "USDT"
    },
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this
queryinstrumentsList trading pairs with metadata and current prices.
Endpoint: POST https://live-api.ouinex.com/graphql
Type: Query
Returns: [Instrument!]!
Rate limit: 120 requests / 60 s

Authentication is optional.

Inputs

NameTypeRequiredDescription
instrument_idStringoptionalReturn a single instrument.
is_activeToggleSwitchoptionalFilter by active status
searchStringoptionalSearch term.
pageIntoptionalPage number (1-based).
limitInt!optional
default 100
Page size (default 100).
sortSortInputoptional
default {direction: DESC}
Sort order.
omit_currencies[String!]optionalFilter by omit_currencies.

Response

Fields of Instrument selected in the operation below.

FieldTypeDescription
nameString!Instrument name.
base_currency_idString!Base currency of pair
quote_currency_idString!Quote currency of pair
instrument_idString!Unique instrument ID
quantity_decimalsIntQuantity precision (decimal places).
price_decimalsFloat!Price precision (decimal places).
min_quantityFloat!Minimum order quantity.
max_quantityFloat!Maximum order quantity.
is_activeToggleSwitch!Active flag.
priceInstrumentPricePrice.

GraphQL Operation

query instruments {
  instruments {
    name base_currency_id quote_currency_id instrument_id quantity_decimals price_decimals min_quantity max_quantity is_active
    price { instrument_id ask bid price_24h_change }
  }
}

Code Examples

curl -X POST 'https://live-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"query instruments { instruments { name base_currency_id quote_currency_id instrument_id quantity_decimals price_decimals min_quantity max_quantity is_active price { instrument_id ask bid price_24h_change } } }","variables":{}}'
import requests

url = "https://live-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """query instruments { instruments { name base_currency_id quote_currency_id instrument_id quantity_decimals price_decimals min_quantity max_quantity is_active price { instrument_id ask bid price_24h_change } } }""",
    "variables": {},
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `query instruments { instruments { name base_currency_id quote_currency_id instrument_id quantity_decimals price_decimals min_quantity max_quantity is_active price { instrument_id ask bid price_24h_change } } }`,
    variables: {},
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this
querycurrenciesList supported currencies.
Endpoint: POST https://live-api.ouinex.com/graphql
Type: Query
Returns: [Currency!]!
Rate limit: 60 requests / 60 s

Authentication is optional.

Inputs

NameTypeRequiredDescription
searchStringoptionalSearch term.
typeCurrencyTypeoptionalFilter by type.
is_activeToggleSwitchoptionalFilter by is_active.
pageIntoptionalPage number (1-based).
limitInt!optional
default 100
Page size (default 100); applied only when page is set.
omit_currencies[String!]optionalFilter by omit_currencies.

Response

Fields of Currency selected in the operation below.

FieldTypeDescription
currency_idString!Unique currency ID
nameStringName.
precisionInt!Decimal precision
typeCurrencyType!Type.
is_activeToggleSwitch!Active flag.

GraphQL Operation

query currencies {
  currencies {
    currency_id name precision type is_active
  }
}

Code Examples

curl -X POST 'https://live-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"query currencies { currencies { currency_id name precision type is_active } }","variables":{}}'
import requests

url = "https://live-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """query currencies { currencies { currency_id name precision type is_active } }""",
    "variables": {},
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `query currencies { currencies { currency_id name precision type is_active } }`,
    variables: {},
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this

Vaults

Optional group: requires vaults to be enabled on the platform (vaults_enabled). Served by the spot API host.

queryenabled_vaultsList yield vaults available to the user.
Endpoint: POST https://live-api.ouinex.com/graphql
Type: Query
Returns: [Vault!]!
Permission: vaults

Inputs

NameTypeRequiredDescription
vault_idStringoptionalFilter by specific vault
currency_idStringoptionalCurrency filter.
is_activeToggleSwitchoptionalFilter by active status.
withdrawal_enabledToggleSwitchoptionalFilter by withdrawal status
deposit_enabledToggleSwitchoptionalFilter by deposit status
lock_strategyVaultLockStrategyoptionalFilter by lock_strategy.
rate_typeVaultRateTypeoptionalFilter by rate_type.
withdrawal_policyVaultWithdrawalPolicyoptionalFilter by withdrawal_policy.
searchStringoptionalSearch term.
pagerPagerInputoptional
default {limit: 1000, offset: 0}
Pagination (limit, offset).
sortSortInputoptional
default {direction: DESC}
Sort order.

Response

Fields of Vault selected in the operation below.

FieldTypeDescription
serial_idIntSequential record ID.
vault_idString!Vault unique identifier
currency_idString!Currency.
nameStringVault name and asset
annual_rate_percentFloat!APY percentage
max_withdrawal_amountFloat!Maximum withdrawal amount.
max_deposit_amountFloat!Maximum deposit amount.
min_withdrawal_amountFloat!Minimum withdrawal amount.
min_deposit_amountFloat!Minimum deposit required
cut_off_time_secondsInt!The minimum amount of time in seconds before first reward is given
lock_in_period_secondsIntThe minimum amount of time before user can withdraw funds from the vault. If 0 then no lock-in period is set. (Effective for fixed rate only)
effective_date_fromString!Start of the vault's effective period.
effective_date_toStringEnd of the vault's effective period.
rate_typeVaultRateType!Type of rate for the vault, flexible allows to withdraw at any time, fixed has a lock-in period.
is_activeToggleSwitch!Active flag.
withdrawal_enabledToggleSwitch!Withdrawals enabled.
deposit_enabledToggleSwitch!Deposits enabled.
last_interest_atStringTime interest was last paid.
created_atString!Creation time.
updated_atString!Last update time.
total_balanceFloat!Total balance.
withdrawal_policyVaultWithdrawalPolicy!Policy for withdrawal of funds from the vault. This will apply to all withdrawals from the vault (including ones created automatically by the system)
withdrawal_delay_secondsIntEffective only if withdrawal_policy is delayed. The minimum amount of time before funds are withdrawn to user wallet after a withdrawal request is made.
metaStringAdditional metadata.
level5_apyFloatAPY with the level-5 yield boost applied (null when no boost applies).
currencyCurrencyCurrency details.

GraphQL Operation

query enabled_vaults($is_active: ToggleSwitch, $pager: PagerInput) {
  enabled_vaults(is_active: $is_active, pager: $pager) {
    serial_id vault_id currency_id name annual_rate_percent max_withdrawal_amount max_deposit_amount min_withdrawal_amount min_deposit_amount cut_off_time_seconds lock_in_period_seconds effective_date_from effective_date_to rate_type is_active withdrawal_enabled deposit_enabled last_interest_at created_at updated_at total_balance withdrawal_policy withdrawal_delay_seconds meta level5_apy
    currency { type }
  }
}

Code Examples

curl -X POST 'https://live-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"query enabled_vaults($is_active: ToggleSwitch, $pager: PagerInput) { enabled_vaults(is_active: $is_active, pager: $pager) { serial_id vault_id currency_id name annual_rate_percent max_withdrawal_amount max_deposit_amount min_withdrawal_amount min_deposit_amount cut_off_time_seconds lock_in_period_seconds effective_date_from effective_date_to rate_type is_active withdrawal_enabled deposit_enabled last_interest_at created_at updated_at total_balance withdrawal_policy withdrawal_delay_seconds meta level5_apy currency { type } } }","variables":{"is_active":"on","pager":{"limit":50,"offset":0}}}'
import requests

url = "https://live-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """query enabled_vaults($is_active: ToggleSwitch, $pager: PagerInput) { enabled_vaults(is_active: $is_active, pager: $pager) { serial_id vault_id currency_id name annual_rate_percent max_withdrawal_amount max_deposit_amount min_withdrawal_amount min_deposit_amount cut_off_time_seconds lock_in_period_seconds effective_date_from effective_date_to rate_type is_active withdrawal_enabled deposit_enabled last_interest_at created_at updated_at total_balance withdrawal_policy withdrawal_delay_seconds meta level5_apy currency { type } } }""",
    "variables": {
        "is_active": "on",
        "pager": {
            "limit": 50,
            "offset": 0
        }
    },
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `query enabled_vaults($is_active: ToggleSwitch, $pager: PagerInput) { enabled_vaults(is_active: $is_active, pager: $pager) { serial_id vault_id currency_id name annual_rate_percent max_withdrawal_amount max_deposit_amount min_withdrawal_amount min_deposit_amount cut_off_time_seconds lock_in_period_seconds effective_date_from effective_date_to rate_type is_active withdrawal_enabled deposit_enabled last_interest_at created_at updated_at total_balance withdrawal_policy withdrawal_delay_seconds meta level5_apy currency { type } } }`,
    variables: {
      "is_active": "on",
      "pager": {
        "limit": 50,
        "offset": 0
      }
    },
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this
queryvaults_accountsRead the user's vault account balances.
Endpoint: POST https://live-api.ouinex.com/graphql
Type: Query
Returns: [VaultAccount!]!
Permission: vaults_accounts

Inputs

NameTypeRequiredDescription
vault_account_idStringoptionalSpecific account filter
vault_idStringoptionalVault filter
currency_idStringoptionalCurrency filter.
hide_zero_balancesToggleSwitchoptional
default off
Filter by hide_zero_balances.
searchStringoptionalSearch term.
pagerPagerInputoptional
default {limit: 30, offset: 0}
Pagination (limit, offset).
sortSortInputoptional
default {direction: DESC}
Sort order.
wallet_idStringoptionalWallet filter.

Response

Fields of VaultAccount selected in the operation below.

FieldTypeDescription
vault_account_idString!Account unique ID
vault_idString!Vault.
balanceFloat!Current vault balance
free_balanceFloatAccount free balance (current balance minus pending requests)
exposed_vault_balanceFloatAccount exposed vault balance
created_at_isoString!Creation time (ISO 8601).
updated_at_isoString!Last update time (ISO 8601).

GraphQL Operation

query vaults_accounts($pager: PagerInput, $wallet_id: String) {
  vaults_accounts(pager: $pager, wallet_id: $wallet_id) {
    vault_account_id vault_id balance free_balance exposed_vault_balance created_at_iso updated_at_iso
  }
}

Code Examples

curl -X POST 'https://live-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"query vaults_accounts($pager: PagerInput, $wallet_id: String) { vaults_accounts(pager: $pager, wallet_id: $wallet_id) { vault_account_id vault_id balance free_balance exposed_vault_balance created_at_iso updated_at_iso } }","variables":{"pager":{"limit":50,"offset":0},"wallet_id":"wallet123"}}'
import requests

url = "https://live-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """query vaults_accounts($pager: PagerInput, $wallet_id: String) { vaults_accounts(pager: $pager, wallet_id: $wallet_id) { vault_account_id vault_id balance free_balance exposed_vault_balance created_at_iso updated_at_iso } }""",
    "variables": {
        "pager": {
            "limit": 50,
            "offset": 0
        },
        "wallet_id": "wallet123"
    },
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `query vaults_accounts($pager: PagerInput, $wallet_id: String) { vaults_accounts(pager: $pager, wallet_id: $wallet_id) { vault_account_id vault_id balance free_balance exposed_vault_balance created_at_iso updated_at_iso } }`,
    variables: {
      "pager": {
        "limit": 50,
        "offset": 0
      },
      "wallet_id": "wallet123"
    },
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this
queryvaults_transactionsRead vault deposit / withdrawal / interest history.
Endpoint: POST https://live-api.ouinex.com/graphql
Type: Query
Returns: [VaultTransaction!]!
Permission: vaults_transactions

Inputs

NameTypeRequiredDescription
vault_idStringoptionalVault filter
vault_transaction_idStringoptionalSpecific transaction
account_transaction_idStringoptionalFilter by account_transaction_id.
transaction_typeAccountTransactionTypeoptionalFilter by debit / credit.
transaction_classVaultsTransactionClassoptionalTransaction class
searchStringoptionalSearch term.
currency_idStringoptionalCurrency filter.
pagerPagerInputoptional
default {limit: 30, offset: 0}
Pagination (limit, offset).
date_rangeDateRangeInputoptionalDate range
sortSortInputoptional
default {direction: DESC}
Sort order.
wallet_idStringoptionalWallet filter.

Response

Fields of VaultTransaction selected in the operation below.

FieldTypeDescription
vault_transaction_idString!Transaction ID
amountFloat!Transaction amount
currency_idStringCurrency.
transaction_classVaultsTransactionClass!Type of transaction
created_at_isoString!Transaction timestamp
is_delayedToggleSwitchWhether execution is delayed.
delayed_until_isoStringTime a delayed transaction is executed (ISO 8601).
apyFloatThe vault APY (annual percentage yield) that was active at the time of this transaction, or of the request that produced it
vaultVaultVault details.

GraphQL Operation

query vaults_transactions($pager: PagerInput, $wallet_id: String) {
  vaults_transactions(pager: $pager, wallet_id: $wallet_id) {
    vault_transaction_id amount currency_id transaction_class created_at_iso is_delayed delayed_until_iso apy
    vault { annual_rate_percent rate_type lock_in_period_seconds }
  }
}

Code Examples

curl -X POST 'https://live-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"query vaults_transactions($pager: PagerInput, $wallet_id: String) { vaults_transactions(pager: $pager, wallet_id: $wallet_id) { vault_transaction_id amount currency_id transaction_class created_at_iso is_delayed delayed_until_iso apy vault { annual_rate_percent rate_type lock_in_period_seconds } } }","variables":{"pager":{"limit":50,"offset":0},"wallet_id":"wallet123"}}'
import requests

url = "https://live-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """query vaults_transactions($pager: PagerInput, $wallet_id: String) { vaults_transactions(pager: $pager, wallet_id: $wallet_id) { vault_transaction_id amount currency_id transaction_class created_at_iso is_delayed delayed_until_iso apy vault { annual_rate_percent rate_type lock_in_period_seconds } } }""",
    "variables": {
        "pager": {
            "limit": 50,
            "offset": 0
        },
        "wallet_id": "wallet123"
    },
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `query vaults_transactions($pager: PagerInput, $wallet_id: String) { vaults_transactions(pager: $pager, wallet_id: $wallet_id) { vault_transaction_id amount currency_id transaction_class created_at_iso is_delayed delayed_until_iso apy vault { annual_rate_percent rate_type lock_in_period_seconds } } }`,
    variables: {
      "pager": {
        "limit": 50,
        "offset": 0
      },
      "wallet_id": "wallet123"
    },
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this
mutationcreate_vault_depositDeposit funds into a vault.
Endpoint: POST https://live-api.ouinex.com/graphql
Type: Mutation
Returns: VaultRequestResponse!
Permission: create_vault_deposit

Inputs

NameTypeRequiredDescription
vault_idString!requiredVault to deposit into
amountFloat!requiredDeposit amount
use_all_fundsBooleanoptionalNot used for deposits; amount is always required.
wallet_idString!optional
default "MAIN"
Wallet to debit. Defaults to MAIN.

Response

Fields of VaultRequestResponse selected in the operation below.

FieldTypeDescription
messageString!Operation message
statusString!Operation status
transactionVaultTransactionExecuted vault transaction, when the operation was executed immediately.
requestVaultTransactionRequestVault transaction request, when the operation was queued as a request.

GraphQL Operation

mutation create_vault_deposit($vault_id: String!, $amount: Float!, $wallet_id: String) {
  create_vault_deposit(vault_id: $vault_id, amount: $amount, wallet_id: $wallet_id) {
    message status
    transaction {
      vault_transaction_id vault_id amount currency_id transaction_class created_at_iso
    }
    request { request_id vault_id amount status created_at_iso }
  }
}

Code Examples

curl -X POST 'https://live-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"mutation create_vault_deposit($vault_id: String!, $amount: Float!, $wallet_id: String) { create_vault_deposit(vault_id: $vault_id, amount: $amount, wallet_id: $wallet_id) { message status transaction { vault_transaction_id vault_id amount currency_id transaction_class created_at_iso } request { request_id vault_id amount status created_at_iso } } }","variables":{"vault_id":"vault123","amount":10000,"wallet_id":"wallet123"}}'
import requests

url = "https://live-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """mutation create_vault_deposit($vault_id: String!, $amount: Float!, $wallet_id: String) { create_vault_deposit(vault_id: $vault_id, amount: $amount, wallet_id: $wallet_id) { message status transaction { vault_transaction_id vault_id amount currency_id transaction_class created_at_iso } request { request_id vault_id amount status created_at_iso } } }""",
    "variables": {
        "vault_id": "vault123",
        "amount": 10000,
        "wallet_id": "wallet123"
    },
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `mutation create_vault_deposit($vault_id: String!, $amount: Float!, $wallet_id: String) { create_vault_deposit(vault_id: $vault_id, amount: $amount, wallet_id: $wallet_id) { message status transaction { vault_transaction_id vault_id amount currency_id transaction_class created_at_iso } request { request_id vault_id amount status created_at_iso } } }`,
    variables: {
      "vault_id": "vault123",
      "amount": 10000,
      "wallet_id": "wallet123"
    },
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this
mutationcreate_vault_withdrawalWithdraw funds from a vault.
Endpoint: POST https://live-api.ouinex.com/graphql
Type: Mutation
Returns: VaultRequestResponse!
Permission: create_vault_withdrawal

Inputs

NameTypeRequiredDescription
vault_idString!requiredVault to withdraw from
amountFloat!requiredWithdrawal amount
use_all_fundsBooleanoptionalWithdraw the full free vault balance (overrides amount).
wallet_idString!optional
default "MAIN"
Wallet to credit. Defaults to MAIN.

Response

Fields of VaultRequestResponse selected in the operation below.

FieldTypeDescription
messageString!Withdrawal status message
statusString!Request status
transactionVaultTransactionExecuted vault transaction, when the operation was executed immediately.
requestVaultTransactionRequestVault transaction request, when the operation was queued as a request.

GraphQL Operation

mutation create_vault_withdrawal($vault_id: String!, $amount: Float!, $wallet_id: String) {
  create_vault_withdrawal(vault_id: $vault_id, amount: $amount, wallet_id: $wallet_id) {
    message status
    transaction {
      vault_transaction_id vault_id amount currency_id transaction_class created_at_iso
    }
    request { request_id vault_id amount status created_at_iso }
  }
}

Code Examples

curl -X POST 'https://live-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"mutation create_vault_withdrawal($vault_id: String!, $amount: Float!, $wallet_id: String) { create_vault_withdrawal(vault_id: $vault_id, amount: $amount, wallet_id: $wallet_id) { message status transaction { vault_transaction_id vault_id amount currency_id transaction_class created_at_iso } request { request_id vault_id amount status created_at_iso } } }","variables":{"vault_id":"vault123","amount":5000,"wallet_id":"wallet123"}}'
import requests

url = "https://live-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """mutation create_vault_withdrawal($vault_id: String!, $amount: Float!, $wallet_id: String) { create_vault_withdrawal(vault_id: $vault_id, amount: $amount, wallet_id: $wallet_id) { message status transaction { vault_transaction_id vault_id amount currency_id transaction_class created_at_iso } request { request_id vault_id amount status created_at_iso } } }""",
    "variables": {
        "vault_id": "vault123",
        "amount": 5000,
        "wallet_id": "wallet123"
    },
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `mutation create_vault_withdrawal($vault_id: String!, $amount: Float!, $wallet_id: String) { create_vault_withdrawal(vault_id: $vault_id, amount: $amount, wallet_id: $wallet_id) { message status transaction { vault_transaction_id vault_id amount currency_id transaction_class created_at_iso } request { request_id vault_id amount status created_at_iso } } }`,
    variables: {
      "vault_id": "vault123",
      "amount": 5000,
      "wallet_id": "wallet123"
    },
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this
queryvaults_transactions_requestsList vault transaction requests.
Endpoint: POST https://live-api.ouinex.com/graphql
Type: Query
Returns: [VaultTransactionRequest!]!
Permission: vaults_transactions_requests

Inputs

NameTypeRequiredDescription
serial_idIntoptionalFilter by serial_id.
request_idStringoptionalFilter by request_id.
vault_idStringoptionalVault filter
transaction_typeAccountTransactionTypeoptionalFilter by debit / credit.
transaction_classVaultsTransactionClassoptionalTransaction class
statusVaultTransactionRequestStatusoptionalFilter by status.
searchStringoptionalSearch term.
pagerPagerInputoptional
default {limit: 30, offset: 0}
Pagination (limit, offset).
date_rangeDateRangeInputoptionalDate range
sortSortInputoptional
default {direction: DESC}
Sort order.
currency_idStringoptionalCurrency filter.
wallet_idStringoptionalWallet filter.

Response

Fields of VaultTransactionRequest selected in the operation below.

FieldTypeDescription
serial_idIntSequential record ID.
request_idString!Request identifier
vault_idString!Vault.
amountFloat!Request amount
transaction_classVaultsTransactionClass!Transaction class.
statusVaultTransactionRequestStatus!Approval status
created_at_isoString!Request timestamp
updated_at_isoString!Last update time (ISO 8601).
approved_atStringApproval time.
vaultVault!Vault details.
apyFloatThe vault APY (annual percentage yield) that was active at the time of this transaction request

GraphQL Operation

query vaults_transactions_requests($pager: PagerInput, $wallet_id: String) {
  vaults_transactions_requests(pager: $pager, wallet_id: $wallet_id) {
    serial_id request_id vault_id amount transaction_class status created_at_iso updated_at_iso approved_at
    vault {
      serial_id vault_id currency_id name annual_rate_percent max_withdrawal_amount max_deposit_amount min_withdrawal_amount min_deposit_amount cut_off_time_seconds lock_in_period_seconds effective_date_from effective_date_to rate_type is_active withdrawal_enabled deposit_enabled last_interest_at created_at updated_at total_balance withdrawal_policy withdrawal_delay_seconds meta level5_apy
      currency { type }
    }
    apy
  }
}

Code Examples

curl -X POST 'https://live-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"query vaults_transactions_requests($pager: PagerInput, $wallet_id: String) { vaults_transactions_requests(pager: $pager, wallet_id: $wallet_id) { serial_id request_id vault_id amount transaction_class status created_at_iso updated_at_iso approved_at vault { serial_id vault_id currency_id name annual_rate_percent max_withdrawal_amount max_deposit_amount min_withdrawal_amount min_deposit_amount cut_off_time_seconds lock_in_period_seconds effective_date_from effective_date_to rate_type is_active withdrawal_enabled deposit_enabled last_interest_at created_at updated_at total_balance withdrawal_policy withdrawal_delay_seconds meta level5_apy currency { type } } apy } }","variables":{"pager":{"limit":50,"offset":0},"wallet_id":"wallet123"}}'
import requests

url = "https://live-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """query vaults_transactions_requests($pager: PagerInput, $wallet_id: String) { vaults_transactions_requests(pager: $pager, wallet_id: $wallet_id) { serial_id request_id vault_id amount transaction_class status created_at_iso updated_at_iso approved_at vault { serial_id vault_id currency_id name annual_rate_percent max_withdrawal_amount max_deposit_amount min_withdrawal_amount min_deposit_amount cut_off_time_seconds lock_in_period_seconds effective_date_from effective_date_to rate_type is_active withdrawal_enabled deposit_enabled last_interest_at created_at updated_at total_balance withdrawal_policy withdrawal_delay_seconds meta level5_apy currency { type } } apy } }""",
    "variables": {
        "pager": {
            "limit": 50,
            "offset": 0
        },
        "wallet_id": "wallet123"
    },
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `query vaults_transactions_requests($pager: PagerInput, $wallet_id: String) { vaults_transactions_requests(pager: $pager, wallet_id: $wallet_id) { serial_id request_id vault_id amount transaction_class status created_at_iso updated_at_iso approved_at vault { serial_id vault_id currency_id name annual_rate_percent max_withdrawal_amount max_deposit_amount min_withdrawal_amount min_deposit_amount cut_off_time_seconds lock_in_period_seconds effective_date_from effective_date_to rate_type is_active withdrawal_enabled deposit_enabled last_interest_at created_at updated_at total_balance withdrawal_policy withdrawal_delay_seconds meta level5_apy currency { type } } apy } }`,
    variables: {
      "pager": {
        "limit": 50,
        "offset": 0
      },
      "wallet_id": "wallet123"
    },
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this
mutationcancel_vault_transaction_requestCancel a pending vault transaction request.
Endpoint: POST https://live-api.ouinex.com/graphql
Type: Mutation
Returns: Boolean!
Permission: cancel_vault_transaction_request

Inputs

NameTypeRequiredDescription
request_idString!requiredRequest ID to cancel

GraphQL Operation

mutation cancel_vault_transaction_request($request_id: String!) {
  cancel_vault_transaction_request(request_id: $request_id)
}

Code Examples

curl -X POST 'https://live-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"mutation cancel_vault_transaction_request($request_id: String!) { cancel_vault_transaction_request(request_id: $request_id) }","variables":{"request_id":"req123"}}'
import requests

url = "https://live-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """mutation cancel_vault_transaction_request($request_id: String!) { cancel_vault_transaction_request(request_id: $request_id) }""",
    "variables": {
        "request_id": "req123"
    },
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `mutation cancel_vault_transaction_request($request_id: String!) { cancel_vault_transaction_request(request_id: $request_id) }`,
    variables: {
      "request_id": "req123"
    },
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this
queryestimate_vault_interestsEstimate interest on a planned deposit into a fixed vault.
Endpoint: POST https://live-api.ouinex.com/graphql
Type: Query
Returns: Float!
Permission: estimate_vault_interests

Fixed vaults only.

Inputs

NameTypeRequiredDescription
vault_idString!requiredVault ID
amountFloat!requiredDeposit amount
duration_secondsIntoptionalDeposit duration, in seconds.

GraphQL Operation

query estimate_vault_interests($vault_id: String!, $amount: Float!, $duration_seconds: Int) {
  estimate_vault_interests(vault_id: $vault_id, amount: $amount, duration_seconds: $duration_seconds)
}

Code Examples

curl -X POST 'https://live-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"query estimate_vault_interests($vault_id: String!, $amount: Float!, $duration_seconds: Int) { estimate_vault_interests(vault_id: $vault_id, amount: $amount, duration_seconds: $duration_seconds) }","variables":{"vault_id":"vault123","amount":10000,"duration_seconds":86400}}'
import requests

url = "https://live-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """query estimate_vault_interests($vault_id: String!, $amount: Float!, $duration_seconds: Int) { estimate_vault_interests(vault_id: $vault_id, amount: $amount, duration_seconds: $duration_seconds) }""",
    "variables": {
        "vault_id": "vault123",
        "amount": 10000,
        "duration_seconds": 86400
    },
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `query estimate_vault_interests($vault_id: String!, $amount: Float!, $duration_seconds: Int) { estimate_vault_interests(vault_id: $vault_id, amount: $amount, duration_seconds: $duration_seconds) }`,
    variables: {
      "vault_id": "vault123",
      "amount": 10000,
      "duration_seconds": 86400
    },
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this

Derivatives

Optional group: requires derivatives to be enabled for the user's limit group. Served by the margin API host. Operation names use the margin_ prefix; the API-key permissions that guard them use the derivatives_ prefix.

querymargin_instrumentsList derivatives instruments.
Endpoint: POST https://live-margin-api.ouinex.com/graphql
Type: Query
Returns: [MarginInstrument!]!
Rate limit: 100 requests / 60 s

Authentication is optional. Without a token, the default limit group's instrument list is returned.

Inputs

NameTypeRequiredDescription
searchStringoptionalSearch term.
pagerPagerInputoptional
default {limit: 30, offset: 0}
Pagination (limit, offset).
sortSortInputoptional
default {direction: ASC}
Sort order.
margin_instrument_idStringoptionalFilter by margin_instrument_id.
is_activeToggleSwitchoptionalFilter by active status.
classMarginInstrumentClassoptionalFilter by instrument class.

Response

Fields of MarginInstrument selected in the operation below.

FieldTypeDescription
margin_instrument_idString!Unique instrument identifier
nameString!Instrument display name.
base_currency_idString!Base currency.
quote_currency_idString!Quote currency.
min_leverageInt!Minimum leverage.
max_leverageInt!Maximum leverage.
min_quantityFloat!Minimum order quantity.
max_quantityFloat!Maximum order quantity.
price_24h_changeFloat24-hour price change.
price_24h_lowFloat24-hour low.
price_24h_highFloat24-hour high.
is_trading_onBoolean!Whether trading is currently open for the user.
market_statusMarketStatus!Current market status.
classMarginInstrumentClass!Instrument class.
lot_sizeFloatContract lot size.
step_sizeFloat!Quantity step size.
cross_quote_priceFloatConversion rate from the instrument's quote currency to the margin currency.
close_onlyToggleSwitch!When on, the instrument is in close-only mode.
base_currencyMarginCurrencyBase currency details.
quote_currencyMarginCurrencyQuote currency details.
priceMarginInstrumentPriceCurrent bid/ask pricing
funding_dataMarginInstrumentFundingData
metaString!Additional metadata.
market_hoursTraderCalendarData!Trading hours.

GraphQL Operation

query margin_instruments($pager: PagerInput) {
  margin_instruments(pager: $pager) {
    margin_instrument_id name base_currency_id quote_currency_id min_leverage max_leverage min_quantity max_quantity price_24h_change price_24h_low price_24h_high is_trading_on market_status class lot_size step_size cross_quote_price close_only
    base_currency { currency_id precision is_active }
    quote_currency { currency_id precision is_active }
    price { margin_instrument_id ask bid updated_at }
    funding_data {
      rate_type next_funding_date long_funding_rate short_funding_rate multiplier period
    }
    meta
    market_hours {
      custom_periods { end_time name start_time }
      general_rules { days end_time is_active start_time }
      holidays { end_time name start_time }
    }
  }
}

Code Examples

curl -X POST 'https://live-margin-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"query margin_instruments($pager: PagerInput) { margin_instruments(pager: $pager) { margin_instrument_id name base_currency_id quote_currency_id min_leverage max_leverage min_quantity max_quantity price_24h_change price_24h_low price_24h_high is_trading_on market_status class lot_size step_size cross_quote_price close_only base_currency { currency_id precision is_active } quote_currency { currency_id precision is_active } price { margin_instrument_id ask bid updated_at } funding_data { rate_type next_funding_date long_funding_rate short_funding_rate multiplier period } meta market_hours { custom_periods { end_time name start_time } general_rules { days end_time is_active start_time } holidays { end_time name start_time } } } }","variables":{"pager":{"limit":1000,"offset":0}}}'
import requests

url = "https://live-margin-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """query margin_instruments($pager: PagerInput) { margin_instruments(pager: $pager) { margin_instrument_id name base_currency_id quote_currency_id min_leverage max_leverage min_quantity max_quantity price_24h_change price_24h_low price_24h_high is_trading_on market_status class lot_size step_size cross_quote_price close_only base_currency { currency_id precision is_active } quote_currency { currency_id precision is_active } price { margin_instrument_id ask bid updated_at } funding_data { rate_type next_funding_date long_funding_rate short_funding_rate multiplier period } meta market_hours { custom_periods { end_time name start_time } general_rules { days end_time is_active start_time } holidays { end_time name start_time } } } }""",
    "variables": {
        "pager": {
            "limit": 1000,
            "offset": 0
        }
    },
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-margin-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `query margin_instruments($pager: PagerInput) { margin_instruments(pager: $pager) { margin_instrument_id name base_currency_id quote_currency_id min_leverage max_leverage min_quantity max_quantity price_24h_change price_24h_low price_24h_high is_trading_on market_status class lot_size step_size cross_quote_price close_only base_currency { currency_id precision is_active } quote_currency { currency_id precision is_active } price { margin_instrument_id ask bid updated_at } funding_data { rate_type next_funding_date long_funding_rate short_funding_rate multiplier period } meta market_hours { custom_periods { end_time name start_time } general_rules { days end_time is_active start_time } holidays { end_time name start_time } } } }`,
    variables: {
      "pager": {
        "limit": 1000,
        "offset": 0
      }
    },
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this
querymargin_instruments_pricesCurrent bid and ask of every derivatives instrument.
Endpoint: POST https://live-margin-api.ouinex.com/graphql
Type: Query
Returns: [MarginInstrumentPrice!]!

Response

Fields of MarginInstrumentPrice selected in the operation below.

FieldTypeDescription
margin_instrument_idString!
askFloat
bidFloat
updated_atString!
updated_at_isoString

GraphQL Operation

query margin_instruments_prices {
  margin_instruments_prices { margin_instrument_id ask bid updated_at updated_at_iso }
}

Code Examples

curl -X POST 'https://live-margin-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"query margin_instruments_prices { margin_instruments_prices { margin_instrument_id ask bid updated_at updated_at_iso } }","variables":{}}'
import requests

url = "https://live-margin-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """query margin_instruments_prices { margin_instruments_prices { margin_instrument_id ask bid updated_at updated_at_iso } }""",
    "variables": {},
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-margin-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `query margin_instruments_prices { margin_instruments_prices { margin_instrument_id ask bid updated_at updated_at_iso } }`,
    variables: {},
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this
querymargin_instrument_price_barsOHLC price history (mid price) of a derivatives instrument.
Endpoint: POST https://live-margin-api.ouinex.com/graphql
Type: Query
Returns: [MarginInstrumentPriceHistory!]!

Bars carry their timestamp in updated_at_iso.

Inputs

NameTypeRequiredDescription
periodicityMarginInstrumentHistoryPeriodicityoptional
default day
Bar interval.
limitIntoptional
default 1000
Maximum number of bars.
date_rangeDateRangeInputoptionalWindow to read (time_from, time_to).
instrument_idString!requiredDerivatives instrument ID (margin_instrument_id from margin_instruments).

Response

Fields of MarginInstrumentPriceHistory selected in the operation below.

FieldTypeDescription
margin_instrument_idString!
openFloat
highFloat
lowFloat
closeFloat
updated_at_isoString!

GraphQL Operation

query margin_instrument_price_bars($periodicity: MarginInstrumentHistoryPeriodicity, $instrument_id: String!) {
  margin_instrument_price_bars(periodicity: $periodicity, instrument_id: $instrument_id) { margin_instrument_id open high low close updated_at_iso }
}

Code Examples

curl -X POST 'https://live-margin-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"query margin_instrument_price_bars($periodicity: MarginInstrumentHistoryPeriodicity, $instrument_id: String!) { margin_instrument_price_bars(periodicity: $periodicity, instrument_id: $instrument_id) { margin_instrument_id open high low close updated_at_iso } }","variables":{"instrument_id":"BTCUSD","periodicity":"hour"}}'
import requests

url = "https://live-margin-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """query margin_instrument_price_bars($periodicity: MarginInstrumentHistoryPeriodicity, $instrument_id: String!) { margin_instrument_price_bars(periodicity: $periodicity, instrument_id: $instrument_id) { margin_instrument_id open high low close updated_at_iso } }""",
    "variables": {
        "instrument_id": "BTCUSD",
        "periodicity": "hour"
    },
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-margin-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `query margin_instrument_price_bars($periodicity: MarginInstrumentHistoryPeriodicity, $instrument_id: String!) { margin_instrument_price_bars(periodicity: $periodicity, instrument_id: $instrument_id) { margin_instrument_id open high low close updated_at_iso } }`,
    variables: {
      "instrument_id": "BTCUSD",
      "periodicity": "hour"
    },
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this
querymargin_advanced_order_types_enabledWhich advanced order types are switched on.
Endpoint: POST https://live-margin-api.ouinex.com/graphql
Type: Query
Returns: AdvancedOrderTypesEnabled!

A type reporting false is switched off platform-wide; its create operation is rejected.

Response

Fields of AdvancedOrderTypesEnabled selected in the operation below.

FieldTypeDescription
stopBoolean!Stop Market & Stop Limit orders (does not cover Trailing Stop)
trailing_stopBoolean!Trailing Stop orders (independent of `stop`)
scaledBoolean!
ocoBoolean!
otoBoolean!
twapBoolean!
icebergBoolean!
stop_presetsBoolean!Stop break-even and stop-win presets on open positions (Smart Protection)
trailing_presetsBoolean!Trailing stop presets attached to open positions
multi_tp_slBoolean!Multiple TP/SL levels on orders and open positions

GraphQL Operation

query margin_advanced_order_types_enabled {
  margin_advanced_order_types_enabled { stop trailing_stop scaled oco oto twap iceberg stop_presets trailing_presets multi_tp_sl }
}

Code Examples

curl -X POST 'https://live-margin-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"query margin_advanced_order_types_enabled { margin_advanced_order_types_enabled { stop trailing_stop scaled oco oto twap iceberg stop_presets trailing_presets multi_tp_sl } }","variables":{}}'
import requests

url = "https://live-margin-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """query margin_advanced_order_types_enabled { margin_advanced_order_types_enabled { stop trailing_stop scaled oco oto twap iceberg stop_presets trailing_presets multi_tp_sl } }""",
    "variables": {},
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-margin-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `query margin_advanced_order_types_enabled { margin_advanced_order_types_enabled { stop trailing_stop scaled oco oto twap iceberg stop_presets trailing_presets multi_tp_sl } }`,
    variables: {},
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this
queryopen_margin_ordersList currently open margin orders.
Endpoint: POST https://live-margin-api.ouinex.com/graphql
Type: Query
Returns: [MarginOrder!]!
Permission: open_derivatives_orders
Rate limit: 100 requests / 60 s

Inputs

NameTypeRequiredDescription
searchStringoptionalSearch term.
pagerPagerInputoptional
default {limit: 30, offset: 0}
Pagination (limit, offset).
sortSortInputoptional
default {direction: ASC}
Sort order.
dateRangeDateRangeInputoptional
default {}
Filter by created_at (format YYYY-MM-DD HH:mm:ss).
sideMarginPositionSideoptionalbuy or sell
statusMarginOrderStatusoptionalFilter by order status.
time_in_forceMarginOrderTimeInForceoptionalFilter by time in force.
typeMarginOrderTypeoptionalmarket or limit
instrument_idStringoptionalInstrument filter.
instruments_ids[String!]optionalMultiple instrument IDs
wallet_idStringoptionalWallet filter.
currency_idStringoptionalFilter orders by base currency ID

Response

Fields of MarginOrder selected in the operation below.

FieldTypeDescription
margin_order_idString!Order unique identifier
margin_position_idStringPosition the order belongs to.
instrument_idString!Instrument.
sideMarginPositionSide!buy or sell.
typeMarginOrderType!market or limit.
statusMarginOrderStatus!Order status.
leverageInt!Leverage multiplier
quantityFloat!Order size
priceFloatPrice.
limit_priceFloatLimit price.
messageStringStatus / rejection message.
created_at_timestampString!Creation time, Unix milliseconds.
stop_lossFloatStop-loss price.
take_profitFloatTake-profit price.
askFloatAsk price.
bidFloatBid price.
executed_quantityFloat!Executed quantity.
fee_amountFloatTrading fee charged
time_in_forceMarginOrderTimeInForce!Time in force.
expires_at_isoStringExpiry time (ISO 8601).
updated_at_isoString!Last update time (ISO 8601).
cross_quote_priceFloatConversion rate from the instrument's quote currency to the margin currency.
wallet_idStringWallet.
margin_instrumentMarginInstrumentInstrument details.

GraphQL Operation

query open_margin_orders($pager: PagerInput, $side: MarginPositionSide, $status: MarginOrderStatus) {
  open_margin_orders(pager: $pager, side: $side, status: $status) {
    margin_order_id margin_position_id instrument_id side type status leverage quantity price limit_price message created_at_timestamp stop_loss take_profit ask bid executed_quantity fee_amount time_in_force expires_at_iso updated_at_iso cross_quote_price wallet_id
    margin_instrument {
      base_currency_id quote_currency_id name min_leverage max_leverage min_quantity max_quantity cross_quote_price close_only
      quote_currency { precision }
      base_currency { precision }
      price { ask bid }
      lot_size step_size class margin_instrument_id is_trading_on market_status
    }
  }
}

Code Examples

curl -X POST 'https://live-margin-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"query open_margin_orders($pager: PagerInput, $side: MarginPositionSide, $status: MarginOrderStatus) { open_margin_orders(pager: $pager, side: $side, status: $status) { margin_order_id margin_position_id instrument_id side type status leverage quantity price limit_price message created_at_timestamp stop_loss take_profit ask bid executed_quantity fee_amount time_in_force expires_at_iso updated_at_iso cross_quote_price wallet_id margin_instrument { base_currency_id quote_currency_id name min_leverage max_leverage min_quantity max_quantity cross_quote_price close_only quote_currency { precision } base_currency { precision } price { ask bid } lot_size step_size class margin_instrument_id is_trading_on market_status } } }","variables":{"pager":{"limit":50,"offset":0},"side":"buy","status":"open"}}'
import requests

url = "https://live-margin-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """query open_margin_orders($pager: PagerInput, $side: MarginPositionSide, $status: MarginOrderStatus) { open_margin_orders(pager: $pager, side: $side, status: $status) { margin_order_id margin_position_id instrument_id side type status leverage quantity price limit_price message created_at_timestamp stop_loss take_profit ask bid executed_quantity fee_amount time_in_force expires_at_iso updated_at_iso cross_quote_price wallet_id margin_instrument { base_currency_id quote_currency_id name min_leverage max_leverage min_quantity max_quantity cross_quote_price close_only quote_currency { precision } base_currency { precision } price { ask bid } lot_size step_size class margin_instrument_id is_trading_on market_status } } }""",
    "variables": {
        "pager": {
            "limit": 50,
            "offset": 0
        },
        "side": "buy",
        "status": "open"
    },
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-margin-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `query open_margin_orders($pager: PagerInput, $side: MarginPositionSide, $status: MarginOrderStatus) { open_margin_orders(pager: $pager, side: $side, status: $status) { margin_order_id margin_position_id instrument_id side type status leverage quantity price limit_price message created_at_timestamp stop_loss take_profit ask bid executed_quantity fee_amount time_in_force expires_at_iso updated_at_iso cross_quote_price wallet_id margin_instrument { base_currency_id quote_currency_id name min_leverage max_leverage min_quantity max_quantity cross_quote_price close_only quote_currency { precision } base_currency { precision } price { ask bid } lot_size step_size class margin_instrument_id is_trading_on market_status } } }`,
    variables: {
      "pager": {
        "limit": 50,
        "offset": 0
      },
      "side": "buy",
      "status": "open"
    },
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this
queryclosed_margin_ordersList completed / cancelled / rejected margin orders.
Endpoint: POST https://live-margin-api.ouinex.com/graphql
Type: Query
Returns: [MarginOrder!]!
Permission: closed_derivatives_orders
Rate limit: 100 requests / 60 s

Inputs

NameTypeRequiredDescription
searchStringoptionalSearch term.
pagerPagerInputoptional
default {limit: 30, offset: 0}
Pagination (limit, offset).
sortSortInputoptional
default {direction: ASC}
Sort order.
dateRangeDateRangeInputoptional
default {}
Filter by updated_at (format YYYY-MM-DD HH:mm:ss). Without time_from only the last 90 days are searched. A time_from older than 90 days queries the archive only, which does not include the last 90 days.
sideMarginPositionSideoptionalbuy or sell
statusMarginOrderStatusoptionalFilter by order status.
time_in_forceMarginOrderTimeInForceoptionalFilter by time in force.
typeMarginOrderTypeoptionalmarket or limit
instrument_idStringoptionalInstrument filter.
instruments_ids[String!]optionalMultiple instruments
wallet_idStringoptionalWallet filter.
currency_idStringoptionalFilter orders by base currency ID

Response

Fields of MarginOrder selected in the operation below.

FieldTypeDescription
margin_order_idString!Order ID
margin_position_idStringPosition the order belongs to.
instrument_idString!Instrument.
sideMarginPositionSide!Side (buy / sell).
typeMarginOrderType!Type.
statusMarginOrderStatus!Order status.
leverageInt!Leverage.
quantityFloat!Quantity.
priceFloatPrice.
limit_priceFloatLimit price.
messageStringStatus / rejection message.
created_at_timestampString!Creation time, Unix milliseconds.
stop_lossFloatStop-loss price.
take_profitFloatTake-profit price.
askFloatAsk price.
bidFloatBid price.
executed_quantityFloat!Amount actually filled
fee_amountFloatTrading fees
time_in_forceMarginOrderTimeInForce!Time in force.
expires_at_isoStringExpiry time (ISO 8601).
updated_at_isoString!Last update time (ISO 8601).
cross_quote_priceFloatConversion rate from the instrument's quote currency to the margin currency.
wallet_idStringWallet.
valueFloatTotal notional value
margin_instrumentMarginInstrumentInstrument details.

GraphQL Operation

query closed_margin_orders($pager: PagerInput, $status: MarginOrderStatus) {
  closed_margin_orders(pager: $pager, status: $status) {
    margin_order_id margin_position_id instrument_id side type status leverage quantity price limit_price message created_at_timestamp stop_loss take_profit ask bid executed_quantity fee_amount time_in_force expires_at_iso updated_at_iso cross_quote_price wallet_id value
    margin_instrument {
      base_currency_id quote_currency_id name min_leverage max_leverage min_quantity max_quantity cross_quote_price close_only
      quote_currency { precision }
      base_currency { precision }
      price { ask bid }
      lot_size step_size class margin_instrument_id is_trading_on market_status
    }
  }
}

Code Examples

curl -X POST 'https://live-margin-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"query closed_margin_orders($pager: PagerInput, $status: MarginOrderStatus) { closed_margin_orders(pager: $pager, status: $status) { margin_order_id margin_position_id instrument_id side type status leverage quantity price limit_price message created_at_timestamp stop_loss take_profit ask bid executed_quantity fee_amount time_in_force expires_at_iso updated_at_iso cross_quote_price wallet_id value margin_instrument { base_currency_id quote_currency_id name min_leverage max_leverage min_quantity max_quantity cross_quote_price close_only quote_currency { precision } base_currency { precision } price { ask bid } lot_size step_size class margin_instrument_id is_trading_on market_status } } }","variables":{"pager":{"limit":50,"offset":0},"status":"completed"}}'
import requests

url = "https://live-margin-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """query closed_margin_orders($pager: PagerInput, $status: MarginOrderStatus) { closed_margin_orders(pager: $pager, status: $status) { margin_order_id margin_position_id instrument_id side type status leverage quantity price limit_price message created_at_timestamp stop_loss take_profit ask bid executed_quantity fee_amount time_in_force expires_at_iso updated_at_iso cross_quote_price wallet_id value margin_instrument { base_currency_id quote_currency_id name min_leverage max_leverage min_quantity max_quantity cross_quote_price close_only quote_currency { precision } base_currency { precision } price { ask bid } lot_size step_size class margin_instrument_id is_trading_on market_status } } }""",
    "variables": {
        "pager": {
            "limit": 50,
            "offset": 0
        },
        "status": "completed"
    },
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-margin-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `query closed_margin_orders($pager: PagerInput, $status: MarginOrderStatus) { closed_margin_orders(pager: $pager, status: $status) { margin_order_id margin_position_id instrument_id side type status leverage quantity price limit_price message created_at_timestamp stop_loss take_profit ask bid executed_quantity fee_amount time_in_force expires_at_iso updated_at_iso cross_quote_price wallet_id value margin_instrument { base_currency_id quote_currency_id name min_leverage max_leverage min_quantity max_quantity cross_quote_price close_only quote_currency { precision } base_currency { precision } price { ask bid } lot_size step_size class margin_instrument_id is_trading_on market_status } } }`,
    variables: {
      "pager": {
        "limit": 50,
        "offset": 0
      },
      "status": "completed"
    },
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this
querymargin_orderOne derivatives order by id.
Endpoint: POST https://live-margin-api.ouinex.com/graphql
Type: Query
Returns: MarginOrder!

Inputs

NameTypeRequiredDescription
margin_order_idString!requiredOrder id.

Response

Fields of MarginOrder selected in the operation below.

FieldTypeDescription
margin_order_idString!
margin_position_idString
instrument_idString!
sideMarginPositionSide!
typeMarginOrderType!
statusMarginOrderStatus!
time_in_forceMarginOrderTimeInForce!
leverageInt!
quantityFloat!
executed_quantityFloat!
fee_amountFloat
priceFloat
limit_priceFloat
messageString
created_atString!
updated_atString!
created_at_timestampString!
updated_at_timestampString!
stop_lossFloat
take_profitFloat
take_profit_percentFloat
stop_loss_percentFloat
askFloat
bidFloat
expires_atString
cross_quote_priceFloat
wallet_idString
margin_currency_idString!
advanced_typeAdvancedOrderType
advanced_order_idString
originMarginOrigin
autoscale_tp_slBoolean!
valueFloat
created_at_isoString!
updated_at_isoString!
expires_at_isoString
durationString!
slippageString

GraphQL Operation

query margin_order($margin_order_id: String!) {
  margin_order(margin_order_id: $margin_order_id) { margin_order_id margin_position_id instrument_id side type status time_in_force leverage quantity executed_quantity fee_amount price limit_price message created_at updated_at created_at_timestamp updated_at_timestamp stop_loss take_profit take_profit_percent stop_loss_percent ask bid expires_at cross_quote_price wallet_id margin_currency_id advanced_type advanced_order_id origin autoscale_tp_sl value created_at_iso updated_at_iso expires_at_iso duration slippage }
}

Code Examples

curl -X POST 'https://live-margin-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"query margin_order($margin_order_id: String!) { margin_order(margin_order_id: $margin_order_id) { margin_order_id margin_position_id instrument_id side type status time_in_force leverage quantity executed_quantity fee_amount price limit_price message created_at updated_at created_at_timestamp updated_at_timestamp stop_loss take_profit take_profit_percent stop_loss_percent ask bid expires_at cross_quote_price wallet_id margin_currency_id advanced_type advanced_order_id origin autoscale_tp_sl value created_at_iso updated_at_iso expires_at_iso duration slippage } }","variables":{"margin_order_id":"order123"}}'
import requests

url = "https://live-margin-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """query margin_order($margin_order_id: String!) { margin_order(margin_order_id: $margin_order_id) { margin_order_id margin_position_id instrument_id side type status time_in_force leverage quantity executed_quantity fee_amount price limit_price message created_at updated_at created_at_timestamp updated_at_timestamp stop_loss take_profit take_profit_percent stop_loss_percent ask bid expires_at cross_quote_price wallet_id margin_currency_id advanced_type advanced_order_id origin autoscale_tp_sl value created_at_iso updated_at_iso expires_at_iso duration slippage } }""",
    "variables": {
        "margin_order_id": "order123"
    },
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-margin-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `query margin_order($margin_order_id: String!) { margin_order(margin_order_id: $margin_order_id) { margin_order_id margin_position_id instrument_id side type status time_in_force leverage quantity executed_quantity fee_amount price limit_price message created_at updated_at created_at_timestamp updated_at_timestamp stop_loss take_profit take_profit_percent stop_loss_percent ask bid expires_at cross_quote_price wallet_id margin_currency_id advanced_type advanced_order_id origin autoscale_tp_sl value created_at_iso updated_at_iso expires_at_iso duration slippage } }`,
    variables: {
      "margin_order_id": "order123"
    },
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this
querymargin_tradesList the user's derivatives trades (executions).
Endpoint: POST https://live-margin-api.ouinex.com/graphql
Type: Query
Returns: [MarginTrade!]!

Without dateRange only a short recent window is returned, with no error; pass dateRange: { time_from, time_to } (YYYY-MM-DD HH:mm:ss, at most 1 year per request) to read older history.

Inputs

NameTypeRequiredDescription
searchStringoptionalSearch term.
pagerPagerInputoptional
default {limit: 30, offset: 0}
Pagination (limit, offset).
sortSortInputoptional
default {direction: ASC}
Sort order.
dateRangeDateRangeInputoptional
default {}
Date range; see the note above.
sideMarginPositionSideoptionalSide filter.
typeMarginOrderTypeoptionalOrder type filter.
instrument_idStringoptionalDerivatives instrument ID (margin_instrument_id from margin_instruments).
instruments_ids[String!]optionalSeveral instruments.
wallet_idStringoptionalWallet filter.
margin_order_idStringoptionalOnly trades of this order.

Response

Fields of MarginTrade selected in the operation below.

FieldTypeDescription
margin_trade_idString!
margin_order_idString!
margin_position_idString
advanced_order_idString
wallet_idString
instrument_idString!
sideMarginPositionSide!
typeMarginOrderType!
quantityFloat!
priceFloat!
fee_amountFloat
margin_currency_idString!
askFloat!
bidFloat!
tsDateTime!
created_atDateTime!

GraphQL Operation

query margin_trades($dateRange: DateRangeInput, $wallet_id: String) {
  margin_trades(dateRange: $dateRange, wallet_id: $wallet_id) { margin_trade_id margin_order_id margin_position_id advanced_order_id wallet_id instrument_id side type quantity price fee_amount margin_currency_id ask bid ts created_at }
}

Code Examples

curl -X POST 'https://live-margin-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"query margin_trades($dateRange: DateRangeInput, $wallet_id: String) { margin_trades(dateRange: $dateRange, wallet_id: $wallet_id) { margin_trade_id margin_order_id margin_position_id advanced_order_id wallet_id instrument_id side type quantity price fee_amount margin_currency_id ask bid ts created_at } }","variables":{"wallet_id":"MAIN","dateRange":{"time_from":"2026-09-01 00:00:00","time_to":"2026-10-01 00:00:00"}}}'
import requests

url = "https://live-margin-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """query margin_trades($dateRange: DateRangeInput, $wallet_id: String) { margin_trades(dateRange: $dateRange, wallet_id: $wallet_id) { margin_trade_id margin_order_id margin_position_id advanced_order_id wallet_id instrument_id side type quantity price fee_amount margin_currency_id ask bid ts created_at } }""",
    "variables": {
        "wallet_id": "MAIN",
        "dateRange": {
            "time_from": "2026-09-01 00:00:00",
            "time_to": "2026-10-01 00:00:00"
        }
    },
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-margin-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `query margin_trades($dateRange: DateRangeInput, $wallet_id: String) { margin_trades(dateRange: $dateRange, wallet_id: $wallet_id) { margin_trade_id margin_order_id margin_position_id advanced_order_id wallet_id instrument_id side type quantity price fee_amount margin_currency_id ask bid ts created_at } }`,
    variables: {
      "wallet_id": "MAIN",
      "dateRange": {
        "time_from": "2026-09-01 00:00:00",
        "time_to": "2026-10-01 00:00:00"
      }
    },
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this
mutationcreate_margin_orderPlace a margin order.
Endpoint: POST https://live-margin-api.ouinex.com/graphql
Type: Mutation
Returns: MarginOrder!
Permission: create_derivatives_order

Inputs

NameTypeRequiredDescription
instrument_idString!requiredInstrument ID.
sideMarginPositionSide!requiredbuy (long) or sell (short).
typeMarginOrderType!requiredmarket or limit
leverageInt!requiredLeverage multiplier
quantityFloat!requiredOrder size
priceFloatoptionalLimit price (required for limit orders)
stop_lossFloatoptionalStop loss trigger price
take_profitFloatoptionalTake profit target price
take_profit_percentFloatoptionalTake-profit as a fraction, resolved at fill. Use one TP mode per order: scalar, percent or array.
stop_loss_percentFloatoptionalStop-loss as a fraction, resolved at fill. Use one SL mode per order: scalar, percent or array.
wallet_idStringoptionalWallet to trade from. Defaults to MAIN.
time_in_forceMarginOrderTimeInForceoptionalOptional. When omitted: ioc for market, gtc for limit. limit also accepts gtd (requires expires_at).
expires_atStringoptionalRequired when time_in_force is gtd.
all_inToggleSwitchoptionalSize the margin reservation for a non-limit order from the maximum available margin.
take_profits[TakeProfitInput!]optionalMulti-level take-profits (price, quantity per level).
stop_losses[StopLossInput!]optionalMulti-level stop-losses (price, quantity per level).
autoscale_tp_slBooleanoptionalScale the TP/SL level quantities with the position size.
stop_presetOrderStopPresetInputoptionalStop preset (break_even / stop_win) activated when the order fills.
trailing_presetOrderTrailingPresetInputoptionalTrailing stop activated when the order fills: retracement_type with callback_rate (0.01–50%) or callback_distance, optional activation_price.

Response

Fields of MarginOrder selected in the operation below.

FieldTypeDescription
margin_order_idString!ID of the created order
margin_position_idStringPosition the order belongs to.
instrument_idString!Instrument.
sideMarginPositionSide!Side (buy / sell).
typeMarginOrderType!Type.
statusMarginOrderStatus!Status.
time_in_forceMarginOrderTimeInForce!Time in force.
leverageInt!Leverage.
quantityFloat!Quantity.
priceFloatPrice.
created_at_timestampString!Creation time, Unix milliseconds.

GraphQL Operation

mutation create_margin_order($instrument_id: String!, $side: MarginPositionSide!, $type: MarginOrderType!, $leverage: Int!, $quantity: Float!) {
  create_margin_order(instrument_id: $instrument_id, side: $side, type: $type, leverage: $leverage, quantity: $quantity) {
    margin_order_id margin_position_id instrument_id side type status time_in_force leverage quantity price created_at_timestamp
  }
}

Code Examples

curl -X POST 'https://live-margin-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"mutation create_margin_order($instrument_id: String!, $side: MarginPositionSide!, $type: MarginOrderType!, $leverage: Int!, $quantity: Float!) { create_margin_order(instrument_id: $instrument_id, side: $side, type: $type, leverage: $leverage, quantity: $quantity) { margin_order_id margin_position_id instrument_id side type status time_in_force leverage quantity price created_at_timestamp } }","variables":{"instrument_id":"BTCUSD","side":"buy","type":"market","leverage":10,"quantity":1}}'
import requests

url = "https://live-margin-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """mutation create_margin_order($instrument_id: String!, $side: MarginPositionSide!, $type: MarginOrderType!, $leverage: Int!, $quantity: Float!) { create_margin_order(instrument_id: $instrument_id, side: $side, type: $type, leverage: $leverage, quantity: $quantity) { margin_order_id margin_position_id instrument_id side type status time_in_force leverage quantity price created_at_timestamp } }""",
    "variables": {
        "instrument_id": "BTCUSD",
        "side": "buy",
        "type": "market",
        "leverage": 10,
        "quantity": 1
    },
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-margin-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `mutation create_margin_order($instrument_id: String!, $side: MarginPositionSide!, $type: MarginOrderType!, $leverage: Int!, $quantity: Float!) { create_margin_order(instrument_id: $instrument_id, side: $side, type: $type, leverage: $leverage, quantity: $quantity) { margin_order_id margin_position_id instrument_id side type status time_in_force leverage quantity price created_at_timestamp } }`,
    variables: {
      "instrument_id": "BTCUSD",
      "side": "buy",
      "type": "market",
      "leverage": 10,
      "quantity": 1
    },
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this
mutationcancel_margin_orderCancel an open margin limit order.
Endpoint: POST https://live-margin-api.ouinex.com/graphql
Type: Mutation
Returns: Boolean!
Permission: cancel_derivatives_order

Only limit orders can be cancelled.

Inputs

NameTypeRequiredDescription
margin_order_idString!requiredOrder ID to cancel

GraphQL Operation

mutation cancel_margin_order($margin_order_id: String!) {
  cancel_margin_order(margin_order_id: $margin_order_id)
}

Code Examples

curl -X POST 'https://live-margin-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"mutation cancel_margin_order($margin_order_id: String!) { cancel_margin_order(margin_order_id: $margin_order_id) }","variables":{"margin_order_id":"order123"}}'
import requests

url = "https://live-margin-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """mutation cancel_margin_order($margin_order_id: String!) { cancel_margin_order(margin_order_id: $margin_order_id) }""",
    "variables": {
        "margin_order_id": "order123"
    },
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-margin-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `mutation cancel_margin_order($margin_order_id: String!) { cancel_margin_order(margin_order_id: $margin_order_id) }`,
    variables: {
      "margin_order_id": "order123"
    },
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this
mutationcancel_all_margin_ordersCancel all open margin limit orders in a wallet.
Endpoint: POST https://live-margin-api.ouinex.com/graphql
Type: Mutation
Returns: Boolean!
Permission: cancel_derivatives_order

Cancels open limit orders (status open / execution_ready) of the authenticated user in the given wallet.

Inputs

NameTypeRequiredDescription
wallet_idStringoptionalWallet whose open limit orders are cancelled. Defaults to MAIN.

GraphQL Operation

mutation cancel_all_margin_orders($wallet_id: String) {
  cancel_all_margin_orders(wallet_id: $wallet_id)
}

Code Examples

curl -X POST 'https://live-margin-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"mutation cancel_all_margin_orders($wallet_id: String) { cancel_all_margin_orders(wallet_id: $wallet_id) }","variables":{"wallet_id":"MAIN"}}'
import requests

url = "https://live-margin-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """mutation cancel_all_margin_orders($wallet_id: String) { cancel_all_margin_orders(wallet_id: $wallet_id) }""",
    "variables": {
        "wallet_id": "MAIN"
    },
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-margin-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `mutation cancel_all_margin_orders($wallet_id: String) { cancel_all_margin_orders(wallet_id: $wallet_id) }`,
    variables: {
      "wallet_id": "MAIN"
    },
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this
mutationedit_margin_orderAmend an open (pending) derivatives order.
Endpoint: POST https://live-margin-api.ouinex.com/graphql
Type: Mutation
Returns: Boolean!

leverage and quantity are required: restate them when only the price or TP/SL changes.

Inputs

NameTypeRequiredDescription
margin_order_idString!requiredOrder to amend.
leverageInt!requiredLeverage (required).
quantityFloat!requiredQuantity (required).
priceFloatoptionalNew limit price.
stop_lossFloatoptionalSingle stop-loss price.
take_profitFloatoptionalSingle take-profit price.
expires_atStringoptionalNew expiry for gtd orders.
take_profits[TakeProfitInput!]optionalSeveral take-profit levels, each { price, quantity }.
stop_losses[StopLossInput!]optionalSeveral stop-loss levels, each { price, quantity }.
autoscale_tp_slBooleanoptionalScale the TP/SL level quantities with the position size.

GraphQL Operation

mutation edit_margin_order($margin_order_id: String!, $leverage: Int!, $quantity: Float!, $price: Float) {
  edit_margin_order(margin_order_id: $margin_order_id, leverage: $leverage, quantity: $quantity, price: $price)
}

Code Examples

curl -X POST 'https://live-margin-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"mutation edit_margin_order($margin_order_id: String!, $leverage: Int!, $quantity: Float!, $price: Float) { edit_margin_order(margin_order_id: $margin_order_id, leverage: $leverage, quantity: $quantity, price: $price) }","variables":{"margin_order_id":"order123","leverage":10,"quantity":0.1,"price":60500}}'
import requests

url = "https://live-margin-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """mutation edit_margin_order($margin_order_id: String!, $leverage: Int!, $quantity: Float!, $price: Float) { edit_margin_order(margin_order_id: $margin_order_id, leverage: $leverage, quantity: $quantity, price: $price) }""",
    "variables": {
        "margin_order_id": "order123",
        "leverage": 10,
        "quantity": 0.1,
        "price": 60500
    },
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-margin-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `mutation edit_margin_order($margin_order_id: String!, $leverage: Int!, $quantity: Float!, $price: Float) { edit_margin_order(margin_order_id: $margin_order_id, leverage: $leverage, quantity: $quantity, price: $price) }`,
    variables: {
      "margin_order_id": "order123",
      "leverage": 10,
      "quantity": 0.1,
      "price": 60500
    },
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this
queryestimate_margin_user_positionPreview required margin, fees and size limits before placing a margin order.
Endpoint: POST https://live-margin-api.ouinex.com/graphql
Type: Query
Returns: MarginOrderEstimation!
Permission: estimate_derivatives_order

Inputs

NameTypeRequiredDescription
instrument_idString!requiredInstrument ID.
sideMarginPositionSide!requiredbuy (long) or sell (short).
leverageInt!requiredLeverage.
quantityFloat!requiredPosition size to estimate
limit_priceFloatoptionalTarget entry price for limit orders
wallet_idStringoptionalWallet filter.
use_cached_priceToggleSwitchoptionalWith on, the last known price is used instead of a fresh quote.
all_inToggleSwitchoptionalWith on, quantity is replaced by the maximum the user's margin allows.

Response

Fields of MarginOrderEstimation selected in the operation below.

FieldTypeDescription
order_required_marginFloat!Margin needed to place order
feeFloat!Total trading fee
order_available_marginFloat!Available margin after trade
order_valueFloat!Notional order value
max_position_size_baseFloat!Maximum position size allowed
min_position_size_baseFloat!Minimum position size in base currency.
fees_breakdown[MarginOrderFee!]!Fee components.

GraphQL Operation

query estimate_margin_user_position($instrument_id: String!, $side: MarginPositionSide!, $leverage: Int!, $quantity: Float!) {
  estimate_margin_user_position(instrument_id: $instrument_id, side: $side, leverage: $leverage, quantity: $quantity) {
    order_required_margin fee order_available_margin order_value max_position_size_base min_position_size_base
    fees_breakdown { fee value source }
  }
}

Code Examples

curl -X POST 'https://live-margin-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"query estimate_margin_user_position($instrument_id: String!, $side: MarginPositionSide!, $leverage: Int!, $quantity: Float!) { estimate_margin_user_position(instrument_id: $instrument_id, side: $side, leverage: $leverage, quantity: $quantity) { order_required_margin fee order_available_margin order_value max_position_size_base min_position_size_base fees_breakdown { fee value source } } }","variables":{"instrument_id":"BTCUSD","side":"buy","leverage":10,"quantity":1}}'
import requests

url = "https://live-margin-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """query estimate_margin_user_position($instrument_id: String!, $side: MarginPositionSide!, $leverage: Int!, $quantity: Float!) { estimate_margin_user_position(instrument_id: $instrument_id, side: $side, leverage: $leverage, quantity: $quantity) { order_required_margin fee order_available_margin order_value max_position_size_base min_position_size_base fees_breakdown { fee value source } } }""",
    "variables": {
        "instrument_id": "BTCUSD",
        "side": "buy",
        "leverage": 10,
        "quantity": 1
    },
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-margin-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `query estimate_margin_user_position($instrument_id: String!, $side: MarginPositionSide!, $leverage: Int!, $quantity: Float!) { estimate_margin_user_position(instrument_id: $instrument_id, side: $side, leverage: $leverage, quantity: $quantity) { order_required_margin fee order_available_margin order_value max_position_size_base min_position_size_base fees_breakdown { fee value source } } }`,
    variables: {
      "instrument_id": "BTCUSD",
      "side": "buy",
      "leverage": 10,
      "quantity": 1
    },
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this
queryestimate_liquidation_priceEstimated liquidation price for an order before placing it (regular and advanced types).
Endpoint: POST https://live-margin-api.ouinex.com/graphql
Type: Query
Returns: LiquidationEstimate!

A null price means no estimate is available (see unavailable_reason). OCO returns one leg per side.

Inputs

NameTypeRequiredDescription
wallet_idStringoptionalWallet to act on; defaults to MAIN.
instrument_idString!requiredDerivatives instrument ID (margin_instrument_id from margin_instruments).
sideMarginPositionSide!requiredOrder side.
leverageInt!requiredLeverage.
quantityFloat!requiredQuantity.
kindLiquidationEstimateOrderKind!requiredOrder kind being estimated.
limit_priceFloatoptionalLimit price (limit, stop limit).
trigger_priceFloatoptionalTrigger price (stop types).
slices_config[ScaledOrderSliceConfigInput!]optionalScaled: the slices.
iceberg_placement_typeIcebergPlacementTypeoptionalIceberg: placement type.
tp_trigger_priceFloatoptionalOCO: take-profit trigger.
tp_order_typeMarginOrderTypeoptionalOCO: take-profit leg type.
tp_limit_priceFloatoptionalOCO: take-profit limit price.
sl_trigger_priceFloatoptionalOCO: stop-loss trigger.
sl_order_typeMarginOrderTypeoptionalOCO: stop-loss leg type.
sl_limit_priceFloatoptionalOCO: stop-loss limit price.
primary_order_typeMarginOrderTypeoptionalOTO: primary order type.
primary_priceFloatoptionalOTO: primary price.
primary_quantityFloatoptionalOTO: primary quantity.
use_cached_priceToggleSwitchoptionalUse the last cached market price instead of a fresh one.

Response

Fields of LiquidationEstimate selected in the operation below.

FieldTypeDescription
estimated_liquidation_priceFloatConvenience copy of legs[0].estimated_liquidation_price. Null for OCO — use legs.
unavailable_reasonLiquidationEstimateUnavailableReason
disclaimers[LiquidationEstimateDisclaimer!]!Codes for the (i) tooltip. Always includes indicative when a price is present.

GraphQL Operation

query estimate_liquidation_price($instrument_id: String!, $side: MarginPositionSide!, $leverage: Int!, $quantity: Float!, $kind: LiquidationEstimateOrderKind!) {
  estimate_liquidation_price(instrument_id: $instrument_id, side: $side, leverage: $leverage, quantity: $quantity, kind: $kind) { estimated_liquidation_price unavailable_reason disclaimers }
}

Code Examples

curl -X POST 'https://live-margin-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"query estimate_liquidation_price($instrument_id: String!, $side: MarginPositionSide!, $leverage: Int!, $quantity: Float!, $kind: LiquidationEstimateOrderKind!) { estimate_liquidation_price(instrument_id: $instrument_id, side: $side, leverage: $leverage, quantity: $quantity, kind: $kind) { estimated_liquidation_price unavailable_reason disclaimers } }","variables":{"instrument_id":"BTCUSD","side":"buy","leverage":10,"quantity":0.1,"kind":"market"}}'
import requests

url = "https://live-margin-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """query estimate_liquidation_price($instrument_id: String!, $side: MarginPositionSide!, $leverage: Int!, $quantity: Float!, $kind: LiquidationEstimateOrderKind!) { estimate_liquidation_price(instrument_id: $instrument_id, side: $side, leverage: $leverage, quantity: $quantity, kind: $kind) { estimated_liquidation_price unavailable_reason disclaimers } }""",
    "variables": {
        "instrument_id": "BTCUSD",
        "side": "buy",
        "leverage": 10,
        "quantity": 0.1,
        "kind": "market"
    },
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-margin-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `query estimate_liquidation_price($instrument_id: String!, $side: MarginPositionSide!, $leverage: Int!, $quantity: Float!, $kind: LiquidationEstimateOrderKind!) { estimate_liquidation_price(instrument_id: $instrument_id, side: $side, leverage: $leverage, quantity: $quantity, kind: $kind) { estimated_liquidation_price unavailable_reason disclaimers } }`,
    variables: {
      "instrument_id": "BTCUSD",
      "side": "buy",
      "leverage": 10,
      "quantity": 0.1,
      "kind": "market"
    },
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this
queryopen_margin_positionsList currently open margin positions.
Endpoint: POST https://live-margin-api.ouinex.com/graphql
Type: Query
Returns: [MarginPosition!]!
Permission: open_derivatives_positions
Rate limit: 100 requests / 60 s

Inputs

NameTypeRequiredDescription
searchStringoptionalSearch term.
pagerPagerInputoptional
default {limit: 30, offset: 0}
Pagination (limit, offset).
sortSortInputoptional
default {direction: ASC}
Sort order.
dateRangeDateRangeInputoptional
default {}
Filter by start_ts (format YYYY-MM-DD HH:mm:ss).
sideMarginPositionSideoptionalbuy or sell.
instrument_idStringoptionalInstrument filter.
instruments_ids[String!]optionalMultiple instruments
wallet_idStringoptionalWallet filter.

Response

Fields of MarginPosition selected in the operation below.

FieldTypeDescription
margin_position_idString!Position unique ID
instrument_idString!Instrument.
sideMarginPositionSide!buy (long) or sell (short).
leverageInt!Current leverage
amountFloat!Position size in base asset
valueFloatPosition value.
funding_fee_amountFloat!Accrued funding fees
entry_priceFloat!Average entry price
start_price_tsString!Price timestamp at open.
end_price_tsStringPrice timestamp at close.
start_ask_priceFloat!Ask price at open.
start_bid_priceFloat!Bid price at open.
durationString!Position duration.
end_ask_priceFloatAsk price at close.
pnlFloat!Unrealized P&L
stop_lossFloatStop-loss price.
take_profitFloatTake-profit price.
start_ts_timestampString!Open time, Unix milliseconds.
close_reasonStringClose reason.
updated_at_isoString!Last update time (ISO 8601).
wallet_idStringWallet.
margin_currency_idString!Margin currency.
exit_priceFloatExit price.
marginFloatMargin.
total_pnlFloat!Total P&L.
cross_quote_priceFloat!Conversion rate from the instrument's quote currency to the margin currency.
end_bid_priceFloatBid price at close.
close_reason_codeStringClose reason code.
margin_instrumentMarginInstrumentInstrument details.

GraphQL Operation

query open_margin_positions($pager: PagerInput) {
  open_margin_positions(pager: $pager) {
    margin_position_id instrument_id side leverage amount value funding_fee_amount entry_price start_price_ts end_price_ts start_ask_price start_bid_price duration end_ask_price pnl stop_loss take_profit start_ts_timestamp close_reason updated_at_iso wallet_id margin_currency_id exit_price margin total_pnl cross_quote_price end_bid_price close_reason_code
    margin_instrument {
      base_currency_id quote_currency_id name min_quantity min_leverage max_leverage is_trading_on class margin_instrument_id market_status cross_quote_price close_only
      quote_currency { precision }
      base_currency { precision }
      price { ask bid }
      lot_size step_size
    }
  }
}

Code Examples

curl -X POST 'https://live-margin-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"query open_margin_positions($pager: PagerInput) { open_margin_positions(pager: $pager) { margin_position_id instrument_id side leverage amount value funding_fee_amount entry_price start_price_ts end_price_ts start_ask_price start_bid_price duration end_ask_price pnl stop_loss take_profit start_ts_timestamp close_reason updated_at_iso wallet_id margin_currency_id exit_price margin total_pnl cross_quote_price end_bid_price close_reason_code margin_instrument { base_currency_id quote_currency_id name min_quantity min_leverage max_leverage is_trading_on class margin_instrument_id market_status cross_quote_price close_only quote_currency { precision } base_currency { precision } price { ask bid } lot_size step_size } } }","variables":{"pager":{"limit":50,"offset":0}}}'
import requests

url = "https://live-margin-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """query open_margin_positions($pager: PagerInput) { open_margin_positions(pager: $pager) { margin_position_id instrument_id side leverage amount value funding_fee_amount entry_price start_price_ts end_price_ts start_ask_price start_bid_price duration end_ask_price pnl stop_loss take_profit start_ts_timestamp close_reason updated_at_iso wallet_id margin_currency_id exit_price margin total_pnl cross_quote_price end_bid_price close_reason_code margin_instrument { base_currency_id quote_currency_id name min_quantity min_leverage max_leverage is_trading_on class margin_instrument_id market_status cross_quote_price close_only quote_currency { precision } base_currency { precision } price { ask bid } lot_size step_size } } }""",
    "variables": {
        "pager": {
            "limit": 50,
            "offset": 0
        }
    },
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-margin-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `query open_margin_positions($pager: PagerInput) { open_margin_positions(pager: $pager) { margin_position_id instrument_id side leverage amount value funding_fee_amount entry_price start_price_ts end_price_ts start_ask_price start_bid_price duration end_ask_price pnl stop_loss take_profit start_ts_timestamp close_reason updated_at_iso wallet_id margin_currency_id exit_price margin total_pnl cross_quote_price end_bid_price close_reason_code margin_instrument { base_currency_id quote_currency_id name min_quantity min_leverage max_leverage is_trading_on class margin_instrument_id market_status cross_quote_price close_only quote_currency { precision } base_currency { precision } price { ask bid } lot_size step_size } } }`,
    variables: {
      "pager": {
        "limit": 50,
        "offset": 0
      }
    },
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this
queryclosed_margin_positionsList closed margin positions.
Endpoint: POST https://live-margin-api.ouinex.com/graphql
Type: Query
Returns: [MarginPosition!]!
Permission: closed_derivatives_positions

Inputs

NameTypeRequiredDescription
searchStringoptionalSearch term.
pagerPagerInputoptional
default {limit: 30, offset: 0}
Pagination (limit, offset).
sortSortInputoptional
default {direction: ASC}
Sort order.
dateRangeDateRangeInputoptional
default {}
Filter by end_ts (format YYYY-MM-DD HH:mm:ss). Without time_from only the last 90 days are searched. A time_from older than 90 days queries the archive only, which does not include the last 90 days.
sideMarginPositionSideoptionalbuy or sell.
instrument_idStringoptionalInstrument filter.
instruments_ids[String!]optionalMultiple instruments
wallet_idStringoptionalWallet filter.

Response

Fields of MarginPosition selected in the operation below.

FieldTypeDescription
margin_position_idString!Position ID
instrument_idString!Instrument.
sideMarginPositionSide!Side (buy / sell).
leverageInt!Leverage.
amountFloat!Amount.
valueFloatPosition value.
funding_fee_amountFloat!Accumulated funding / financing fees.
entry_priceFloat!Entry price.
start_price_tsString!Price timestamp at open.
end_price_tsStringPrice timestamp at close.
start_ask_priceFloat!Ask price at open.
start_bid_priceFloat!Bid price at open.
durationString!Position duration.
end_ask_priceFloatAsk price at close.
pnlFloat!Realized P&L
stop_lossFloatStop-loss price.
take_profitFloatTake-profit price.
start_ts_timestampString!Open time, Unix milliseconds.
close_reasonStringWhy position closed
updated_at_isoString!Last update time (ISO 8601).
wallet_idStringWallet.
margin_currency_idString!Margin currency.
exit_priceFloatClosing price
marginFloatMargin.
total_pnlFloat!Total P&L.
cross_quote_priceFloat!Conversion rate from the instrument's quote currency to the margin currency.
end_bid_priceFloatBid price at close.
close_reason_codeStringClose reason code.
end_ts_isoStringClose timestamp
margin_instrumentMarginInstrumentInstrument details.

GraphQL Operation

query closed_margin_positions($pager: PagerInput) {
  closed_margin_positions(pager: $pager) {
    margin_position_id instrument_id side leverage amount value funding_fee_amount entry_price start_price_ts end_price_ts start_ask_price start_bid_price duration end_ask_price pnl stop_loss take_profit start_ts_timestamp close_reason updated_at_iso wallet_id margin_currency_id exit_price margin total_pnl cross_quote_price end_bid_price close_reason_code end_ts_iso
    margin_instrument {
      base_currency_id quote_currency_id name min_quantity min_leverage max_leverage is_trading_on class margin_instrument_id market_status cross_quote_price close_only
      quote_currency { precision }
      base_currency { precision }
      price { ask bid }
      lot_size step_size
    }
  }
}

Code Examples

curl -X POST 'https://live-margin-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"query closed_margin_positions($pager: PagerInput) { closed_margin_positions(pager: $pager) { margin_position_id instrument_id side leverage amount value funding_fee_amount entry_price start_price_ts end_price_ts start_ask_price start_bid_price duration end_ask_price pnl stop_loss take_profit start_ts_timestamp close_reason updated_at_iso wallet_id margin_currency_id exit_price margin total_pnl cross_quote_price end_bid_price close_reason_code end_ts_iso margin_instrument { base_currency_id quote_currency_id name min_quantity min_leverage max_leverage is_trading_on class margin_instrument_id market_status cross_quote_price close_only quote_currency { precision } base_currency { precision } price { ask bid } lot_size step_size } } }","variables":{"pager":{"limit":50,"offset":0}}}'
import requests

url = "https://live-margin-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """query closed_margin_positions($pager: PagerInput) { closed_margin_positions(pager: $pager) { margin_position_id instrument_id side leverage amount value funding_fee_amount entry_price start_price_ts end_price_ts start_ask_price start_bid_price duration end_ask_price pnl stop_loss take_profit start_ts_timestamp close_reason updated_at_iso wallet_id margin_currency_id exit_price margin total_pnl cross_quote_price end_bid_price close_reason_code end_ts_iso margin_instrument { base_currency_id quote_currency_id name min_quantity min_leverage max_leverage is_trading_on class margin_instrument_id market_status cross_quote_price close_only quote_currency { precision } base_currency { precision } price { ask bid } lot_size step_size } } }""",
    "variables": {
        "pager": {
            "limit": 50,
            "offset": 0
        }
    },
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-margin-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `query closed_margin_positions($pager: PagerInput) { closed_margin_positions(pager: $pager) { margin_position_id instrument_id side leverage amount value funding_fee_amount entry_price start_price_ts end_price_ts start_ask_price start_bid_price duration end_ask_price pnl stop_loss take_profit start_ts_timestamp close_reason updated_at_iso wallet_id margin_currency_id exit_price margin total_pnl cross_quote_price end_bid_price close_reason_code end_ts_iso margin_instrument { base_currency_id quote_currency_id name min_quantity min_leverage max_leverage is_trading_on class margin_instrument_id market_status cross_quote_price close_only quote_currency { precision } base_currency { precision } price { ask bid } lot_size step_size } } }`,
    variables: {
      "pager": {
        "limit": 50,
        "offset": 0
      }
    },
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this
mutationupdate_open_margin_positionChange leverage and take-profit / stop-loss on an open position.
Endpoint: POST https://live-margin-api.ouinex.com/graphql
Type: Mutation
Returns: MarginPosition!
Permission: update_open_derivatives_position

Inputs

NameTypeRequiredDescription
margin_position_idString!requiredPosition ID to update
leverageInt!requiredRequired. To change only take-profit / stop-loss, send the position's current leverage; a different value changes the position leverage.
stop_lossFloatoptionalStop-loss price; send null to clear, omit to leave unchanged.
take_profitFloatoptionalTake-profit price; send null to clear, omit to leave unchanged.
take_profits[TakeProfitInput!]optionalMulti-level take-profits; an empty array clears them.
stop_losses[StopLossInput!]optionalMulti-level stop-losses; an empty array clears them.

Response

Fields of MarginPosition selected in the operation below.

FieldTypeDescription
margin_position_idString!Updated position ID
instrument_idString!Instrument.
sideMarginPositionSide!Side (buy / sell).
leverageInt!Leverage.
amountFloat!Amount.
stop_lossFloatStop-loss price.
take_profitFloatTake-profit price.

GraphQL Operation

mutation update_open_margin_position($margin_position_id: String!, $leverage: Int!, $stop_loss: Float, $take_profit: Float) {
  update_open_margin_position(margin_position_id: $margin_position_id, leverage: $leverage, stop_loss: $stop_loss, take_profit: $take_profit) {
    margin_position_id instrument_id side leverage amount stop_loss take_profit
  }
}

Code Examples

curl -X POST 'https://live-margin-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"mutation update_open_margin_position($margin_position_id: String!, $leverage: Int!, $stop_loss: Float, $take_profit: Float) { update_open_margin_position(margin_position_id: $margin_position_id, leverage: $leverage, stop_loss: $stop_loss, take_profit: $take_profit) { margin_position_id instrument_id side leverage amount stop_loss take_profit } }","variables":{"margin_position_id":"pos123","leverage":15,"stop_loss":40000,"take_profit":45000}}'
import requests

url = "https://live-margin-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """mutation update_open_margin_position($margin_position_id: String!, $leverage: Int!, $stop_loss: Float, $take_profit: Float) { update_open_margin_position(margin_position_id: $margin_position_id, leverage: $leverage, stop_loss: $stop_loss, take_profit: $take_profit) { margin_position_id instrument_id side leverage amount stop_loss take_profit } }""",
    "variables": {
        "margin_position_id": "pos123",
        "leverage": 15,
        "stop_loss": 40000,
        "take_profit": 45000
    },
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-margin-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `mutation update_open_margin_position($margin_position_id: String!, $leverage: Int!, $stop_loss: Float, $take_profit: Float) { update_open_margin_position(margin_position_id: $margin_position_id, leverage: $leverage, stop_loss: $stop_loss, take_profit: $take_profit) { margin_position_id instrument_id side leverage amount stop_loss take_profit } }`,
    variables: {
      "margin_position_id": "pos123",
      "leverage": 15,
      "stop_loss": 40000,
      "take_profit": 45000
    },
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this
mutationclose_margin_positionClose an open margin position, fully or partially.
Endpoint: POST https://live-margin-api.ouinex.com/graphql
Type: Mutation
Returns: Boolean!
Permission: create_derivatives_order

Inputs

NameTypeRequiredDescription
margin_position_idString!requiredPosition to close.
wallet_idStringoptional
default "MAIN"
Wallet holding the position. Defaults to MAIN.
percentagePercentageoptional
default percent100
Portion to close. Defaults to percent100. Use custom together with amount.
amountFloatoptionalQuantity (base) to close; takes precedence over percentage. Must not exceed the position size.

GraphQL Operation

mutation close_margin_position($margin_position_id: String!, $percentage: Percentage) {
  close_margin_position(margin_position_id: $margin_position_id, percentage: $percentage)
}

Code Examples

curl -X POST 'https://live-margin-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"mutation close_margin_position($margin_position_id: String!, $percentage: Percentage) { close_margin_position(margin_position_id: $margin_position_id, percentage: $percentage) }","variables":{"margin_position_id":"pos123","percentage":"percent100"}}'
import requests

url = "https://live-margin-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """mutation close_margin_position($margin_position_id: String!, $percentage: Percentage) { close_margin_position(margin_position_id: $margin_position_id, percentage: $percentage) }""",
    "variables": {
        "margin_position_id": "pos123",
        "percentage": "percent100"
    },
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-margin-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `mutation close_margin_position($margin_position_id: String!, $percentage: Percentage) { close_margin_position(margin_position_id: $margin_position_id, percentage: $percentage) }`,
    variables: {
      "margin_position_id": "pos123",
      "percentage": "percent100"
    },
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this
mutationclose_all_margin_positionsClose every open margin position in a wallet.
Endpoint: POST https://live-margin-api.ouinex.com/graphql
Type: Mutation
Returns: Boolean!
Permission: create_derivatives_order

Closes every open position of the authenticated user in the given wallet, in full.

Inputs

NameTypeRequiredDescription
wallet_idStringoptional
default "MAIN"
Wallet whose open positions are closed. Defaults to MAIN.

GraphQL Operation

mutation close_all_margin_positions($wallet_id: String) {
  close_all_margin_positions(wallet_id: $wallet_id)
}

Code Examples

curl -X POST 'https://live-margin-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"mutation close_all_margin_positions($wallet_id: String) { close_all_margin_positions(wallet_id: $wallet_id) }","variables":{"wallet_id":"MAIN"}}'
import requests

url = "https://live-margin-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """mutation close_all_margin_positions($wallet_id: String) { close_all_margin_positions(wallet_id: $wallet_id) }""",
    "variables": {
        "wallet_id": "MAIN"
    },
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-margin-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `mutation close_all_margin_positions($wallet_id: String) { close_all_margin_positions(wallet_id: $wallet_id) }`,
    variables: {
      "wallet_id": "MAIN"
    },
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this
mutationset_stop_presetSet a break-even or stop-win preset on an open position (replaces any existing one).
Endpoint: POST https://live-margin-api.ouinex.com/graphql
Type: Mutation
Returns: MarginPositionStopPreset!

When the price reaches trigger_price, the position's stop loss moves to its entry price (break_even) or to target_sl_price (stop_win).

Inputs

NameTypeRequiredDescription
margin_position_idString!requiredPosition.
preset_typeStopPresetType!requiredbreak_even or stop_win.
trigger_priceFloat!requiredPrice that activates the preset.
target_sl_priceFloatoptionalNew stop-loss price (stop_win).

Response

Fields of MarginPositionStopPreset selected in the operation below.

FieldTypeDescription
preset_idString!
margin_position_idString
order_idStringSet for presets configured at order creation, before the position exists
instrument_idString!
preset_typeStopPresetType!
statusStopPresetStatus!
trigger_priceFloat!
target_sl_priceFloat
created_atString!
updated_atString!

GraphQL Operation

mutation set_stop_preset($margin_position_id: String!, $preset_type: StopPresetType!, $trigger_price: Float!) {
  set_stop_preset(margin_position_id: $margin_position_id, preset_type: $preset_type, trigger_price: $trigger_price) { preset_id margin_position_id order_id instrument_id preset_type status trigger_price target_sl_price created_at updated_at }
}

Code Examples

curl -X POST 'https://live-margin-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"mutation set_stop_preset($margin_position_id: String!, $preset_type: StopPresetType!, $trigger_price: Float!) { set_stop_preset(margin_position_id: $margin_position_id, preset_type: $preset_type, trigger_price: $trigger_price) { preset_id margin_position_id order_id instrument_id preset_type status trigger_price target_sl_price created_at updated_at } }","variables":{"margin_position_id":"pos123","preset_type":"break_even","trigger_price":62000}}'
import requests

url = "https://live-margin-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """mutation set_stop_preset($margin_position_id: String!, $preset_type: StopPresetType!, $trigger_price: Float!) { set_stop_preset(margin_position_id: $margin_position_id, preset_type: $preset_type, trigger_price: $trigger_price) { preset_id margin_position_id order_id instrument_id preset_type status trigger_price target_sl_price created_at updated_at } }""",
    "variables": {
        "margin_position_id": "pos123",
        "preset_type": "break_even",
        "trigger_price": 62000
    },
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-margin-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `mutation set_stop_preset($margin_position_id: String!, $preset_type: StopPresetType!, $trigger_price: Float!) { set_stop_preset(margin_position_id: $margin_position_id, preset_type: $preset_type, trigger_price: $trigger_price) { preset_id margin_position_id order_id instrument_id preset_type status trigger_price target_sl_price created_at updated_at } }`,
    variables: {
      "margin_position_id": "pos123",
      "preset_type": "break_even",
      "trigger_price": 62000
    },
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this
mutationedit_pending_stop_presetEdit a stop preset set at order creation while its order waits to fill.
Endpoint: POST https://live-margin-api.ouinex.com/graphql
Type: Mutation
Returns: MarginPositionStopPreset!

Inputs

NameTypeRequiredDescription
preset_idString!requiredPreset.
preset_typeStopPresetType!requiredbreak_even or stop_win.
trigger_priceFloat!requiredPrice that activates the preset.
target_sl_priceFloatoptionalNew stop-loss price (stop_win).

Response

Fields of MarginPositionStopPreset selected in the operation below.

FieldTypeDescription
preset_idString!
margin_position_idString
order_idStringSet for presets configured at order creation, before the position exists
instrument_idString!
preset_typeStopPresetType!
statusStopPresetStatus!
trigger_priceFloat!
target_sl_priceFloat
created_atString!
updated_atString!

GraphQL Operation

mutation edit_pending_stop_preset($preset_id: String!, $preset_type: StopPresetType!, $trigger_price: Float!, $target_sl_price: Float) {
  edit_pending_stop_preset(preset_id: $preset_id, preset_type: $preset_type, trigger_price: $trigger_price, target_sl_price: $target_sl_price) { preset_id margin_position_id order_id instrument_id preset_type status trigger_price target_sl_price created_at updated_at }
}

Code Examples

curl -X POST 'https://live-margin-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"mutation edit_pending_stop_preset($preset_id: String!, $preset_type: StopPresetType!, $trigger_price: Float!, $target_sl_price: Float) { edit_pending_stop_preset(preset_id: $preset_id, preset_type: $preset_type, trigger_price: $trigger_price, target_sl_price: $target_sl_price) { preset_id margin_position_id order_id instrument_id preset_type status trigger_price target_sl_price created_at updated_at } }","variables":{"preset_id":"preset123","preset_type":"stop_win","trigger_price":63000,"target_sl_price":61500}}'
import requests

url = "https://live-margin-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """mutation edit_pending_stop_preset($preset_id: String!, $preset_type: StopPresetType!, $trigger_price: Float!, $target_sl_price: Float) { edit_pending_stop_preset(preset_id: $preset_id, preset_type: $preset_type, trigger_price: $trigger_price, target_sl_price: $target_sl_price) { preset_id margin_position_id order_id instrument_id preset_type status trigger_price target_sl_price created_at updated_at } }""",
    "variables": {
        "preset_id": "preset123",
        "preset_type": "stop_win",
        "trigger_price": 63000,
        "target_sl_price": 61500
    },
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-margin-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `mutation edit_pending_stop_preset($preset_id: String!, $preset_type: StopPresetType!, $trigger_price: Float!, $target_sl_price: Float) { edit_pending_stop_preset(preset_id: $preset_id, preset_type: $preset_type, trigger_price: $trigger_price, target_sl_price: $target_sl_price) { preset_id margin_position_id order_id instrument_id preset_type status trigger_price target_sl_price created_at updated_at } }`,
    variables: {
      "preset_id": "preset123",
      "preset_type": "stop_win",
      "trigger_price": 63000,
      "target_sl_price": 61500
    },
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this
mutationcancel_stop_presetCancel an active stop preset.
Endpoint: POST https://live-margin-api.ouinex.com/graphql
Type: Mutation
Returns: Boolean!

Inputs

NameTypeRequiredDescription
preset_idString!requiredPreset.

GraphQL Operation

mutation cancel_stop_preset($preset_id: String!) {
  cancel_stop_preset(preset_id: $preset_id)
}

Code Examples

curl -X POST 'https://live-margin-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"mutation cancel_stop_preset($preset_id: String!) { cancel_stop_preset(preset_id: $preset_id) }","variables":{"preset_id":"preset123"}}'
import requests

url = "https://live-margin-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """mutation cancel_stop_preset($preset_id: String!) { cancel_stop_preset(preset_id: $preset_id) }""",
    "variables": {
        "preset_id": "preset123"
    },
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-margin-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `mutation cancel_stop_preset($preset_id: String!) { cancel_stop_preset(preset_id: $preset_id) }`,
    variables: {
      "preset_id": "preset123"
    },
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this
querystop_presetsList the user's stop presets.
Endpoint: POST https://live-margin-api.ouinex.com/graphql
Type: Query
Returns: [MarginPositionStopPreset!]!

Inputs

NameTypeRequiredDescription
margin_position_idStringoptionalPosition filter.
statusStopPresetStatusoptionalStatus filter.

Response

Fields of MarginPositionStopPreset selected in the operation below.

FieldTypeDescription
preset_idString!
margin_position_idString
order_idStringSet for presets configured at order creation, before the position exists
instrument_idString!
preset_typeStopPresetType!
statusStopPresetStatus!
trigger_priceFloat!
target_sl_priceFloat
created_atString!
updated_atString!

GraphQL Operation

query stop_presets {
  stop_presets { preset_id margin_position_id order_id instrument_id preset_type status trigger_price target_sl_price created_at updated_at }
}

Code Examples

curl -X POST 'https://live-margin-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"query stop_presets { stop_presets { preset_id margin_position_id order_id instrument_id preset_type status trigger_price target_sl_price created_at updated_at } }","variables":{}}'
import requests

url = "https://live-margin-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """query stop_presets { stop_presets { preset_id margin_position_id order_id instrument_id preset_type status trigger_price target_sl_price created_at updated_at } }""",
    "variables": {},
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-margin-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `query stop_presets { stop_presets { preset_id margin_position_id order_id instrument_id preset_type status trigger_price target_sl_price created_at updated_at } }`,
    variables: {},
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this
mutationset_trailing_presetSet a trailing stop on an open position (replaces any existing one).
Endpoint: POST https://live-margin-api.ouinex.com/graphql
Type: Mutation
Returns: MarginPositionTrailingPreset!

The trailing stop follows the best price by callback_rate (percent, retracement_type: percentage) or callback_distance (price, retracement_type: distance), starting once the price reaches activation_price when given. It combines with the regular SL/TP and stop presets.

Inputs

NameTypeRequiredDescription
margin_position_idString!requiredPosition.
retracement_typeTrailingStopRetracementType!requiredpercentage or distance.
callback_rateFloatoptionalRetracement in percent.
callback_distanceFloatoptionalRetracement in price.
activation_priceFloatoptionalPrice that starts the trailing.

Response

Fields of MarginPositionTrailingPreset selected in the operation below.

FieldTypeDescription
preset_idString!
margin_position_idString
order_idStringSet for presets configured at order creation, before the position exists
instrument_idString!
statusTrailingPresetStatus!
retracement_typeTrailingStopRetracementType!
callback_rateFloatPercent callback (e.g. 1.5 = 1.5%) when retracement_type=percentage
callback_distanceFloatAbsolute price distance when retracement_type=distance
activation_priceFloatOptional activation price; tracking starts only after it is reached
action_priceFloatPersisted runtime cursor. Before activation it holds nothing (activation is gated by activation_price); after activation it is the best favorable price seen so far, from which the stop_loss is derived. Survives restarts/failover.
is_activatedBoolean
created_atString!
updated_atString!

GraphQL Operation

mutation set_trailing_preset($margin_position_id: String!, $retracement_type: TrailingStopRetracementType!, $callback_rate: Float) {
  set_trailing_preset(margin_position_id: $margin_position_id, retracement_type: $retracement_type, callback_rate: $callback_rate) { preset_id margin_position_id order_id instrument_id status retracement_type callback_rate callback_distance activation_price action_price is_activated created_at updated_at }
}

Code Examples

curl -X POST 'https://live-margin-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"mutation set_trailing_preset($margin_position_id: String!, $retracement_type: TrailingStopRetracementType!, $callback_rate: Float) { set_trailing_preset(margin_position_id: $margin_position_id, retracement_type: $retracement_type, callback_rate: $callback_rate) { preset_id margin_position_id order_id instrument_id status retracement_type callback_rate callback_distance activation_price action_price is_activated created_at updated_at } }","variables":{"margin_position_id":"pos123","retracement_type":"percentage","callback_rate":1}}'
import requests

url = "https://live-margin-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """mutation set_trailing_preset($margin_position_id: String!, $retracement_type: TrailingStopRetracementType!, $callback_rate: Float) { set_trailing_preset(margin_position_id: $margin_position_id, retracement_type: $retracement_type, callback_rate: $callback_rate) { preset_id margin_position_id order_id instrument_id status retracement_type callback_rate callback_distance activation_price action_price is_activated created_at updated_at } }""",
    "variables": {
        "margin_position_id": "pos123",
        "retracement_type": "percentage",
        "callback_rate": 1
    },
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-margin-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `mutation set_trailing_preset($margin_position_id: String!, $retracement_type: TrailingStopRetracementType!, $callback_rate: Float) { set_trailing_preset(margin_position_id: $margin_position_id, retracement_type: $retracement_type, callback_rate: $callback_rate) { preset_id margin_position_id order_id instrument_id status retracement_type callback_rate callback_distance activation_price action_price is_activated created_at updated_at } }`,
    variables: {
      "margin_position_id": "pos123",
      "retracement_type": "percentage",
      "callback_rate": 1
    },
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this
mutationcancel_trailing_presetCancel an active trailing stop.
Endpoint: POST https://live-margin-api.ouinex.com/graphql
Type: Mutation
Returns: Boolean!

Inputs

NameTypeRequiredDescription
preset_idString!requiredPreset.

GraphQL Operation

mutation cancel_trailing_preset($preset_id: String!) {
  cancel_trailing_preset(preset_id: $preset_id)
}

Code Examples

curl -X POST 'https://live-margin-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"mutation cancel_trailing_preset($preset_id: String!) { cancel_trailing_preset(preset_id: $preset_id) }","variables":{"preset_id":"preset123"}}'
import requests

url = "https://live-margin-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """mutation cancel_trailing_preset($preset_id: String!) { cancel_trailing_preset(preset_id: $preset_id) }""",
    "variables": {
        "preset_id": "preset123"
    },
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-margin-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `mutation cancel_trailing_preset($preset_id: String!) { cancel_trailing_preset(preset_id: $preset_id) }`,
    variables: {
      "preset_id": "preset123"
    },
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this
querytrailing_presetsList the user's trailing stops.
Endpoint: POST https://live-margin-api.ouinex.com/graphql
Type: Query
Returns: [MarginPositionTrailingPreset!]!

Inputs

NameTypeRequiredDescription
margin_position_idStringoptionalPosition filter.
statusTrailingPresetStatusoptionalStatus filter.

Response

Fields of MarginPositionTrailingPreset selected in the operation below.

FieldTypeDescription
preset_idString!
margin_position_idString
order_idStringSet for presets configured at order creation, before the position exists
instrument_idString!
statusTrailingPresetStatus!
retracement_typeTrailingStopRetracementType!
callback_rateFloatPercent callback (e.g. 1.5 = 1.5%) when retracement_type=percentage
callback_distanceFloatAbsolute price distance when retracement_type=distance
activation_priceFloatOptional activation price; tracking starts only after it is reached
action_priceFloatPersisted runtime cursor. Before activation it holds nothing (activation is gated by activation_price); after activation it is the best favorable price seen so far, from which the stop_loss is derived. Survives restarts/failover.
is_activatedBoolean
created_atString!
updated_atString!

GraphQL Operation

query trailing_presets {
  trailing_presets { preset_id margin_position_id order_id instrument_id status retracement_type callback_rate callback_distance activation_price action_price is_activated created_at updated_at }
}

Code Examples

curl -X POST 'https://live-margin-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"query trailing_presets { trailing_presets { preset_id margin_position_id order_id instrument_id status retracement_type callback_rate callback_distance activation_price action_price is_activated created_at updated_at } }","variables":{}}'
import requests

url = "https://live-margin-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """query trailing_presets { trailing_presets { preset_id margin_position_id order_id instrument_id status retracement_type callback_rate callback_distance activation_price action_price is_activated created_at updated_at } }""",
    "variables": {},
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-margin-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `query trailing_presets { trailing_presets { preset_id margin_position_id order_id instrument_id status retracement_type callback_rate callback_distance activation_price action_price is_activated created_at updated_at } }`,
    variables: {},
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this
querymargin_funding_feesRead funding / financing fees charged or paid on positions.
Endpoint: POST https://live-margin-api.ouinex.com/graphql
Type: Query
Returns: [MarginFundingFee!]!
Permission: derivatives_funding_history

Inputs

NameTypeRequiredDescription
pagerPagerInputoptional
default {limit: 30, offset: 0}
Pagination (limit, offset).
sortSortInputoptional
default {direction: ASC}
Sort order.
wallet_idStringoptionalWallet filter.
margin_position_idStringoptionalFilter by specific position
margin_instrument_idStringoptionalFilter by margin_instrument_id.
dateRangeDateRangeInputoptional
default {}
Filter by updated_at (format YYYY-MM-DD HH:mm:ss).

Response

Fields of MarginFundingFee selected in the operation below.

FieldTypeDescription
amountFloat!Funding fee paid/received
updated_at_isoString!Fee calculation time
margin_position_idString!Position ID
position_sizeFloat!Position size the fee was charged on.
rateFloat!Funding rate at time of charge
currency_idString!Currency.
rate_typeRateType!Rate type; see RateType.

GraphQL Operation

query margin_funding_fees($pager: PagerInput, $wallet_id: String) {
  margin_funding_fees(pager: $pager, wallet_id: $wallet_id) {
    amount updated_at_iso margin_position_id position_size rate currency_id rate_type
  }
}

Code Examples

curl -X POST 'https://live-margin-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"query margin_funding_fees($pager: PagerInput, $wallet_id: String) { margin_funding_fees(pager: $pager, wallet_id: $wallet_id) { amount updated_at_iso margin_position_id position_size rate currency_id rate_type } }","variables":{"pager":{"limit":100,"offset":0},"wallet_id":"wallet123"}}'
import requests

url = "https://live-margin-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """query margin_funding_fees($pager: PagerInput, $wallet_id: String) { margin_funding_fees(pager: $pager, wallet_id: $wallet_id) { amount updated_at_iso margin_position_id position_size rate currency_id rate_type } }""",
    "variables": {
        "pager": {
            "limit": 100,
            "offset": 0
        },
        "wallet_id": "wallet123"
    },
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-margin-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `query margin_funding_fees($pager: PagerInput, $wallet_id: String) { margin_funding_fees(pager: $pager, wallet_id: $wallet_id) { amount updated_at_iso margin_position_id position_size rate currency_id rate_type } }`,
    variables: {
      "pager": {
        "limit": 100,
        "offset": 0
      },
      "wallet_id": "wallet123"
    },
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this

Advanced Orders

Stop, trailing stop, OCO, OTO, TWAP, iceberg and scaled orders on derivatives. Each runs server-side and places regular derivatives orders as it executes. Check margin_advanced_order_types_enabled before offering a type. Updates stream on the *_order_update subscriptions.

mutationcreate_stop_orderPlace a stop market, stop limit or trailing stop order.
Endpoint: POST https://live-margin-api.ouinex.com/graphql
Type: Mutation
Returns: StopMarginOrder!

stop_market and stop_limit trigger at trigger_price (stop_limit then rests at limit_price); trailing_stop uses retracement_type with callback_rate or callback_distance, from activation_price when given.

Inputs

NameTypeRequiredDescription
instrument_idString!requiredDerivatives instrument ID (margin_instrument_id from margin_instruments).
sideMarginPositionSide!requiredSide.
stop_order_typeStopOrderType!requiredOrder type.
quantityFloat!requiredQuantity.
leverageInt!requiredLeverage.
trigger_priceFloatoptionalTrigger price (stop market, stop limit).
limit_priceFloatoptionalLimit price (stop limit).
retracement_typeTrailingStopRetracementTypeoptionalTrailing: percentage or distance.
callback_rateFloatoptionalTrailing retracement in percent.
callback_distanceFloatoptionalTrailing retracement in price.
activation_priceFloatoptionalTrailing: price that starts the trailing.
take_profitFloatoptionalSingle take-profit price.
stop_lossFloatoptionalSingle stop-loss price.
wallet_idStringoptionalWallet to act on; defaults to MAIN.
autoscale_tp_slBooleanoptionalScale the TP/SL level quantities with the position size.
take_profits[TakeProfitInput!]optionalSeveral take-profit levels, each { price, quantity }.
stop_losses[StopLossInput!]optionalSeveral stop-loss levels, each { price, quantity }.

Response

Fields of StopMarginOrder selected in the operation below.

FieldTypeDescription
stop_order_idString!
instrument_idString!
sideMarginPositionSide!
stop_order_typeStopOrderType!
statusStopOrderStatus!
termination_reasonAdvancedOrderTerminationReason
termination_detailString
quantityFloat!
leverageInt!
wallet_idString!
trigger_priceFloat
trigger_directionStopOrderTriggerDirection
limit_priceFloat
retracement_typeTrailingStopRetracementType
callback_rateFloat
callback_distanceFloat
activation_priceFloat
best_priceFloat
is_activatedBoolean
take_profitFloat
stop_lossFloat
autoscale_tp_slBoolean!
created_atString!
updated_atString!

GraphQL Operation

mutation create_stop_order($instrument_id: String!, $side: MarginPositionSide!, $stop_order_type: StopOrderType!, $quantity: Float!, $leverage: Int!, $trigger_price: Float) {
  create_stop_order(instrument_id: $instrument_id, side: $side, stop_order_type: $stop_order_type, quantity: $quantity, leverage: $leverage, trigger_price: $trigger_price) { stop_order_id instrument_id side stop_order_type status termination_reason termination_detail quantity leverage wallet_id trigger_price trigger_direction limit_price retracement_type callback_rate callback_distance activation_price best_price is_activated take_profit stop_loss autoscale_tp_sl created_at updated_at }
}

Code Examples

curl -X POST 'https://live-margin-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"mutation create_stop_order($instrument_id: String!, $side: MarginPositionSide!, $stop_order_type: StopOrderType!, $quantity: Float!, $leverage: Int!, $trigger_price: Float) { create_stop_order(instrument_id: $instrument_id, side: $side, stop_order_type: $stop_order_type, quantity: $quantity, leverage: $leverage, trigger_price: $trigger_price) { stop_order_id instrument_id side stop_order_type status termination_reason termination_detail quantity leverage wallet_id trigger_price trigger_direction limit_price retracement_type callback_rate callback_distance activation_price best_price is_activated take_profit stop_loss autoscale_tp_sl created_at updated_at } }","variables":{"instrument_id":"BTCUSD","side":"sell","stop_order_type":"stop_market","quantity":0.1,"leverage":10,"trigger_price":58000}}'
import requests

url = "https://live-margin-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """mutation create_stop_order($instrument_id: String!, $side: MarginPositionSide!, $stop_order_type: StopOrderType!, $quantity: Float!, $leverage: Int!, $trigger_price: Float) { create_stop_order(instrument_id: $instrument_id, side: $side, stop_order_type: $stop_order_type, quantity: $quantity, leverage: $leverage, trigger_price: $trigger_price) { stop_order_id instrument_id side stop_order_type status termination_reason termination_detail quantity leverage wallet_id trigger_price trigger_direction limit_price retracement_type callback_rate callback_distance activation_price best_price is_activated take_profit stop_loss autoscale_tp_sl created_at updated_at } }""",
    "variables": {
        "instrument_id": "BTCUSD",
        "side": "sell",
        "stop_order_type": "stop_market",
        "quantity": 0.1,
        "leverage": 10,
        "trigger_price": 58000
    },
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-margin-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `mutation create_stop_order($instrument_id: String!, $side: MarginPositionSide!, $stop_order_type: StopOrderType!, $quantity: Float!, $leverage: Int!, $trigger_price: Float) { create_stop_order(instrument_id: $instrument_id, side: $side, stop_order_type: $stop_order_type, quantity: $quantity, leverage: $leverage, trigger_price: $trigger_price) { stop_order_id instrument_id side stop_order_type status termination_reason termination_detail quantity leverage wallet_id trigger_price trigger_direction limit_price retracement_type callback_rate callback_distance activation_price best_price is_activated take_profit stop_loss autoscale_tp_sl created_at updated_at } }`,
    variables: {
      "instrument_id": "BTCUSD",
      "side": "sell",
      "stop_order_type": "stop_market",
      "quantity": 0.1,
      "leverage": 10,
      "trigger_price": 58000
    },
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this
mutationedit_stop_order_tp_slReplace the TP/SL attached to a stop order that has not triggered yet.
Endpoint: POST https://live-margin-api.ouinex.com/graphql
Type: Mutation
Returns: StopMarginOrder!

Omitted TP/SL fields are cleared: sending none detaches TP/SL entirely.

Inputs

NameTypeRequiredDescription
stop_order_idString!requiredOrder.
take_profitFloatoptionalSingle take-profit price.
stop_lossFloatoptionalSingle stop-loss price.
take_profits[TakeProfitInput!]optionalSeveral take-profit levels, each { price, quantity }.
stop_losses[StopLossInput!]optionalSeveral stop-loss levels, each { price, quantity }.
autoscale_tp_slBooleanoptionalScale the TP/SL level quantities with the position size.

Response

Fields of StopMarginOrder selected in the operation below.

FieldTypeDescription
stop_order_idString!
instrument_idString!
sideMarginPositionSide!
stop_order_typeStopOrderType!
statusStopOrderStatus!
termination_reasonAdvancedOrderTerminationReason
termination_detailString
quantityFloat!
leverageInt!
wallet_idString!
trigger_priceFloat
trigger_directionStopOrderTriggerDirection
limit_priceFloat
retracement_typeTrailingStopRetracementType
callback_rateFloat
callback_distanceFloat
activation_priceFloat
best_priceFloat
is_activatedBoolean
take_profitFloat
stop_lossFloat
autoscale_tp_slBoolean!
created_atString!
updated_atString!

GraphQL Operation

mutation edit_stop_order_tp_sl($stop_order_id: String!, $take_profit: Float) {
  edit_stop_order_tp_sl(stop_order_id: $stop_order_id, take_profit: $take_profit) { stop_order_id instrument_id side stop_order_type status termination_reason termination_detail quantity leverage wallet_id trigger_price trigger_direction limit_price retracement_type callback_rate callback_distance activation_price best_price is_activated take_profit stop_loss autoscale_tp_sl created_at updated_at }
}

Code Examples

curl -X POST 'https://live-margin-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"mutation edit_stop_order_tp_sl($stop_order_id: String!, $take_profit: Float) { edit_stop_order_tp_sl(stop_order_id: $stop_order_id, take_profit: $take_profit) { stop_order_id instrument_id side stop_order_type status termination_reason termination_detail quantity leverage wallet_id trigger_price trigger_direction limit_price retracement_type callback_rate callback_distance activation_price best_price is_activated take_profit stop_loss autoscale_tp_sl created_at updated_at } }","variables":{"stop_order_id":"stop123","take_profit":65000}}'
import requests

url = "https://live-margin-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """mutation edit_stop_order_tp_sl($stop_order_id: String!, $take_profit: Float) { edit_stop_order_tp_sl(stop_order_id: $stop_order_id, take_profit: $take_profit) { stop_order_id instrument_id side stop_order_type status termination_reason termination_detail quantity leverage wallet_id trigger_price trigger_direction limit_price retracement_type callback_rate callback_distance activation_price best_price is_activated take_profit stop_loss autoscale_tp_sl created_at updated_at } }""",
    "variables": {
        "stop_order_id": "stop123",
        "take_profit": 65000
    },
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-margin-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `mutation edit_stop_order_tp_sl($stop_order_id: String!, $take_profit: Float) { edit_stop_order_tp_sl(stop_order_id: $stop_order_id, take_profit: $take_profit) { stop_order_id instrument_id side stop_order_type status termination_reason termination_detail quantity leverage wallet_id trigger_price trigger_direction limit_price retracement_type callback_rate callback_distance activation_price best_price is_activated take_profit stop_loss autoscale_tp_sl created_at updated_at } }`,
    variables: {
      "stop_order_id": "stop123",
      "take_profit": 65000
    },
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this
mutationcancel_stop_orderCancel an active stop order.
Endpoint: POST https://live-margin-api.ouinex.com/graphql
Type: Mutation
Returns: Boolean!

Inputs

NameTypeRequiredDescription
stop_order_idString!requiredOrder.

GraphQL Operation

mutation cancel_stop_order($stop_order_id: String!) {
  cancel_stop_order(stop_order_id: $stop_order_id)
}

Code Examples

curl -X POST 'https://live-margin-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"mutation cancel_stop_order($stop_order_id: String!) { cancel_stop_order(stop_order_id: $stop_order_id) }","variables":{"stop_order_id":"stop123"}}'
import requests

url = "https://live-margin-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """mutation cancel_stop_order($stop_order_id: String!) { cancel_stop_order(stop_order_id: $stop_order_id) }""",
    "variables": {
        "stop_order_id": "stop123"
    },
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-margin-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `mutation cancel_stop_order($stop_order_id: String!) { cancel_stop_order(stop_order_id: $stop_order_id) }`,
    variables: {
      "stop_order_id": "stop123"
    },
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this
querystop_ordersList the user's stop orders.
Endpoint: POST https://live-margin-api.ouinex.com/graphql
Type: Query
Returns: [StopMarginOrder!]!

Inputs

NameTypeRequiredDescription
searchStringoptionalSearch term.
pagerPagerInputoptional
default {limit: 30, offset: 0}
Pagination (limit, offset).
sortSortInputoptional
default {direction: ASC}
Sort order.
instrument_idStringoptionalDerivatives instrument ID (margin_instrument_id from margin_instruments).
statusStopOrderStatusoptionalStatus filter.
stop_order_typeStopOrderTypeoptionalType filter.
wallet_idStringoptionalWallet filter.
dateRangeDateRangeInputoptionalDate range.

Response

Fields of StopMarginOrder selected in the operation below.

FieldTypeDescription
stop_order_idString!
instrument_idString!
sideMarginPositionSide!
stop_order_typeStopOrderType!
statusStopOrderStatus!
termination_reasonAdvancedOrderTerminationReason
termination_detailString
quantityFloat!
leverageInt!
wallet_idString!
trigger_priceFloat
trigger_directionStopOrderTriggerDirection
limit_priceFloat
retracement_typeTrailingStopRetracementType
callback_rateFloat
callback_distanceFloat
activation_priceFloat
best_priceFloat
is_activatedBoolean
take_profitFloat
stop_lossFloat
autoscale_tp_slBoolean!
created_atString!
updated_atString!

GraphQL Operation

query stop_orders {
  stop_orders { stop_order_id instrument_id side stop_order_type status termination_reason termination_detail quantity leverage wallet_id trigger_price trigger_direction limit_price retracement_type callback_rate callback_distance activation_price best_price is_activated take_profit stop_loss autoscale_tp_sl created_at updated_at }
}

Code Examples

curl -X POST 'https://live-margin-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"query stop_orders { stop_orders { stop_order_id instrument_id side stop_order_type status termination_reason termination_detail quantity leverage wallet_id trigger_price trigger_direction limit_price retracement_type callback_rate callback_distance activation_price best_price is_activated take_profit stop_loss autoscale_tp_sl created_at updated_at } }","variables":{}}'
import requests

url = "https://live-margin-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """query stop_orders { stop_orders { stop_order_id instrument_id side stop_order_type status termination_reason termination_detail quantity leverage wallet_id trigger_price trigger_direction limit_price retracement_type callback_rate callback_distance activation_price best_price is_activated take_profit stop_loss autoscale_tp_sl created_at updated_at } }""",
    "variables": {},
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-margin-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `query stop_orders { stop_orders { stop_order_id instrument_id side stop_order_type status termination_reason termination_detail quantity leverage wallet_id trigger_price trigger_direction limit_price retracement_type callback_rate callback_distance activation_price best_price is_activated take_profit stop_loss autoscale_tp_sl created_at updated_at } }`,
    variables: {},
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this
querystop_orderOne stop order by id.
Endpoint: POST https://live-margin-api.ouinex.com/graphql
Type: Query
Returns: StopMarginOrder!

Inputs

NameTypeRequiredDescription
stop_order_idString!requiredOrder.

Response

Fields of StopMarginOrder selected in the operation below.

FieldTypeDescription
stop_order_idString!
instrument_idString!
sideMarginPositionSide!
stop_order_typeStopOrderType!
statusStopOrderStatus!
termination_reasonAdvancedOrderTerminationReason
termination_detailString
quantityFloat!
leverageInt!
wallet_idString!
trigger_priceFloat
trigger_directionStopOrderTriggerDirection
limit_priceFloat
retracement_typeTrailingStopRetracementType
callback_rateFloat
callback_distanceFloat
activation_priceFloat
best_priceFloat
is_activatedBoolean
take_profitFloat
stop_lossFloat
autoscale_tp_slBoolean!
created_atString!
updated_atString!

GraphQL Operation

query stop_order($stop_order_id: String!) {
  stop_order(stop_order_id: $stop_order_id) { stop_order_id instrument_id side stop_order_type status termination_reason termination_detail quantity leverage wallet_id trigger_price trigger_direction limit_price retracement_type callback_rate callback_distance activation_price best_price is_activated take_profit stop_loss autoscale_tp_sl created_at updated_at }
}

Code Examples

curl -X POST 'https://live-margin-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"query stop_order($stop_order_id: String!) { stop_order(stop_order_id: $stop_order_id) { stop_order_id instrument_id side stop_order_type status termination_reason termination_detail quantity leverage wallet_id trigger_price trigger_direction limit_price retracement_type callback_rate callback_distance activation_price best_price is_activated take_profit stop_loss autoscale_tp_sl created_at updated_at } }","variables":{"stop_order_id":"stop123"}}'
import requests

url = "https://live-margin-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """query stop_order($stop_order_id: String!) { stop_order(stop_order_id: $stop_order_id) { stop_order_id instrument_id side stop_order_type status termination_reason termination_detail quantity leverage wallet_id trigger_price trigger_direction limit_price retracement_type callback_rate callback_distance activation_price best_price is_activated take_profit stop_loss autoscale_tp_sl created_at updated_at } }""",
    "variables": {
        "stop_order_id": "stop123"
    },
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-margin-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `query stop_order($stop_order_id: String!) { stop_order(stop_order_id: $stop_order_id) { stop_order_id instrument_id side stop_order_type status termination_reason termination_detail quantity leverage wallet_id trigger_price trigger_direction limit_price retracement_type callback_rate callback_distance activation_price best_price is_activated take_profit stop_loss autoscale_tp_sl created_at updated_at } }`,
    variables: {
      "stop_order_id": "stop123"
    },
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this
mutationcreate_oco_orderPlace an OCO (one-cancels-the-other) order: a take-profit and a stop-loss leg.
Endpoint: POST https://live-margin-api.ouinex.com/graphql
Type: Mutation
Returns: OcoMarginOrder!

When one leg triggers, the other is cancelled. Each leg is market or limit; a limit leg needs its *_limit_price.

Inputs

NameTypeRequiredDescription
instrument_idString!requiredDerivatives instrument ID (margin_instrument_id from margin_instruments).
sideMarginPositionSide!requiredSide.
quantityFloat!requiredQuantity.
leverageInt!requiredLeverage.
tp_trigger_priceFloat!requiredTake-profit trigger.
tp_order_typeMarginOrderType!requiredTake-profit leg type.
tp_limit_priceFloatoptionalTake-profit limit price.
sl_trigger_priceFloat!requiredStop-loss trigger.
sl_order_typeMarginOrderType!requiredStop-loss leg type.
sl_limit_priceFloatoptionalStop-loss limit price.
wallet_idStringoptionalWallet to act on; defaults to MAIN.

Response

Fields of OcoMarginOrder selected in the operation below.

FieldTypeDescription
oco_order_idString!
instrument_idString!
sideMarginPositionSide!
statusOcoOrderStatus!
termination_reasonAdvancedOrderTerminationReason
termination_detailString
quantityFloat!
leverageInt!
wallet_idString!
tp_trigger_priceFloat!
tp_trigger_directionStopOrderTriggerDirection!
tp_order_typeMarginOrderType!
tp_limit_priceFloat
sl_trigger_priceFloat!
sl_trigger_directionStopOrderTriggerDirection!
sl_order_typeMarginOrderType!
sl_limit_priceFloat
triggered_legOcoTriggeredLeg
created_atString!
updated_atString!

GraphQL Operation

mutation create_oco_order($instrument_id: String!, $side: MarginPositionSide!, $quantity: Float!, $leverage: Int!, $tp_trigger_price: Float!, $tp_order_type: MarginOrderType!, $sl_trigger_price: Float!, $sl_order_type: MarginOrderType!) {
  create_oco_order(instrument_id: $instrument_id, side: $side, quantity: $quantity, leverage: $leverage, tp_trigger_price: $tp_trigger_price, tp_order_type: $tp_order_type, sl_trigger_price: $sl_trigger_price, sl_order_type: $sl_order_type) { oco_order_id instrument_id side status termination_reason termination_detail quantity leverage wallet_id tp_trigger_price tp_trigger_direction tp_order_type tp_limit_price sl_trigger_price sl_trigger_direction sl_order_type sl_limit_price triggered_leg created_at updated_at }
}

Code Examples

curl -X POST 'https://live-margin-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"mutation create_oco_order($instrument_id: String!, $side: MarginPositionSide!, $quantity: Float!, $leverage: Int!, $tp_trigger_price: Float!, $tp_order_type: MarginOrderType!, $sl_trigger_price: Float!, $sl_order_type: MarginOrderType!) { create_oco_order(instrument_id: $instrument_id, side: $side, quantity: $quantity, leverage: $leverage, tp_trigger_price: $tp_trigger_price, tp_order_type: $tp_order_type, sl_trigger_price: $sl_trigger_price, sl_order_type: $sl_order_type) { oco_order_id instrument_id side status termination_reason termination_detail quantity leverage wallet_id tp_trigger_price tp_trigger_direction tp_order_type tp_limit_price sl_trigger_price sl_trigger_direction sl_order_type sl_limit_price triggered_leg created_at updated_at } }","variables":{"instrument_id":"BTCUSD","side":"sell","quantity":0.1,"leverage":10,"tp_trigger_price":66000,"tp_order_type":"market","sl_trigger_price":58000,"sl_order_type":"market"}}'
import requests

url = "https://live-margin-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """mutation create_oco_order($instrument_id: String!, $side: MarginPositionSide!, $quantity: Float!, $leverage: Int!, $tp_trigger_price: Float!, $tp_order_type: MarginOrderType!, $sl_trigger_price: Float!, $sl_order_type: MarginOrderType!) { create_oco_order(instrument_id: $instrument_id, side: $side, quantity: $quantity, leverage: $leverage, tp_trigger_price: $tp_trigger_price, tp_order_type: $tp_order_type, sl_trigger_price: $sl_trigger_price, sl_order_type: $sl_order_type) { oco_order_id instrument_id side status termination_reason termination_detail quantity leverage wallet_id tp_trigger_price tp_trigger_direction tp_order_type tp_limit_price sl_trigger_price sl_trigger_direction sl_order_type sl_limit_price triggered_leg created_at updated_at } }""",
    "variables": {
        "instrument_id": "BTCUSD",
        "side": "sell",
        "quantity": 0.1,
        "leverage": 10,
        "tp_trigger_price": 66000,
        "tp_order_type": "market",
        "sl_trigger_price": 58000,
        "sl_order_type": "market"
    },
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-margin-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `mutation create_oco_order($instrument_id: String!, $side: MarginPositionSide!, $quantity: Float!, $leverage: Int!, $tp_trigger_price: Float!, $tp_order_type: MarginOrderType!, $sl_trigger_price: Float!, $sl_order_type: MarginOrderType!) { create_oco_order(instrument_id: $instrument_id, side: $side, quantity: $quantity, leverage: $leverage, tp_trigger_price: $tp_trigger_price, tp_order_type: $tp_order_type, sl_trigger_price: $sl_trigger_price, sl_order_type: $sl_order_type) { oco_order_id instrument_id side status termination_reason termination_detail quantity leverage wallet_id tp_trigger_price tp_trigger_direction tp_order_type tp_limit_price sl_trigger_price sl_trigger_direction sl_order_type sl_limit_price triggered_leg created_at updated_at } }`,
    variables: {
      "instrument_id": "BTCUSD",
      "side": "sell",
      "quantity": 0.1,
      "leverage": 10,
      "tp_trigger_price": 66000,
      "tp_order_type": "market",
      "sl_trigger_price": 58000,
      "sl_order_type": "market"
    },
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this
mutationcancel_oco_orderCancel an active OCO order.
Endpoint: POST https://live-margin-api.ouinex.com/graphql
Type: Mutation
Returns: Boolean!

Inputs

NameTypeRequiredDescription
oco_order_idString!requiredOrder.

GraphQL Operation

mutation cancel_oco_order($oco_order_id: String!) {
  cancel_oco_order(oco_order_id: $oco_order_id)
}

Code Examples

curl -X POST 'https://live-margin-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"mutation cancel_oco_order($oco_order_id: String!) { cancel_oco_order(oco_order_id: $oco_order_id) }","variables":{"oco_order_id":"oco123"}}'
import requests

url = "https://live-margin-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """mutation cancel_oco_order($oco_order_id: String!) { cancel_oco_order(oco_order_id: $oco_order_id) }""",
    "variables": {
        "oco_order_id": "oco123"
    },
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-margin-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `mutation cancel_oco_order($oco_order_id: String!) { cancel_oco_order(oco_order_id: $oco_order_id) }`,
    variables: {
      "oco_order_id": "oco123"
    },
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this
queryoco_ordersList the user's OCO orders.
Endpoint: POST https://live-margin-api.ouinex.com/graphql
Type: Query
Returns: [OcoMarginOrder!]!

Inputs

NameTypeRequiredDescription
searchStringoptionalSearch term.
pagerPagerInputoptional
default {limit: 30, offset: 0}
Pagination (limit, offset).
sortSortInputoptional
default {direction: ASC}
Sort order.
instrument_idStringoptionalDerivatives instrument ID (margin_instrument_id from margin_instruments).
statusOcoOrderStatusoptionalStatus filter.
wallet_idStringoptionalWallet filter.
dateRangeDateRangeInputoptionalDate range.

Response

Fields of OcoMarginOrder selected in the operation below.

FieldTypeDescription
oco_order_idString!
instrument_idString!
sideMarginPositionSide!
statusOcoOrderStatus!
termination_reasonAdvancedOrderTerminationReason
termination_detailString
quantityFloat!
leverageInt!
wallet_idString!
tp_trigger_priceFloat!
tp_trigger_directionStopOrderTriggerDirection!
tp_order_typeMarginOrderType!
tp_limit_priceFloat
sl_trigger_priceFloat!
sl_trigger_directionStopOrderTriggerDirection!
sl_order_typeMarginOrderType!
sl_limit_priceFloat
triggered_legOcoTriggeredLeg
created_atString!
updated_atString!

GraphQL Operation

query oco_orders {
  oco_orders { oco_order_id instrument_id side status termination_reason termination_detail quantity leverage wallet_id tp_trigger_price tp_trigger_direction tp_order_type tp_limit_price sl_trigger_price sl_trigger_direction sl_order_type sl_limit_price triggered_leg created_at updated_at }
}

Code Examples

curl -X POST 'https://live-margin-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"query oco_orders { oco_orders { oco_order_id instrument_id side status termination_reason termination_detail quantity leverage wallet_id tp_trigger_price tp_trigger_direction tp_order_type tp_limit_price sl_trigger_price sl_trigger_direction sl_order_type sl_limit_price triggered_leg created_at updated_at } }","variables":{}}'
import requests

url = "https://live-margin-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """query oco_orders { oco_orders { oco_order_id instrument_id side status termination_reason termination_detail quantity leverage wallet_id tp_trigger_price tp_trigger_direction tp_order_type tp_limit_price sl_trigger_price sl_trigger_direction sl_order_type sl_limit_price triggered_leg created_at updated_at } }""",
    "variables": {},
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-margin-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `query oco_orders { oco_orders { oco_order_id instrument_id side status termination_reason termination_detail quantity leverage wallet_id tp_trigger_price tp_trigger_direction tp_order_type tp_limit_price sl_trigger_price sl_trigger_direction sl_order_type sl_limit_price triggered_leg created_at updated_at } }`,
    variables: {},
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this
queryoco_orderOne OCO order by id.
Endpoint: POST https://live-margin-api.ouinex.com/graphql
Type: Query
Returns: OcoMarginOrder!

Inputs

NameTypeRequiredDescription
oco_order_idString!requiredOrder.

Response

Fields of OcoMarginOrder selected in the operation below.

FieldTypeDescription
oco_order_idString!
instrument_idString!
sideMarginPositionSide!
statusOcoOrderStatus!
termination_reasonAdvancedOrderTerminationReason
termination_detailString
quantityFloat!
leverageInt!
wallet_idString!
tp_trigger_priceFloat!
tp_trigger_directionStopOrderTriggerDirection!
tp_order_typeMarginOrderType!
tp_limit_priceFloat
sl_trigger_priceFloat!
sl_trigger_directionStopOrderTriggerDirection!
sl_order_typeMarginOrderType!
sl_limit_priceFloat
triggered_legOcoTriggeredLeg
created_atString!
updated_atString!

GraphQL Operation

query oco_order($oco_order_id: String!) {
  oco_order(oco_order_id: $oco_order_id) { oco_order_id instrument_id side status termination_reason termination_detail quantity leverage wallet_id tp_trigger_price tp_trigger_direction tp_order_type tp_limit_price sl_trigger_price sl_trigger_direction sl_order_type sl_limit_price triggered_leg created_at updated_at }
}

Code Examples

curl -X POST 'https://live-margin-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"query oco_order($oco_order_id: String!) { oco_order(oco_order_id: $oco_order_id) { oco_order_id instrument_id side status termination_reason termination_detail quantity leverage wallet_id tp_trigger_price tp_trigger_direction tp_order_type tp_limit_price sl_trigger_price sl_trigger_direction sl_order_type sl_limit_price triggered_leg created_at updated_at } }","variables":{"oco_order_id":"oco123"}}'
import requests

url = "https://live-margin-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """query oco_order($oco_order_id: String!) { oco_order(oco_order_id: $oco_order_id) { oco_order_id instrument_id side status termination_reason termination_detail quantity leverage wallet_id tp_trigger_price tp_trigger_direction tp_order_type tp_limit_price sl_trigger_price sl_trigger_direction sl_order_type sl_limit_price triggered_leg created_at updated_at } }""",
    "variables": {
        "oco_order_id": "oco123"
    },
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-margin-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `query oco_order($oco_order_id: String!) { oco_order(oco_order_id: $oco_order_id) { oco_order_id instrument_id side status termination_reason termination_detail quantity leverage wallet_id tp_trigger_price tp_trigger_direction tp_order_type tp_limit_price sl_trigger_price sl_trigger_direction sl_order_type sl_limit_price triggered_leg created_at updated_at } }`,
    variables: {
      "oco_order_id": "oco123"
    },
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this
mutationcreate_oto_orderPlace an OTO (one-triggers-the-other) order: a secondary order placed once the primary fills.
Endpoint: POST https://live-margin-api.ouinex.com/graphql
Type: Mutation
Returns: OtoMarginOrder!

Inputs

NameTypeRequiredDescription
instrument_idString!requiredDerivatives instrument ID (margin_instrument_id from margin_instruments).
sideMarginPositionSide!requiredSide.
leverageInt!requiredLeverage.
primary_order_typeMarginOrderType!requiredPrimary order type.
primary_priceFloatoptionalPrimary limit price.
primary_quantityFloat!requiredPrimary quantity.
secondary_sideMarginPositionSide!requiredSecondary side.
secondary_order_typeMarginOrderType!requiredSecondary order type.
secondary_priceFloatoptionalSecondary limit price.
secondary_quantityFloat!requiredSecondary quantity.
wallet_idStringoptionalWallet to act on; defaults to MAIN.

Response

Fields of OtoMarginOrder selected in the operation below.

FieldTypeDescription
oto_order_idString!
instrument_idString!
sideMarginPositionSide!
statusOtoOrderStatus!
leverageInt!
wallet_idString!
primary_order_typeMarginOrderType!
primary_priceFloat
primary_quantityFloat!
secondary_sideMarginPositionSide!
secondary_order_typeMarginOrderType!
secondary_priceFloat
secondary_quantityFloat!
primary_order_idString
secondary_order_idString
termination_reasonAdvancedOrderTerminationReason
termination_detailString
created_atString!
updated_atString!

GraphQL Operation

mutation create_oto_order($instrument_id: String!, $side: MarginPositionSide!, $leverage: Int!, $primary_order_type: MarginOrderType!, $primary_price: Float, $primary_quantity: Float!, $secondary_side: MarginPositionSide!, $secondary_order_type: MarginOrderType!, $secondary_price: Float, $secondary_quantity: Float!) {
  create_oto_order(instrument_id: $instrument_id, side: $side, leverage: $leverage, primary_order_type: $primary_order_type, primary_price: $primary_price, primary_quantity: $primary_quantity, secondary_side: $secondary_side, secondary_order_type: $secondary_order_type, secondary_price: $secondary_price, secondary_quantity: $secondary_quantity) { oto_order_id instrument_id side status leverage wallet_id primary_order_type primary_price primary_quantity secondary_side secondary_order_type secondary_price secondary_quantity primary_order_id secondary_order_id termination_reason termination_detail created_at updated_at }
}

Code Examples

curl -X POST 'https://live-margin-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"mutation create_oto_order($instrument_id: String!, $side: MarginPositionSide!, $leverage: Int!, $primary_order_type: MarginOrderType!, $primary_price: Float, $primary_quantity: Float!, $secondary_side: MarginPositionSide!, $secondary_order_type: MarginOrderType!, $secondary_price: Float, $secondary_quantity: Float!) { create_oto_order(instrument_id: $instrument_id, side: $side, leverage: $leverage, primary_order_type: $primary_order_type, primary_price: $primary_price, primary_quantity: $primary_quantity, secondary_side: $secondary_side, secondary_order_type: $secondary_order_type, secondary_price: $secondary_price, secondary_quantity: $secondary_quantity) { oto_order_id instrument_id side status leverage wallet_id primary_order_type primary_price primary_quantity secondary_side secondary_order_type secondary_price secondary_quantity primary_order_id secondary_order_id termination_reason termination_detail created_at updated_at } }","variables":{"instrument_id":"BTCUSD","side":"buy","leverage":10,"primary_order_type":"limit","primary_price":59000,"primary_quantity":0.1,"secondary_side":"sell","secondary_order_type":"limit","secondary_price":63000,"secondary_quantity":0.1}}'
import requests

url = "https://live-margin-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """mutation create_oto_order($instrument_id: String!, $side: MarginPositionSide!, $leverage: Int!, $primary_order_type: MarginOrderType!, $primary_price: Float, $primary_quantity: Float!, $secondary_side: MarginPositionSide!, $secondary_order_type: MarginOrderType!, $secondary_price: Float, $secondary_quantity: Float!) { create_oto_order(instrument_id: $instrument_id, side: $side, leverage: $leverage, primary_order_type: $primary_order_type, primary_price: $primary_price, primary_quantity: $primary_quantity, secondary_side: $secondary_side, secondary_order_type: $secondary_order_type, secondary_price: $secondary_price, secondary_quantity: $secondary_quantity) { oto_order_id instrument_id side status leverage wallet_id primary_order_type primary_price primary_quantity secondary_side secondary_order_type secondary_price secondary_quantity primary_order_id secondary_order_id termination_reason termination_detail created_at updated_at } }""",
    "variables": {
        "instrument_id": "BTCUSD",
        "side": "buy",
        "leverage": 10,
        "primary_order_type": "limit",
        "primary_price": 59000,
        "primary_quantity": 0.1,
        "secondary_side": "sell",
        "secondary_order_type": "limit",
        "secondary_price": 63000,
        "secondary_quantity": 0.1
    },
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-margin-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `mutation create_oto_order($instrument_id: String!, $side: MarginPositionSide!, $leverage: Int!, $primary_order_type: MarginOrderType!, $primary_price: Float, $primary_quantity: Float!, $secondary_side: MarginPositionSide!, $secondary_order_type: MarginOrderType!, $secondary_price: Float, $secondary_quantity: Float!) { create_oto_order(instrument_id: $instrument_id, side: $side, leverage: $leverage, primary_order_type: $primary_order_type, primary_price: $primary_price, primary_quantity: $primary_quantity, secondary_side: $secondary_side, secondary_order_type: $secondary_order_type, secondary_price: $secondary_price, secondary_quantity: $secondary_quantity) { oto_order_id instrument_id side status leverage wallet_id primary_order_type primary_price primary_quantity secondary_side secondary_order_type secondary_price secondary_quantity primary_order_id secondary_order_id termination_reason termination_detail created_at updated_at } }`,
    variables: {
      "instrument_id": "BTCUSD",
      "side": "buy",
      "leverage": 10,
      "primary_order_type": "limit",
      "primary_price": 59000,
      "primary_quantity": 0.1,
      "secondary_side": "sell",
      "secondary_order_type": "limit",
      "secondary_price": 63000,
      "secondary_quantity": 0.1
    },
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this
mutationcancel_oto_orderCancel an active OTO order.
Endpoint: POST https://live-margin-api.ouinex.com/graphql
Type: Mutation
Returns: Boolean!

Inputs

NameTypeRequiredDescription
oto_order_idString!requiredOrder.

GraphQL Operation

mutation cancel_oto_order($oto_order_id: String!) {
  cancel_oto_order(oto_order_id: $oto_order_id)
}

Code Examples

curl -X POST 'https://live-margin-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"mutation cancel_oto_order($oto_order_id: String!) { cancel_oto_order(oto_order_id: $oto_order_id) }","variables":{"oto_order_id":"oto123"}}'
import requests

url = "https://live-margin-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """mutation cancel_oto_order($oto_order_id: String!) { cancel_oto_order(oto_order_id: $oto_order_id) }""",
    "variables": {
        "oto_order_id": "oto123"
    },
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-margin-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `mutation cancel_oto_order($oto_order_id: String!) { cancel_oto_order(oto_order_id: $oto_order_id) }`,
    variables: {
      "oto_order_id": "oto123"
    },
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this
queryoto_ordersList the user's OTO orders.
Endpoint: POST https://live-margin-api.ouinex.com/graphql
Type: Query
Returns: [OtoMarginOrder!]!

Inputs

NameTypeRequiredDescription
searchStringoptionalSearch term.
pagerPagerInputoptional
default {limit: 30, offset: 0}
Pagination (limit, offset).
sortSortInputoptional
default {direction: ASC}
Sort order.
instrument_idStringoptionalDerivatives instrument ID (margin_instrument_id from margin_instruments).
statusOtoOrderStatusoptionalStatus filter.
wallet_idStringoptionalWallet filter.
dateRangeDateRangeInputoptionalDate range.

Response

Fields of OtoMarginOrder selected in the operation below.

FieldTypeDescription
oto_order_idString!
instrument_idString!
sideMarginPositionSide!
statusOtoOrderStatus!
leverageInt!
wallet_idString!
primary_order_typeMarginOrderType!
primary_priceFloat
primary_quantityFloat!
secondary_sideMarginPositionSide!
secondary_order_typeMarginOrderType!
secondary_priceFloat
secondary_quantityFloat!
primary_order_idString
secondary_order_idString
termination_reasonAdvancedOrderTerminationReason
termination_detailString
created_atString!
updated_atString!

GraphQL Operation

query oto_orders {
  oto_orders { oto_order_id instrument_id side status leverage wallet_id primary_order_type primary_price primary_quantity secondary_side secondary_order_type secondary_price secondary_quantity primary_order_id secondary_order_id termination_reason termination_detail created_at updated_at }
}

Code Examples

curl -X POST 'https://live-margin-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"query oto_orders { oto_orders { oto_order_id instrument_id side status leverage wallet_id primary_order_type primary_price primary_quantity secondary_side secondary_order_type secondary_price secondary_quantity primary_order_id secondary_order_id termination_reason termination_detail created_at updated_at } }","variables":{}}'
import requests

url = "https://live-margin-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """query oto_orders { oto_orders { oto_order_id instrument_id side status leverage wallet_id primary_order_type primary_price primary_quantity secondary_side secondary_order_type secondary_price secondary_quantity primary_order_id secondary_order_id termination_reason termination_detail created_at updated_at } }""",
    "variables": {},
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-margin-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `query oto_orders { oto_orders { oto_order_id instrument_id side status leverage wallet_id primary_order_type primary_price primary_quantity secondary_side secondary_order_type secondary_price secondary_quantity primary_order_id secondary_order_id termination_reason termination_detail created_at updated_at } }`,
    variables: {},
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this
queryoto_orderOne OTO order by id.
Endpoint: POST https://live-margin-api.ouinex.com/graphql
Type: Query
Returns: OtoMarginOrder!

Inputs

NameTypeRequiredDescription
oto_order_idString!requiredOrder.

Response

Fields of OtoMarginOrder selected in the operation below.

FieldTypeDescription
oto_order_idString!
instrument_idString!
sideMarginPositionSide!
statusOtoOrderStatus!
leverageInt!
wallet_idString!
primary_order_typeMarginOrderType!
primary_priceFloat
primary_quantityFloat!
secondary_sideMarginPositionSide!
secondary_order_typeMarginOrderType!
secondary_priceFloat
secondary_quantityFloat!
primary_order_idString
secondary_order_idString
termination_reasonAdvancedOrderTerminationReason
termination_detailString
created_atString!
updated_atString!

GraphQL Operation

query oto_order($oto_order_id: String!) {
  oto_order(oto_order_id: $oto_order_id) { oto_order_id instrument_id side status leverage wallet_id primary_order_type primary_price primary_quantity secondary_side secondary_order_type secondary_price secondary_quantity primary_order_id secondary_order_id termination_reason termination_detail created_at updated_at }
}

Code Examples

curl -X POST 'https://live-margin-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"query oto_order($oto_order_id: String!) { oto_order(oto_order_id: $oto_order_id) { oto_order_id instrument_id side status leverage wallet_id primary_order_type primary_price primary_quantity secondary_side secondary_order_type secondary_price secondary_quantity primary_order_id secondary_order_id termination_reason termination_detail created_at updated_at } }","variables":{"oto_order_id":"oto123"}}'
import requests

url = "https://live-margin-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """query oto_order($oto_order_id: String!) { oto_order(oto_order_id: $oto_order_id) { oto_order_id instrument_id side status leverage wallet_id primary_order_type primary_price primary_quantity secondary_side secondary_order_type secondary_price secondary_quantity primary_order_id secondary_order_id termination_reason termination_detail created_at updated_at } }""",
    "variables": {
        "oto_order_id": "oto123"
    },
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-margin-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `query oto_order($oto_order_id: String!) { oto_order(oto_order_id: $oto_order_id) { oto_order_id instrument_id side status leverage wallet_id primary_order_type primary_price primary_quantity secondary_side secondary_order_type secondary_price secondary_quantity primary_order_id secondary_order_id termination_reason termination_detail created_at updated_at } }`,
    variables: {
      "oto_order_id": "oto123"
    },
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this
mutationcreate_twap_orderPlace a TWAP order: the quantity is split into slices executed at a fixed frequency over a duration.
Endpoint: POST https://live-margin-api.ouinex.com/graphql
Type: Mutation
Returns: TWAPMarginOrder!

Inputs

NameTypeRequiredDescription
instrument_idString!requiredDerivatives instrument ID (margin_instrument_id from margin_instruments).
sideMarginPositionSide!requiredSide.
total_quantityFloat!requiredTotal quantity.
leverageInt!requiredLeverage.
frequencyTWAPFrequency!requiredInterval between slices.
durationInt!requiredTotal duration, in seconds.
execution_strategyTWAPExecutionStrategy!requireduniform slices or randomized sizes.
slice_order_typeMarginOrderType!requiredSlice order type.
limit_priceFloatoptionalLimit price for limit slices.
price_tolerance_percentFloatoptionalMaximum price deviation for a slice, in percent.
wallet_idStringoptionalWallet to act on; defaults to MAIN.

Response

Fields of TWAPMarginOrder selected in the operation below.

FieldTypeDescription
twap_order_idString!
instrument_idString!
sideMarginPositionSide!
statusTWAPOrderStatus!
termination_reasonAdvancedOrderTerminationReason
termination_detailString
total_quantityFloat!
executed_quantityFloat!
frequencyTWAPFrequency!
durationInt!
total_slicesInt!
execution_strategyTWAPExecutionStrategy!
slice_order_typeMarginOrderType!
start_timeString!
end_timeString!
next_execution_timeString
limit_priceFloat
price_tolerance_percentFloat
slices_executedInt!
slices_failedInt!
average_execution_priceFloat
leverageInt!
wallet_idString!
created_atString!
updated_atString!
progress_percentFloat!

GraphQL Operation

mutation create_twap_order($instrument_id: String!, $side: MarginPositionSide!, $total_quantity: Float!, $leverage: Int!, $frequency: TWAPFrequency!, $duration: Int!, $execution_strategy: TWAPExecutionStrategy!, $slice_order_type: MarginOrderType!) {
  create_twap_order(instrument_id: $instrument_id, side: $side, total_quantity: $total_quantity, leverage: $leverage, frequency: $frequency, duration: $duration, execution_strategy: $execution_strategy, slice_order_type: $slice_order_type) { twap_order_id instrument_id side status termination_reason termination_detail total_quantity executed_quantity frequency duration total_slices execution_strategy slice_order_type start_time end_time next_execution_time limit_price price_tolerance_percent slices_executed slices_failed average_execution_price leverage wallet_id created_at updated_at progress_percent }
}

Code Examples

curl -X POST 'https://live-margin-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"mutation create_twap_order($instrument_id: String!, $side: MarginPositionSide!, $total_quantity: Float!, $leverage: Int!, $frequency: TWAPFrequency!, $duration: Int!, $execution_strategy: TWAPExecutionStrategy!, $slice_order_type: MarginOrderType!) { create_twap_order(instrument_id: $instrument_id, side: $side, total_quantity: $total_quantity, leverage: $leverage, frequency: $frequency, duration: $duration, execution_strategy: $execution_strategy, slice_order_type: $slice_order_type) { twap_order_id instrument_id side status termination_reason termination_detail total_quantity executed_quantity frequency duration total_slices execution_strategy slice_order_type start_time end_time next_execution_time limit_price price_tolerance_percent slices_executed slices_failed average_execution_price leverage wallet_id created_at updated_at progress_percent } }","variables":{"instrument_id":"BTCUSD","side":"buy","total_quantity":1,"leverage":10,"frequency":"MIN_5","duration":3600,"execution_strategy":"uniform","slice_order_type":"market"}}'
import requests

url = "https://live-margin-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """mutation create_twap_order($instrument_id: String!, $side: MarginPositionSide!, $total_quantity: Float!, $leverage: Int!, $frequency: TWAPFrequency!, $duration: Int!, $execution_strategy: TWAPExecutionStrategy!, $slice_order_type: MarginOrderType!) { create_twap_order(instrument_id: $instrument_id, side: $side, total_quantity: $total_quantity, leverage: $leverage, frequency: $frequency, duration: $duration, execution_strategy: $execution_strategy, slice_order_type: $slice_order_type) { twap_order_id instrument_id side status termination_reason termination_detail total_quantity executed_quantity frequency duration total_slices execution_strategy slice_order_type start_time end_time next_execution_time limit_price price_tolerance_percent slices_executed slices_failed average_execution_price leverage wallet_id created_at updated_at progress_percent } }""",
    "variables": {
        "instrument_id": "BTCUSD",
        "side": "buy",
        "total_quantity": 1,
        "leverage": 10,
        "frequency": "MIN_5",
        "duration": 3600,
        "execution_strategy": "uniform",
        "slice_order_type": "market"
    },
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-margin-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `mutation create_twap_order($instrument_id: String!, $side: MarginPositionSide!, $total_quantity: Float!, $leverage: Int!, $frequency: TWAPFrequency!, $duration: Int!, $execution_strategy: TWAPExecutionStrategy!, $slice_order_type: MarginOrderType!) { create_twap_order(instrument_id: $instrument_id, side: $side, total_quantity: $total_quantity, leverage: $leverage, frequency: $frequency, duration: $duration, execution_strategy: $execution_strategy, slice_order_type: $slice_order_type) { twap_order_id instrument_id side status termination_reason termination_detail total_quantity executed_quantity frequency duration total_slices execution_strategy slice_order_type start_time end_time next_execution_time limit_price price_tolerance_percent slices_executed slices_failed average_execution_price leverage wallet_id created_at updated_at progress_percent } }`,
    variables: {
      "instrument_id": "BTCUSD",
      "side": "buy",
      "total_quantity": 1,
      "leverage": 10,
      "frequency": "MIN_5",
      "duration": 3600,
      "execution_strategy": "uniform",
      "slice_order_type": "market"
    },
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this
mutationpause_twap_orderPause an active TWAP order.
Endpoint: POST https://live-margin-api.ouinex.com/graphql
Type: Mutation
Returns: Boolean!

Inputs

NameTypeRequiredDescription
twap_order_idString!requiredOrder.

GraphQL Operation

mutation pause_twap_order($twap_order_id: String!) {
  pause_twap_order(twap_order_id: $twap_order_id)
}

Code Examples

curl -X POST 'https://live-margin-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"mutation pause_twap_order($twap_order_id: String!) { pause_twap_order(twap_order_id: $twap_order_id) }","variables":{"twap_order_id":"twap123"}}'
import requests

url = "https://live-margin-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """mutation pause_twap_order($twap_order_id: String!) { pause_twap_order(twap_order_id: $twap_order_id) }""",
    "variables": {
        "twap_order_id": "twap123"
    },
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-margin-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `mutation pause_twap_order($twap_order_id: String!) { pause_twap_order(twap_order_id: $twap_order_id) }`,
    variables: {
      "twap_order_id": "twap123"
    },
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this
mutationresume_twap_orderResume a paused TWAP order.
Endpoint: POST https://live-margin-api.ouinex.com/graphql
Type: Mutation
Returns: Boolean!

Inputs

NameTypeRequiredDescription
twap_order_idString!requiredOrder.

GraphQL Operation

mutation resume_twap_order($twap_order_id: String!) {
  resume_twap_order(twap_order_id: $twap_order_id)
}

Code Examples

curl -X POST 'https://live-margin-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"mutation resume_twap_order($twap_order_id: String!) { resume_twap_order(twap_order_id: $twap_order_id) }","variables":{"twap_order_id":"twap123"}}'
import requests

url = "https://live-margin-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """mutation resume_twap_order($twap_order_id: String!) { resume_twap_order(twap_order_id: $twap_order_id) }""",
    "variables": {
        "twap_order_id": "twap123"
    },
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-margin-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `mutation resume_twap_order($twap_order_id: String!) { resume_twap_order(twap_order_id: $twap_order_id) }`,
    variables: {
      "twap_order_id": "twap123"
    },
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this
mutationcancel_twap_orderCancel an active TWAP order.
Endpoint: POST https://live-margin-api.ouinex.com/graphql
Type: Mutation
Returns: Boolean!

Inputs

NameTypeRequiredDescription
twap_order_idString!requiredOrder.

GraphQL Operation

mutation cancel_twap_order($twap_order_id: String!) {
  cancel_twap_order(twap_order_id: $twap_order_id)
}

Code Examples

curl -X POST 'https://live-margin-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"mutation cancel_twap_order($twap_order_id: String!) { cancel_twap_order(twap_order_id: $twap_order_id) }","variables":{"twap_order_id":"twap123"}}'
import requests

url = "https://live-margin-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """mutation cancel_twap_order($twap_order_id: String!) { cancel_twap_order(twap_order_id: $twap_order_id) }""",
    "variables": {
        "twap_order_id": "twap123"
    },
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-margin-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `mutation cancel_twap_order($twap_order_id: String!) { cancel_twap_order(twap_order_id: $twap_order_id) }`,
    variables: {
      "twap_order_id": "twap123"
    },
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this
querytwap_ordersList the user's TWAP orders.
Endpoint: POST https://live-margin-api.ouinex.com/graphql
Type: Query
Returns: [TWAPMarginOrder!]!

Inputs

NameTypeRequiredDescription
searchStringoptionalSearch term.
pagerPagerInputoptional
default {limit: 30, offset: 0}
Pagination (limit, offset).
sortSortInputoptional
default {direction: ASC}
Sort order.
instrument_idStringoptionalDerivatives instrument ID (margin_instrument_id from margin_instruments).
statusTWAPOrderStatusoptionalStatus filter.
wallet_idStringoptionalWallet filter.
dateRangeDateRangeInputoptionalDate range.

Response

Fields of TWAPMarginOrder selected in the operation below.

FieldTypeDescription
twap_order_idString!
instrument_idString!
sideMarginPositionSide!
statusTWAPOrderStatus!
termination_reasonAdvancedOrderTerminationReason
termination_detailString
total_quantityFloat!
executed_quantityFloat!
frequencyTWAPFrequency!
durationInt!
total_slicesInt!
execution_strategyTWAPExecutionStrategy!
slice_order_typeMarginOrderType!
start_timeString!
end_timeString!
next_execution_timeString
limit_priceFloat
price_tolerance_percentFloat
slices_executedInt!
slices_failedInt!
average_execution_priceFloat
leverageInt!
wallet_idString!
created_atString!
updated_atString!
progress_percentFloat!

GraphQL Operation

query twap_orders {
  twap_orders { twap_order_id instrument_id side status termination_reason termination_detail total_quantity executed_quantity frequency duration total_slices execution_strategy slice_order_type start_time end_time next_execution_time limit_price price_tolerance_percent slices_executed slices_failed average_execution_price leverage wallet_id created_at updated_at progress_percent }
}

Code Examples

curl -X POST 'https://live-margin-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"query twap_orders { twap_orders { twap_order_id instrument_id side status termination_reason termination_detail total_quantity executed_quantity frequency duration total_slices execution_strategy slice_order_type start_time end_time next_execution_time limit_price price_tolerance_percent slices_executed slices_failed average_execution_price leverage wallet_id created_at updated_at progress_percent } }","variables":{}}'
import requests

url = "https://live-margin-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """query twap_orders { twap_orders { twap_order_id instrument_id side status termination_reason termination_detail total_quantity executed_quantity frequency duration total_slices execution_strategy slice_order_type start_time end_time next_execution_time limit_price price_tolerance_percent slices_executed slices_failed average_execution_price leverage wallet_id created_at updated_at progress_percent } }""",
    "variables": {},
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-margin-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `query twap_orders { twap_orders { twap_order_id instrument_id side status termination_reason termination_detail total_quantity executed_quantity frequency duration total_slices execution_strategy slice_order_type start_time end_time next_execution_time limit_price price_tolerance_percent slices_executed slices_failed average_execution_price leverage wallet_id created_at updated_at progress_percent } }`,
    variables: {},
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this
querytwap_orderOne TWAP order by id.
Endpoint: POST https://live-margin-api.ouinex.com/graphql
Type: Query
Returns: TWAPMarginOrder!

Inputs

NameTypeRequiredDescription
twap_order_idString!requiredOrder.

Response

Fields of TWAPMarginOrder selected in the operation below.

FieldTypeDescription
twap_order_idString!
instrument_idString!
sideMarginPositionSide!
statusTWAPOrderStatus!
termination_reasonAdvancedOrderTerminationReason
termination_detailString
total_quantityFloat!
executed_quantityFloat!
frequencyTWAPFrequency!
durationInt!
total_slicesInt!
execution_strategyTWAPExecutionStrategy!
slice_order_typeMarginOrderType!
start_timeString!
end_timeString!
next_execution_timeString
limit_priceFloat
price_tolerance_percentFloat
slices_executedInt!
slices_failedInt!
average_execution_priceFloat
leverageInt!
wallet_idString!
created_atString!
updated_atString!
progress_percentFloat!

GraphQL Operation

query twap_order($twap_order_id: String!) {
  twap_order(twap_order_id: $twap_order_id) { twap_order_id instrument_id side status termination_reason termination_detail total_quantity executed_quantity frequency duration total_slices execution_strategy slice_order_type start_time end_time next_execution_time limit_price price_tolerance_percent slices_executed slices_failed average_execution_price leverage wallet_id created_at updated_at progress_percent }
}

Code Examples

curl -X POST 'https://live-margin-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"query twap_order($twap_order_id: String!) { twap_order(twap_order_id: $twap_order_id) { twap_order_id instrument_id side status termination_reason termination_detail total_quantity executed_quantity frequency duration total_slices execution_strategy slice_order_type start_time end_time next_execution_time limit_price price_tolerance_percent slices_executed slices_failed average_execution_price leverage wallet_id created_at updated_at progress_percent } }","variables":{"twap_order_id":"twap123"}}'
import requests

url = "https://live-margin-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """query twap_order($twap_order_id: String!) { twap_order(twap_order_id: $twap_order_id) { twap_order_id instrument_id side status termination_reason termination_detail total_quantity executed_quantity frequency duration total_slices execution_strategy slice_order_type start_time end_time next_execution_time limit_price price_tolerance_percent slices_executed slices_failed average_execution_price leverage wallet_id created_at updated_at progress_percent } }""",
    "variables": {
        "twap_order_id": "twap123"
    },
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-margin-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `query twap_order($twap_order_id: String!) { twap_order(twap_order_id: $twap_order_id) { twap_order_id instrument_id side status termination_reason termination_detail total_quantity executed_quantity frequency duration total_slices execution_strategy slice_order_type start_time end_time next_execution_time limit_price price_tolerance_percent slices_executed slices_failed average_execution_price leverage wallet_id created_at updated_at progress_percent } }`,
    variables: {
      "twap_order_id": "twap123"
    },
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this
mutationcreate_iceberg_orderPlace an iceberg order: only a slice of the total quantity shows at a time.
Endpoint: POST https://live-margin-api.ouinex.com/graphql
Type: Mutation
Returns: IcebergMarginOrder!

Give display_quantity or number_of_slices. estimate_iceberg_order takes display_quantity or number_of_orders and returns the others, rounded to the instrument step.

Inputs

NameTypeRequiredDescription
instrument_idString!requiredDerivatives instrument ID (margin_instrument_id from margin_instruments).
sideMarginPositionSide!requiredSide.
total_quantityFloat!requiredTotal quantity.
display_quantityFloatoptionalQuantity shown per slice.
number_of_slicesIntoptionalNumber of slices.
placement_typeIcebergPlacementType!requiredfixed_price at limit_price, or chase_taker.
limit_priceFloatoptionalLimit price (fixed_price).
leverageInt!requiredLeverage.
wallet_idStringoptionalWallet to act on; defaults to MAIN.

Response

Fields of IcebergMarginOrder selected in the operation below.

FieldTypeDescription
iceberg_order_idString!
instrument_idString!
sideMarginPositionSide!
statusIcebergOrderStatus!
termination_reasonAdvancedOrderTerminationReason
termination_detailString
total_quantityFloat!
executed_quantityFloat!
display_quantityFloat!
placement_typeIcebergPlacementType!
limit_priceFloat
leverageInt!
wallet_idString!
average_execution_priceFloat
created_atString!
updated_atString!

GraphQL Operation

mutation create_iceberg_order($instrument_id: String!, $side: MarginPositionSide!, $total_quantity: Float!, $display_quantity: Float, $placement_type: IcebergPlacementType!, $limit_price: Float, $leverage: Int!) {
  create_iceberg_order(instrument_id: $instrument_id, side: $side, total_quantity: $total_quantity, display_quantity: $display_quantity, placement_type: $placement_type, limit_price: $limit_price, leverage: $leverage) { iceberg_order_id instrument_id side status termination_reason termination_detail total_quantity executed_quantity display_quantity placement_type limit_price leverage wallet_id average_execution_price created_at updated_at }
}

Code Examples

curl -X POST 'https://live-margin-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"mutation create_iceberg_order($instrument_id: String!, $side: MarginPositionSide!, $total_quantity: Float!, $display_quantity: Float, $placement_type: IcebergPlacementType!, $limit_price: Float, $leverage: Int!) { create_iceberg_order(instrument_id: $instrument_id, side: $side, total_quantity: $total_quantity, display_quantity: $display_quantity, placement_type: $placement_type, limit_price: $limit_price, leverage: $leverage) { iceberg_order_id instrument_id side status termination_reason termination_detail total_quantity executed_quantity display_quantity placement_type limit_price leverage wallet_id average_execution_price created_at updated_at } }","variables":{"instrument_id":"BTCUSD","side":"buy","total_quantity":1,"display_quantity":0.1,"placement_type":"fixed_price","limit_price":59000,"leverage":10}}'
import requests

url = "https://live-margin-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """mutation create_iceberg_order($instrument_id: String!, $side: MarginPositionSide!, $total_quantity: Float!, $display_quantity: Float, $placement_type: IcebergPlacementType!, $limit_price: Float, $leverage: Int!) { create_iceberg_order(instrument_id: $instrument_id, side: $side, total_quantity: $total_quantity, display_quantity: $display_quantity, placement_type: $placement_type, limit_price: $limit_price, leverage: $leverage) { iceberg_order_id instrument_id side status termination_reason termination_detail total_quantity executed_quantity display_quantity placement_type limit_price leverage wallet_id average_execution_price created_at updated_at } }""",
    "variables": {
        "instrument_id": "BTCUSD",
        "side": "buy",
        "total_quantity": 1,
        "display_quantity": 0.1,
        "placement_type": "fixed_price",
        "limit_price": 59000,
        "leverage": 10
    },
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-margin-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `mutation create_iceberg_order($instrument_id: String!, $side: MarginPositionSide!, $total_quantity: Float!, $display_quantity: Float, $placement_type: IcebergPlacementType!, $limit_price: Float, $leverage: Int!) { create_iceberg_order(instrument_id: $instrument_id, side: $side, total_quantity: $total_quantity, display_quantity: $display_quantity, placement_type: $placement_type, limit_price: $limit_price, leverage: $leverage) { iceberg_order_id instrument_id side status termination_reason termination_detail total_quantity executed_quantity display_quantity placement_type limit_price leverage wallet_id average_execution_price created_at updated_at } }`,
    variables: {
      "instrument_id": "BTCUSD",
      "side": "buy",
      "total_quantity": 1,
      "display_quantity": 0.1,
      "placement_type": "fixed_price",
      "limit_price": 59000,
      "leverage": 10
    },
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this
queryestimate_iceberg_orderCompute the slice count or slice size of an iceberg order.
Endpoint: POST https://live-margin-api.ouinex.com/graphql
Type: Query
Returns: EstimateIcebergOrderResult!

Inputs

NameTypeRequiredDescription
instrument_idString!requiredDerivatives instrument ID (margin_instrument_id from margin_instruments).
total_quantityFloat!requiredTotal quantity.
display_quantityFloatoptionalSlice size (give this or number_of_orders).
number_of_ordersIntoptionalSlice count.

Response

Fields of EstimateIcebergOrderResult selected in the operation below.

FieldTypeDescription
total_quantityFloat!Total quantity (rounded to instrument step_size)
display_quantityFloat!Quantity per order / slice (rounded to instrument step_size)
number_of_ordersInt!Estimated number of slice orders

GraphQL Operation

query estimate_iceberg_order($instrument_id: String!, $total_quantity: Float!, $number_of_orders: Int) {
  estimate_iceberg_order(instrument_id: $instrument_id, total_quantity: $total_quantity, number_of_orders: $number_of_orders) { total_quantity display_quantity number_of_orders }
}

Code Examples

curl -X POST 'https://live-margin-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"query estimate_iceberg_order($instrument_id: String!, $total_quantity: Float!, $number_of_orders: Int) { estimate_iceberg_order(instrument_id: $instrument_id, total_quantity: $total_quantity, number_of_orders: $number_of_orders) { total_quantity display_quantity number_of_orders } }","variables":{"instrument_id":"BTCUSD","total_quantity":1,"number_of_orders":10}}'
import requests

url = "https://live-margin-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """query estimate_iceberg_order($instrument_id: String!, $total_quantity: Float!, $number_of_orders: Int) { estimate_iceberg_order(instrument_id: $instrument_id, total_quantity: $total_quantity, number_of_orders: $number_of_orders) { total_quantity display_quantity number_of_orders } }""",
    "variables": {
        "instrument_id": "BTCUSD",
        "total_quantity": 1,
        "number_of_orders": 10
    },
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-margin-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `query estimate_iceberg_order($instrument_id: String!, $total_quantity: Float!, $number_of_orders: Int) { estimate_iceberg_order(instrument_id: $instrument_id, total_quantity: $total_quantity, number_of_orders: $number_of_orders) { total_quantity display_quantity number_of_orders } }`,
    variables: {
      "instrument_id": "BTCUSD",
      "total_quantity": 1,
      "number_of_orders": 10
    },
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this
mutationcancel_iceberg_orderCancel an active iceberg order.
Endpoint: POST https://live-margin-api.ouinex.com/graphql
Type: Mutation
Returns: Boolean!

Inputs

NameTypeRequiredDescription
iceberg_order_idString!requiredOrder.

GraphQL Operation

mutation cancel_iceberg_order($iceberg_order_id: String!) {
  cancel_iceberg_order(iceberg_order_id: $iceberg_order_id)
}

Code Examples

curl -X POST 'https://live-margin-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"mutation cancel_iceberg_order($iceberg_order_id: String!) { cancel_iceberg_order(iceberg_order_id: $iceberg_order_id) }","variables":{"iceberg_order_id":"iceberg123"}}'
import requests

url = "https://live-margin-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """mutation cancel_iceberg_order($iceberg_order_id: String!) { cancel_iceberg_order(iceberg_order_id: $iceberg_order_id) }""",
    "variables": {
        "iceberg_order_id": "iceberg123"
    },
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-margin-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `mutation cancel_iceberg_order($iceberg_order_id: String!) { cancel_iceberg_order(iceberg_order_id: $iceberg_order_id) }`,
    variables: {
      "iceberg_order_id": "iceberg123"
    },
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this
queryiceberg_ordersList the user's iceberg orders.
Endpoint: POST https://live-margin-api.ouinex.com/graphql
Type: Query
Returns: [IcebergMarginOrder!]!

Inputs

NameTypeRequiredDescription
searchStringoptionalSearch term.
pagerPagerInputoptional
default {limit: 30, offset: 0}
Pagination (limit, offset).
sortSortInputoptional
default {direction: ASC}
Sort order.
instrument_idStringoptionalDerivatives instrument ID (margin_instrument_id from margin_instruments).
statusIcebergOrderStatusoptionalStatus filter.
wallet_idStringoptionalWallet filter.
dateRangeDateRangeInputoptionalDate range.

Response

Fields of IcebergMarginOrder selected in the operation below.

FieldTypeDescription
iceberg_order_idString!
instrument_idString!
sideMarginPositionSide!
statusIcebergOrderStatus!
termination_reasonAdvancedOrderTerminationReason
termination_detailString
total_quantityFloat!
executed_quantityFloat!
display_quantityFloat!
placement_typeIcebergPlacementType!
limit_priceFloat
leverageInt!
wallet_idString!
average_execution_priceFloat
created_atString!
updated_atString!

GraphQL Operation

query iceberg_orders {
  iceberg_orders { iceberg_order_id instrument_id side status termination_reason termination_detail total_quantity executed_quantity display_quantity placement_type limit_price leverage wallet_id average_execution_price created_at updated_at }
}

Code Examples

curl -X POST 'https://live-margin-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"query iceberg_orders { iceberg_orders { iceberg_order_id instrument_id side status termination_reason termination_detail total_quantity executed_quantity display_quantity placement_type limit_price leverage wallet_id average_execution_price created_at updated_at } }","variables":{}}'
import requests

url = "https://live-margin-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """query iceberg_orders { iceberg_orders { iceberg_order_id instrument_id side status termination_reason termination_detail total_quantity executed_quantity display_quantity placement_type limit_price leverage wallet_id average_execution_price created_at updated_at } }""",
    "variables": {},
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-margin-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `query iceberg_orders { iceberg_orders { iceberg_order_id instrument_id side status termination_reason termination_detail total_quantity executed_quantity display_quantity placement_type limit_price leverage wallet_id average_execution_price created_at updated_at } }`,
    variables: {},
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this
queryiceberg_orderOne iceberg order by id.
Endpoint: POST https://live-margin-api.ouinex.com/graphql
Type: Query
Returns: IcebergMarginOrder!

Inputs

NameTypeRequiredDescription
iceberg_order_idString!requiredOrder.

Response

Fields of IcebergMarginOrder selected in the operation below.

FieldTypeDescription
iceberg_order_idString!
instrument_idString!
sideMarginPositionSide!
statusIcebergOrderStatus!
termination_reasonAdvancedOrderTerminationReason
termination_detailString
total_quantityFloat!
executed_quantityFloat!
display_quantityFloat!
placement_typeIcebergPlacementType!
limit_priceFloat
leverageInt!
wallet_idString!
average_execution_priceFloat
created_atString!
updated_atString!

GraphQL Operation

query iceberg_order($iceberg_order_id: String!) {
  iceberg_order(iceberg_order_id: $iceberg_order_id) { iceberg_order_id instrument_id side status termination_reason termination_detail total_quantity executed_quantity display_quantity placement_type limit_price leverage wallet_id average_execution_price created_at updated_at }
}

Code Examples

curl -X POST 'https://live-margin-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"query iceberg_order($iceberg_order_id: String!) { iceberg_order(iceberg_order_id: $iceberg_order_id) { iceberg_order_id instrument_id side status termination_reason termination_detail total_quantity executed_quantity display_quantity placement_type limit_price leverage wallet_id average_execution_price created_at updated_at } }","variables":{"iceberg_order_id":"iceberg123"}}'
import requests

url = "https://live-margin-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """query iceberg_order($iceberg_order_id: String!) { iceberg_order(iceberg_order_id: $iceberg_order_id) { iceberg_order_id instrument_id side status termination_reason termination_detail total_quantity executed_quantity display_quantity placement_type limit_price leverage wallet_id average_execution_price created_at updated_at } }""",
    "variables": {
        "iceberg_order_id": "iceberg123"
    },
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-margin-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `query iceberg_order($iceberg_order_id: String!) { iceberg_order(iceberg_order_id: $iceberg_order_id) { iceberg_order_id instrument_id side status termination_reason termination_detail total_quantity executed_quantity display_quantity placement_type limit_price leverage wallet_id average_execution_price created_at updated_at } }`,
    variables: {
      "iceberg_order_id": "iceberg123"
    },
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this
mutationcreate_scaled_orderPlace a scaled order: several limit orders spread across a price range.
Endpoint: POST https://live-margin-api.ouinex.com/graphql
Type: Mutation
Returns: ScaledMarginOrder!

Build slices_config with estimate_scaled_order, or pass your own slices.

Inputs

NameTypeRequiredDescription
instrument_idString!requiredDerivatives instrument ID (margin_instrument_id from margin_instruments).
sideMarginPositionSide!requiredSide.
total_quantityFloat!requiredTotal quantity.
number_of_ordersInt!requiredNumber of limit orders.
price_range_startFloat!requiredFirst price of the range.
price_range_endFloat!requiredLast price of the range.
slices_config[ScaledOrderSliceConfigInput!]!requiredOne { index, price, rate, amount } per order.
leverageInt!requiredLeverage.
wallet_idStringoptionalWallet to act on; defaults to MAIN.

Response

Fields of ScaledMarginOrder selected in the operation below.

FieldTypeDescription
scaled_order_idString!
instrument_idString!
sideMarginPositionSide!
statusScaledOrderStatus!
termination_reasonAdvancedOrderTerminationReason
termination_detailString
total_quantityFloat!
executed_quantityFloat!
number_of_ordersInt!
price_range_startFloat!
price_range_endFloat!
leverageInt!
wallet_idString!
average_execution_priceFloat
orders_executedInt!
orders_failedInt!
created_atString!
updated_atString!

GraphQL Operation

mutation create_scaled_order($instrument_id: String!, $side: MarginPositionSide!, $total_quantity: Float!, $number_of_orders: Int!, $price_range_start: Float!, $price_range_end: Float!, $slices_config: [ScaledOrderSliceConfigInput!]!, $leverage: Int!) {
  create_scaled_order(instrument_id: $instrument_id, side: $side, total_quantity: $total_quantity, number_of_orders: $number_of_orders, price_range_start: $price_range_start, price_range_end: $price_range_end, slices_config: $slices_config, leverage: $leverage) { scaled_order_id instrument_id side status termination_reason termination_detail total_quantity executed_quantity number_of_orders price_range_start price_range_end leverage wallet_id average_execution_price orders_executed orders_failed created_at updated_at }
}

Code Examples

curl -X POST 'https://live-margin-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"mutation create_scaled_order($instrument_id: String!, $side: MarginPositionSide!, $total_quantity: Float!, $number_of_orders: Int!, $price_range_start: Float!, $price_range_end: Float!, $slices_config: [ScaledOrderSliceConfigInput!]!, $leverage: Int!) { create_scaled_order(instrument_id: $instrument_id, side: $side, total_quantity: $total_quantity, number_of_orders: $number_of_orders, price_range_start: $price_range_start, price_range_end: $price_range_end, slices_config: $slices_config, leverage: $leverage) { scaled_order_id instrument_id side status termination_reason termination_detail total_quantity executed_quantity number_of_orders price_range_start price_range_end leverage wallet_id average_execution_price orders_executed orders_failed created_at updated_at } }","variables":{"instrument_id":"BTCUSD","side":"buy","total_quantity":1,"number_of_orders":2,"price_range_start":58000,"price_range_end":59000,"leverage":10,"slices_config":[{"index":0,"price":58000,"rate":50,"amount":0.5},{"index":1,"price":59000,"rate":50,"amount":0.5}]}}'
import requests

url = "https://live-margin-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """mutation create_scaled_order($instrument_id: String!, $side: MarginPositionSide!, $total_quantity: Float!, $number_of_orders: Int!, $price_range_start: Float!, $price_range_end: Float!, $slices_config: [ScaledOrderSliceConfigInput!]!, $leverage: Int!) { create_scaled_order(instrument_id: $instrument_id, side: $side, total_quantity: $total_quantity, number_of_orders: $number_of_orders, price_range_start: $price_range_start, price_range_end: $price_range_end, slices_config: $slices_config, leverage: $leverage) { scaled_order_id instrument_id side status termination_reason termination_detail total_quantity executed_quantity number_of_orders price_range_start price_range_end leverage wallet_id average_execution_price orders_executed orders_failed created_at updated_at } }""",
    "variables": {
        "instrument_id": "BTCUSD",
        "side": "buy",
        "total_quantity": 1,
        "number_of_orders": 2,
        "price_range_start": 58000,
        "price_range_end": 59000,
        "leverage": 10,
        "slices_config": [
            {
                "index": 0,
                "price": 58000,
                "rate": 50,
                "amount": 0.5
            },
            {
                "index": 1,
                "price": 59000,
                "rate": 50,
                "amount": 0.5
            }
        ]
    },
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-margin-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `mutation create_scaled_order($instrument_id: String!, $side: MarginPositionSide!, $total_quantity: Float!, $number_of_orders: Int!, $price_range_start: Float!, $price_range_end: Float!, $slices_config: [ScaledOrderSliceConfigInput!]!, $leverage: Int!) { create_scaled_order(instrument_id: $instrument_id, side: $side, total_quantity: $total_quantity, number_of_orders: $number_of_orders, price_range_start: $price_range_start, price_range_end: $price_range_end, slices_config: $slices_config, leverage: $leverage) { scaled_order_id instrument_id side status termination_reason termination_detail total_quantity executed_quantity number_of_orders price_range_start price_range_end leverage wallet_id average_execution_price orders_executed orders_failed created_at updated_at } }`,
    variables: {
      "instrument_id": "BTCUSD",
      "side": "buy",
      "total_quantity": 1,
      "number_of_orders": 2,
      "price_range_start": 58000,
      "price_range_end": 59000,
      "leverage": 10,
      "slices_config": [
        {
          "index": 0,
          "price": 58000,
          "rate": 50,
          "amount": 0.5
        },
        {
          "index": 1,
          "price": 59000,
          "rate": 50,
          "amount": 0.5
        }
      ]
    },
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this
queryestimate_scaled_orderCompute the slices of a scaled order for a distribution.
Endpoint: POST https://live-margin-api.ouinex.com/graphql
Type: Query
Returns: [ScaledOrderSliceConfig!]!

Inputs

NameTypeRequiredDescription
instrument_idString!requiredDerivatives instrument ID (margin_instrument_id from margin_instruments).
distribution_typeScaledDistributionType!requiredSize distribution across the range.
total_quantityFloat!requiredTotal quantity.
number_of_ordersInt!requiredNumber of orders.
price_range_startFloat!requiredFirst price.
price_range_endFloat!requiredLast price.
varianceIntoptional
default 25
Steepness for increasing / decreasing distributions.

Response

Fields of ScaledOrderSliceConfig selected in the operation below.

FieldTypeDescription
indexInt!
priceFloat!
rateFloat!
amountFloat!

GraphQL Operation

query estimate_scaled_order($instrument_id: String!, $distribution_type: ScaledDistributionType!, $total_quantity: Float!, $number_of_orders: Int!, $price_range_start: Float!, $price_range_end: Float!) {
  estimate_scaled_order(instrument_id: $instrument_id, distribution_type: $distribution_type, total_quantity: $total_quantity, number_of_orders: $number_of_orders, price_range_start: $price_range_start, price_range_end: $price_range_end) { index price rate amount }
}

Code Examples

curl -X POST 'https://live-margin-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"query estimate_scaled_order($instrument_id: String!, $distribution_type: ScaledDistributionType!, $total_quantity: Float!, $number_of_orders: Int!, $price_range_start: Float!, $price_range_end: Float!) { estimate_scaled_order(instrument_id: $instrument_id, distribution_type: $distribution_type, total_quantity: $total_quantity, number_of_orders: $number_of_orders, price_range_start: $price_range_start, price_range_end: $price_range_end) { index price rate amount } }","variables":{"instrument_id":"BTCUSD","distribution_type":"flat","total_quantity":1,"number_of_orders":5,"price_range_start":58000,"price_range_end":59000}}'
import requests

url = "https://live-margin-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """query estimate_scaled_order($instrument_id: String!, $distribution_type: ScaledDistributionType!, $total_quantity: Float!, $number_of_orders: Int!, $price_range_start: Float!, $price_range_end: Float!) { estimate_scaled_order(instrument_id: $instrument_id, distribution_type: $distribution_type, total_quantity: $total_quantity, number_of_orders: $number_of_orders, price_range_start: $price_range_start, price_range_end: $price_range_end) { index price rate amount } }""",
    "variables": {
        "instrument_id": "BTCUSD",
        "distribution_type": "flat",
        "total_quantity": 1,
        "number_of_orders": 5,
        "price_range_start": 58000,
        "price_range_end": 59000
    },
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-margin-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `query estimate_scaled_order($instrument_id: String!, $distribution_type: ScaledDistributionType!, $total_quantity: Float!, $number_of_orders: Int!, $price_range_start: Float!, $price_range_end: Float!) { estimate_scaled_order(instrument_id: $instrument_id, distribution_type: $distribution_type, total_quantity: $total_quantity, number_of_orders: $number_of_orders, price_range_start: $price_range_start, price_range_end: $price_range_end) { index price rate amount } }`,
    variables: {
      "instrument_id": "BTCUSD",
      "distribution_type": "flat",
      "total_quantity": 1,
      "number_of_orders": 5,
      "price_range_start": 58000,
      "price_range_end": 59000
    },
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this
mutationcancel_scaled_orderCancel an active scaled order.
Endpoint: POST https://live-margin-api.ouinex.com/graphql
Type: Mutation
Returns: Boolean!

Inputs

NameTypeRequiredDescription
scaled_order_idString!requiredOrder.

GraphQL Operation

mutation cancel_scaled_order($scaled_order_id: String!) {
  cancel_scaled_order(scaled_order_id: $scaled_order_id)
}

Code Examples

curl -X POST 'https://live-margin-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"mutation cancel_scaled_order($scaled_order_id: String!) { cancel_scaled_order(scaled_order_id: $scaled_order_id) }","variables":{"scaled_order_id":"scaled123"}}'
import requests

url = "https://live-margin-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """mutation cancel_scaled_order($scaled_order_id: String!) { cancel_scaled_order(scaled_order_id: $scaled_order_id) }""",
    "variables": {
        "scaled_order_id": "scaled123"
    },
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-margin-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `mutation cancel_scaled_order($scaled_order_id: String!) { cancel_scaled_order(scaled_order_id: $scaled_order_id) }`,
    variables: {
      "scaled_order_id": "scaled123"
    },
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this
queryscaled_ordersList the user's scaled orders.
Endpoint: POST https://live-margin-api.ouinex.com/graphql
Type: Query
Returns: [ScaledMarginOrder!]!

Inputs

NameTypeRequiredDescription
searchStringoptionalSearch term.
pagerPagerInputoptional
default {limit: 30, offset: 0}
Pagination (limit, offset).
sortSortInputoptional
default {direction: ASC}
Sort order.
instrument_idStringoptionalDerivatives instrument ID (margin_instrument_id from margin_instruments).
statusScaledOrderStatusoptionalStatus filter.
wallet_idStringoptionalWallet filter.
dateRangeDateRangeInputoptionalDate range.

Response

Fields of ScaledMarginOrder selected in the operation below.

FieldTypeDescription
scaled_order_idString!
instrument_idString!
sideMarginPositionSide!
statusScaledOrderStatus!
termination_reasonAdvancedOrderTerminationReason
termination_detailString
total_quantityFloat!
executed_quantityFloat!
number_of_ordersInt!
price_range_startFloat!
price_range_endFloat!
leverageInt!
wallet_idString!
average_execution_priceFloat
orders_executedInt!
orders_failedInt!
created_atString!
updated_atString!

GraphQL Operation

query scaled_orders {
  scaled_orders { scaled_order_id instrument_id side status termination_reason termination_detail total_quantity executed_quantity number_of_orders price_range_start price_range_end leverage wallet_id average_execution_price orders_executed orders_failed created_at updated_at }
}

Code Examples

curl -X POST 'https://live-margin-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"query scaled_orders { scaled_orders { scaled_order_id instrument_id side status termination_reason termination_detail total_quantity executed_quantity number_of_orders price_range_start price_range_end leverage wallet_id average_execution_price orders_executed orders_failed created_at updated_at } }","variables":{}}'
import requests

url = "https://live-margin-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """query scaled_orders { scaled_orders { scaled_order_id instrument_id side status termination_reason termination_detail total_quantity executed_quantity number_of_orders price_range_start price_range_end leverage wallet_id average_execution_price orders_executed orders_failed created_at updated_at } }""",
    "variables": {},
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-margin-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `query scaled_orders { scaled_orders { scaled_order_id instrument_id side status termination_reason termination_detail total_quantity executed_quantity number_of_orders price_range_start price_range_end leverage wallet_id average_execution_price orders_executed orders_failed created_at updated_at } }`,
    variables: {},
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this
queryscaled_orderOne scaled order by id.
Endpoint: POST https://live-margin-api.ouinex.com/graphql
Type: Query
Returns: ScaledMarginOrder!

Inputs

NameTypeRequiredDescription
scaled_order_idString!requiredOrder.

Response

Fields of ScaledMarginOrder selected in the operation below.

FieldTypeDescription
scaled_order_idString!
instrument_idString!
sideMarginPositionSide!
statusScaledOrderStatus!
termination_reasonAdvancedOrderTerminationReason
termination_detailString
total_quantityFloat!
executed_quantityFloat!
number_of_ordersInt!
price_range_startFloat!
price_range_endFloat!
leverageInt!
wallet_idString!
average_execution_priceFloat
orders_executedInt!
orders_failedInt!
created_atString!
updated_atString!

GraphQL Operation

query scaled_order($scaled_order_id: String!) {
  scaled_order(scaled_order_id: $scaled_order_id) { scaled_order_id instrument_id side status termination_reason termination_detail total_quantity executed_quantity number_of_orders price_range_start price_range_end leverage wallet_id average_execution_price orders_executed orders_failed created_at updated_at }
}

Code Examples

curl -X POST 'https://live-margin-api.ouinex.com/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"query":"query scaled_order($scaled_order_id: String!) { scaled_order(scaled_order_id: $scaled_order_id) { scaled_order_id instrument_id side status termination_reason termination_detail total_quantity executed_quantity number_of_orders price_range_start price_range_end leverage wallet_id average_execution_price orders_executed orders_failed created_at updated_at } }","variables":{"scaled_order_id":"scaled123"}}'
import requests

url = "https://live-margin-api.ouinex.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}
payload = {
    "query": """query scaled_order($scaled_order_id: String!) { scaled_order(scaled_order_id: $scaled_order_id) { scaled_order_id instrument_id side status termination_reason termination_detail total_quantity executed_quantity number_of_orders price_range_start price_range_end leverage wallet_id average_execution_price orders_executed orders_failed created_at updated_at } }""",
    "variables": {
        "scaled_order_id": "scaled123"
    },
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const response = await fetch("https://live-margin-api.ouinex.com/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    query: `query scaled_order($scaled_order_id: String!) { scaled_order(scaled_order_id: $scaled_order_id) { scaled_order_id instrument_id side status termination_reason termination_detail total_quantity executed_quantity number_of_orders price_range_start price_range_end leverage wallet_id average_execution_price orders_executed orders_failed created_at updated_at } }`,
    variables: {
      "scaled_order_id": "scaled123"
    },
  }),
});
const data = await response.json();
console.log(data);
Authenticate at the top of the page to try this

Types

Enums and input types used by the operations above. Enum values are sent as unquoted GraphQL enum literals (for example side: buy) or as the same string in JSON variables. The spot and margin APIs each define their own types; a few names exist on both hosts with different values, so check the host heading.

Spot API (https://live-api.ouinex.com/graphql)

enum AccountTransactionClass

trade fee payment reward conversion manual fee_rebalance referral_reward wallet_transfer u2u_transfer vault_payment

enum AccountTransactionType

debit credit

enum ApiKeyTypes

API users create trader keys.

trader

enum ConditionalOrderAttachmentType

standalone entry_order

enum ConditionalOrderExecutionType

market limit

input ConditionalOrderLegInput

FieldTypeRequiredDescription
trigger_priceFloat!requiredReference price at which this leg becomes eligible to trigger.
execution_typeConditionalOrderExecutionType!optional default marketExecution strategy used after the trigger: protected market-style or explicit limit.
limit_priceFloatoptionalRequired child-order price when execution_type is limit.
price_referenceConditionalOrderPriceReference!optional default orderbookPrice stream evaluated against trigger_price.
slippage_bpsIntoptional default 100Maximum market-style execution deviation in basis points. 100 equals 1%.
time_in_forceOrderTimeInForce!optional default gtcTime-in-force used by a limit child order.

enum ConditionalOrderPriceReference

last_trade orderbook

enum ConditionalOrderStatus

waiting_entry active executing queued completed cancelled rejected unprotected

enum ConditionalOrderType

take_profit stop_loss oco

enum ConversionStatus

new completed rejected

enum CryptoAddressTagType

destination_tag memo_id note tag

enum CryptoNetworkFeePreference

low medium high

enum CurrencyType

crypto fiat

input DateRangeInput

FieldTypeRequiredDescription
time_fromStringoptionalTime FROM filter, YYYY-MM-DD HH:mm:ss
time_toStringoptionalTime TO filter, YYYY-MM-DD HH:mm:ss

enum FeeCalculationType

sum max

input FiatDepositPropertyInput

FieldTypeRequiredDescription
nameString!required
valueString!required

enum InstrumentHistoryPeriodicity

minute minute5 minute10 minute15 minute30 hour hour4 hour8 day week month

enum OrderQuantityMode

base quote

enum OrderSide

sell buy

enum OrderStatus

new pending completed cancelled rejected expired

enum OrderTimeInForce

fok ioc gtc gtd

enum OrderType

limit market stop_market stop_limit

input PagerInput

FieldTypeRequiredDescription
limitIntoptional default 30pager limit, default 30
offsetIntoptional default 0pager offset, default 0

enum PaymentStatus

new processing rejected completed unconfirmed

enum PaymentType

withdrawal deposit

enum Permission

Values an API key of type trader can hold. See API key permissions.

accounts accounts_balances account_transactions conversion_quotes create_conversion_quote conversions create_conversion_order currencies payments_fees trading_fees instruments payments_limits aggregated_payments_limits trading_limits payments_routes create_order cancel_order estimate_order open_orders closed_orders trades payments create_withdrawal_crypto create_withdrawal_fiat is_withdrawal_allowed create_deposit_fiat deposit_bank_details_fiat deposit_addresses_crypto upload_user_document update_user wallets create_wallet update_wallet deactivate_wallet create_wallet_transfer notification_settings create_kyc_manual_request estimate_network_fee webhooks create_webhook update_webhook delete_webhook daily_balances_report timeline kyc_user_data create_kyc_user_data update_kyc_user_data crypto_pay_core settl_payments settl_create_invoice settl_create_open_deposit vaults vaults_transactions create_vault_withdrawal create_vault_deposit trading_grids set_trading_grid vaults_accounts estimate_vault_interests vaults_transactions_requests cancel_vault_transaction_request referrals create_referral claim_referral referrals_history referrals_transactions_info derivatives_instruments create_derivatives_order cancel_derivatives_order estimate_derivatives_order open_derivatives_orders closed_derivatives_orders update_open_derivatives_position open_derivatives_positions closed_derivatives_positions crypto_pay_payments voucher_codes derivatives_funding_history otc_orders otc_create_order portfolios create_portfolio update_portfolio followers update_follower u2u_transfers create_u2u_transfer prediction_positions prediction_orders create_prediction_order estimate_prediction_order prediction_trades prediction_accounts prediction_transactions transfer_prediction_funds set_prediction_event_favourite

enum PortfolioHistoryInterval

minute hour day week month year all

input SerialIdRangeInput

FieldTypeRequiredDescription
serial_id_fromIntoptionalSerial ID FROM filter
serial_id_toIntoptionalSerial ID TO filter

enum SortDirection

ASC DESC

input SortInput

FieldTypeRequiredDescription
directionSortDirectionoptional default DESCSort direction
propertyStringoptionalSort property

enum ToggleSwitch

on off

input TravelRuleAddress

FieldTypeRequiredDescription
countryStringoptional
post_codeStringoptional
townStringoptional
streetStringoptional
stateStringoptional
building_numberStringoptional
flat_numberStringoptional

input TravelRuleCounterParty

FieldTypeRequiredDescription
fullNameString!required
crypto_addressString!required
vasp_idStringoptional
place_of_birthStringoptional
date_of_birthStringoptional
addressTravelRuleAddressoptional

input TravelRulePropertiesArgs

FieldTypeRequiredDescription
counterpartyTravelRuleCounterParty!required

enum VaultLockStrategy

aggregated independent

enum VaultRateType

flexible fixed

enum VaultTransactionRequestStatus

processing pending approved rejected cancelled

enum VaultWithdrawalPolicy

instant delayed manual_approval

enum VaultsTransactionClass

deposit withdrawal interest manual

enum VerificationType

none totp bank_id sms passkey passkey_or_mfa local_mfa

enum WalletType

MAIN PERSONAL

Margin API (https://live-margin-api.ouinex.com/graphql)

enum AdvancedOrderTerminationReason

user_request child_order_error system position_leverage_mismatch

enum AdvancedOrderType

twap iceberg stop_order scaled_order oco_order oto_order

input DateRangeInput

FieldTypeRequiredDescription
time_fromStringoptionalTime FROM filter, YYYY-MM-DD HH:mm:ss
time_toStringoptionalTime TO filter, YYYY-MM-DD HH:mm:ss

enum IcebergOrderStatus

active cancelled completed

enum IcebergPlacementType

fixed_price chase_taker

enum LiquidationEstimateDisclaimer

indicative other_instruments_frozen twap_current_market

enum LiquidationEstimateOrderKind

market limit stop_market stop_limit trailing_stop twap iceberg scaled oco oto

enum LiquidationEstimateUnavailableReason

insufficient_parameters trailing_stop no_remaining_position non_positive_price price_unavailable

enum MarginInstrumentClass

perpetual rwa forex stocks indexes metals commodities

enum MarginInstrumentHistoryPeriodicity

minute minute5 minute10 minute15 minute30 hour hour4 hour8 day week month

enum MarginOrderStatus

open execution_ready requested partially_filled completed cancelled rejected pending

enum MarginOrderTimeInForce

fok ioc gtc gtd

enum MarginOrderType

market limit

enum MarginOrigin

user copy_follower copy_leader bot system

enum MarginPositionSide

buy sell

enum MarketStatus

closed open

enum OcoOrderStatus

active tp_triggered sl_triggered completed cancelled

enum OcoTriggeredLeg

tp sl

input OrderStopPresetInput

FieldTypeRequiredDescription
preset_typeStopPresetType!required
trigger_priceFloat!required
target_sl_priceFloatoptionalRequired for stop_win; ignored for break_even

input OrderTrailingPresetInput

FieldTypeRequiredDescription
retracement_typeTrailingStopRetracementType!required
callback_rateFloatoptionalRequired for percentage retracement (0.01-50%)
callback_distanceFloatoptionalRequired for distance retracement (absolute price units)
activation_priceFloatoptionalOptional; tracking starts only after this level is reached

enum OtoOrderStatus

active primary_executed completed cancelled

input PagerInput

FieldTypeRequiredDescription
limitIntoptional default 30
offsetIntoptional default 0

enum Percentage

percent25 percent50 percent75 percent100 custom

enum RateType

financing funding by_money_in_margin_currency

enum ScaledDistributionType

flat increasing decreasing custom

input ScaledOrderSliceConfigInput

FieldTypeRequiredDescription
indexInt!required
priceFloat!required
rateFloat!required
amountFloat!required

enum ScaledOrderStatus

active completed cancelled

enum SortDirection

ASC DESC

input SortInput

FieldTypeRequiredDescription
directionSortDirectionoptional default ASC
fieldStringoptional

input StopLossInput

FieldTypeRequiredDescription
priceFloat!required
quantityFloat!required

enum StopOrderStatus

active triggered completed cancelled

enum StopOrderTriggerDirection

rises_to_trigger falls_to_trigger

enum StopOrderType

stop_market stop_limit trailing_stop

enum StopPresetStatus

pending active triggered cancelled

enum StopPresetType

break_even stop_win

enum TWAPExecutionStrategy

uniform randomized

enum TWAPFrequency

MIN_1 MIN_3 MIN_5 MIN_10 MIN_15 MIN_20 MIN_30

enum TWAPOrderStatus

active paused completed cancelled

input TakeProfitInput

FieldTypeRequiredDescription
priceFloat!required
quantityFloat!required

enum ToggleSwitch

on off

enum TrailingPresetStatus

pending active cancelled

enum TrailingStopRetracementType

percentage distance

Changelog

2026-10-15 — platform 4.35.5

  • Added service_signin_v2: a server-side session bound to the API key's expiry, with expires_at in Unix seconds (sliding). service_signin is still supported.
  • Added session management: user_sessions, revoke_current_session, revoke_session, revoke_other_sessions.
  • Added portfolio_history_v2 and user_trading_pnl (portfolio value, PNL and ROI over a period).
  • API keys: a trader key requires an IP allow-list of 1 to 3 addresses, and cannot hold API-key management permissions; keys are managed from your OUINEX account in the web app. Added the wallet permissions create_wallet, update_wallet and create_wallet_transfer to the permissions guide.
  • Payment and API-key operations require a KYC-approved, active account. Errors carry their real HTTP status (4xx).
  • Removed fields that do not apply to API users.
  • Fixed examples: spot instruments are written BTCUSDT, derivatives instruments BTCUSD; create_twap_order duration is in seconds.

2026-10-14 — platform 4.35

  • Added the Demo environment: hosts, keys, and a Live/Demo switch for Try It.
  • Added Advanced Orders: stop, trailing stop, OCO, OTO, TWAP, iceberg and scaled orders, with their update subscriptions.
  • Added stop presets (break-even, stop-win) and trailing stops on open positions, edit_margin_order, margin_order, margin_trades, margin_instruments_prices, margin_instrument_price_bars, estimate_liquidation_price and margin_advanced_order_types_enabled.
  • Added spot conditional orders (take-profit, stop-loss, OCO): create_conditional_order, cancel_conditional_order, conditional_orders, conditional_order_policy, and take_profit / stop_loss on create_order.
  • Added spot trades, update_open_order, cancel_multiple_orders, cancel_all_orders, and sub-wallets: create_wallet, update_wallet, create_wallet_transfer.
  • Fixed create_withdrawal_fiat: bank and beneficiary details are sent as properties name/value pairs, not as separate arguments.
  • Fixed wallets: is_active and type take strings.
  • Inputs, defaults and types are now generated from the platform schema.