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.
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.
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
| Name | Type | Required | Description |
|---|---|---|---|
service_api_key | String! | required | API key ID (api_key_id returned by create_api_key). |
service_api_secret | String! | required | API secret (api_key_secret returned by create_api_key; shown only once). |
Response
Fields of SignInResult selected in the operation below.
| Field | Type | Description |
|---|---|---|
jwt | String! | Bearer token (RS256-signed JWT). |
expires_at | Float! | 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);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.
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
| Name | Type | Required | Description |
|---|---|---|---|
service_api_key | String! | required | API key ID (api_key_id returned by create_api_key). |
service_api_secret | String! | required | API secret (api_key_secret returned by create_api_key; shown only once). |
Response
Fields of LocalSessionResult selected in the operation below.
| Field | Type | Description |
|---|---|---|
session_token | String! | Opaque session token. Send it as Authorization: Bearer <token>. |
session_id | String! | Session ID, as listed by user_sessions. |
expires_at | Float! | 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);queryuser_sessionsList your active sessions (devices).
Tokens from service_signin carry no session and are not listed.
Response
Fields of UserSessionInfo selected in the operation below.
| Field | Type | Description |
|---|---|---|
session_id | String! | Session ID (use it with revoke_session). |
device_label | String | Device label. |
country | String | Country of the last use. |
city | String | City of the last use. |
created_at | String! | Session start. |
last_used_at | String! | Last use. |
is_current | Boolean! | 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);mutationrevoke_current_sessionRevoke the session this request was made with (server-side logout).
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);mutationrevoke_sessionRevoke one of your own sessions. Takes effect immediately.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
session_id | String! | required | Session 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);mutationrevoke_other_sessionsRevoke all your sessions except the current one.
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);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).
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
| Name | Type | Required | Description |
|---|---|---|---|
wallet_id | String | optional | Wallet filter. |
name | String | optional | Filter by name. |
description | String | optional | Filter by description. |
is_active | String | optional | Wallet status filter. Defaults to on; the synthetic MAIN wallet is included only when filtering for active wallets. |
type | String | optional | Filter by type. |
pager | PagerInput | optional default {limit: 30, offset: 0} | Pagination (limit, offset). |
sort | SortInput | optional default {direction: DESC} | Sort order. |
dateRange | DateRangeInput | optional default {} | Filter by wallet creation date. |
Response
Fields of WalletsResult selected in the operation below.
| Field | Type | Description |
|---|---|---|
wallets | [Wallet!]! | Wallets of the user, MAIN first. |
personal_wallets_limit | Float! | 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);mutationcreate_walletCreate a personal sub-wallet.
Wallet names are unique per user, and the number of wallets per user is limited.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
name | String! | required | Wallet name, unique for the user. |
description | String | optional | Free-text description. |
Response
Fields of Wallet selected in the operation below.
| Field | Type | Description |
|---|---|---|
wallet_id | String! | |
name | String! | Type of the wallet (will become enum in future) |
description | String | |
type | WalletType | |
created_at | String! |
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);mutationupdate_walletRename a wallet or change its description.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
wallet_id | String! | required | Wallet to update. |
name | String | optional | New name. |
description | String | optional | New description. |
Response
Fields of Wallet selected in the operation below.
| Field | Type | Description |
|---|---|---|
wallet_id | String! | |
name | String! | Type of the wallet (will become enum in future) |
description | String |
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);mutationcreate_wallet_transferMove funds between two of the user's own wallets.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
from_wallet_id | String! | required | Source wallet. |
to_wallet_id | String! | required | Destination wallet. |
currency_id | String! | required | Currency to move. |
amount | Float! | required | Amount to move. |
description | String | optional | Free-text description. |
Response
Fields of WalletTransfer selected in the operation below.
| Field | Type | Description |
|---|---|---|
serial_id | Int! | |
transfer_id | String! | |
from_wallet_id | String! | |
to_wallet_id | String! | |
currency_id | String! | |
amount | Float! | |
created_at | String! | |
from_post_balance | Float! | |
to_post_balance | Float! | |
description | String |
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);queryaccounts_balancesRead current balances per currency (free, total, exposed, margin exposure).
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
currency_id | String | optional | Currency filter. |
hide_zero_balances | ToggleSwitch | optional default off | With on, rows whose total_balance is 0 are removed. |
wallet_id | String | optional | Wallet to read. When omitted, balances of all the user's wallets are returned. |
omit_currencies | [String!] | optional | Currencies to exclude from the result. |
respect_limit_group | ToggleSwitch | optional 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.
| Field | Type | Description |
|---|---|---|
currency_id | String! | Currency ID |
total_balance | Float! | Total balance |
exposed_balance | Float! | Exposed (reserved) balance. |
margin_exposure | Float! | Margin exposure. |
free_balance | Float! | 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);queryaccount_transactionsRead account ledger (trades, fees, deposits, withdrawals, transfers).
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
account_transaction_id | String | optional | Filter by account_transaction_id. |
parent_transaction_id | String | optional | Filter by parent_transaction_id. |
client_transaction_id | String | optional | Filter by client_transaction_id. |
account_id | String | optional | Filter by account_id. |
payment_id | String | optional | Filter by payment_id. |
currency_id | String | optional | Currency filter. |
transaction_class | AccountTransactionClass | optional | Filter by transaction_class. |
type | AccountTransactionType | optional | Filter by debit / credit. |
order_id | String | optional | Filter by order_id. |
trade_id | String | optional | Filter by trade_id. |
conversion_id | String | optional | Filter by conversion_id. |
margin_trade_id | String | optional | Filter by margin_trade_id. |
comment | String | optional | Prefix match on the transaction comment. |
search | String | optional | Search term. |
instrument_id | String | optional | Instrument filter. |
pager | PagerInput | optional default {limit: 30, offset: 0} | Pagination (limit, offset). |
sort | SortInput | optional default {direction: DESC} | Sort order. |
dateRange | DateRangeInput | optional 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. |
serialIdRange | SerialIdRangeInput | optional default {} | Filter by serial ID range. |
wallet_id | String | optional | Wallet filter. |
reference | String | optional | Client reference. |
Response
Fields of AccountTransaction selected in the operation below.
| Field | Type | Description |
|---|---|---|
account_transaction_id | String! | Transaction ID |
currency_id | String! | Currency. |
type | AccountTransactionType! | debit or credit. |
amount | Float! | Amount. |
post_balance | Float! | Account balance after this transaction. |
created_at_iso | String! | 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);queryportfolio_history_v2Portfolio value history over a period, with PNL and ROI.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
period | PortfolioHistoryInterval! | required | Period to cover. |
wallet_id | String | optional | Wallet filter. |
currency_id | String | optional | Currency 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.
| Field | Type | Description |
|---|---|---|
points | [PortfolioHistoryPoint!]! | Portfolio value over time (ts, value). |
pnl | Float! | PNL over the period. |
roi | Float! | ROI over the period. |
currency_id | String | Currency every value and pnl is denominated in. |
backfill_in_progress | Boolean | true 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);queryuser_trading_pnlCumulative unrealized trading PNL over a period, with ROI; deposits and withdrawals are excluded.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
period | PortfolioHistoryInterval! | required | Period to cover. |
wallet_id | String | optional | Wallet filter. |
currency_id | String | optional | Currency 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.
| Field | Type | Description |
|---|---|---|
points | [TradingPnlPoint!]! | Cumulative PNL over time (ts, pnl). |
pnl | Float! | PNL over the period. |
roi | Float! | ROI over the period. |
currency_id | String | Currency every value and pnl is denominated in. |
start_value | Float! | 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);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
| Permission | Description |
|---|---|
accounts_balances | Read current balances per currency (free, total, exposed, margin exposure). |
daily_balances_report | Read end-of-day balance snapshots / history. |
account_transactions | Read account ledger (trades, fees, deposits, withdrawals, transfers). |
accounts | List the user's accounts and metadata. |
wallets | List the user's wallets (wallets). |
create_wallet | Create a personal sub-wallet. |
update_wallet | Rename a wallet or change its description. |
create_wallet_transfer | Move 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
| Permission | Description |
|---|---|
create_conversion_quote | Get a locked exchange-rate quote between two currencies. |
conversion_quotes | List previously generated quotes. |
create_conversion_order | Execute a conversion against a quote. |
conversions | List conversion history. |
payments_fees | Read fee schedule for deposits / withdrawals. |
trading_fees | Read trading fee tiers per instrument. |
payments_limits | Payment limits. |
payments | List deposit / withdrawal history. |
payments_routes | List available deposit / withdrawal methods and bank details. |
create_withdrawal_crypto | Initiate a crypto withdrawal to an external address. |
create_withdrawal_fiat | Initiate a fiat withdrawal via bank transfer. |
deposit_bank_details_fiat | Read bank account details for fiat deposits. |
deposit_addresses_crypto | Generate / read crypto deposit addresses. |
estimate_network_fee | Estimate the on-chain network fee for a pending withdrawal. |
Orders and trades
| Permission | Description |
|---|---|
create_order | Place spot orders (market, limit, stop). |
cancel_order | Cancel a single open order or all orders. |
open_orders | List currently open spot orders. |
closed_orders | List filled / cancelled spot orders. |
estimate_order | Preview cost, fees, and slippage before placing an order. |
trades | List executed trades / fills. |
instruments | List trading pairs with metadata and current prices. |
currencies | List supported currencies. |
trading_limits | Read user's per-instrument trading limits. |
Vaults
| Permission | Description |
|---|---|
vaults | List available yield vaults. |
vaults_accounts | Read user's vault account balances. |
vaults_transactions | Read vault deposit / withdrawal history. |
create_vault_deposit | Deposit funds into a vault. |
create_vault_withdrawal | Withdraw funds from a vault. |
vaults_transactions_requests | List pending vault transactions. |
cancel_vault_transaction_request | Cancel a pending vault transaction. |
estimate_vault_interests | Estimate yield on a planned vault deposit. |
Derivatives
| Permission | Description |
|---|---|
derivatives_instruments | List perpetual swap contracts. |
open_derivatives_orders | List currently open margin orders. |
closed_derivatives_orders | List filled / cancelled margin orders. |
create_derivatives_order | Place a margin / perpetual order. |
cancel_derivatives_order | Cancel a margin order. |
estimate_derivatives_order | Preview a margin order before placing. |
open_derivatives_positions | List currently open margin positions. |
closed_derivatives_positions | List historical (closed) margin positions. |
update_open_derivatives_position | Adjust take-profit / stop-loss / leverage on an open position. |
derivatives_funding_history | Read funding fees paid / earned over time. |
mutationcreate_api_keyCreate a new API key.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
name | String | optional | Key name. Letters and digits, optionally separated by single spaces, - or _. |
expires_at | String! | required | Expiry date-time; must be in the future. Tokens issued by service_signin for this key expire at the same moment. |
is_active | ToggleSwitch! | required | Whether the key is active. |
type | ApiKeyTypes! | required | Key type. A trader can only create trader keys. |
ip_address | [String!] | optional | IP allow-list: 1 to 3 IP addresses. A trader key requires a non-empty list. |
permissions | [Permission!]! | required | Permission 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_required | ToggleSwitch | optional | When 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.
| Field | Type | Description |
|---|---|---|
api_key_id | String! | Newly created API key (public key) |
api_key_secret | String! | 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);mutationupdate_api_keyRename, expire, enable/disable, change permissions of an existing key.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
name | String | optional | New key name. |
expires_at | String | optional | New expiration date |
is_active | ToggleSwitch | optional | Enable or disable the key |
api_key_id | String! | required | ID of the API key to update |
ip_address | [String!] | optional | Replacement IP allow-list: 1 to 3 IP addresses. |
permissions | [Permission!] | optional | Replacement permission list (lowercase identifiers). |
hmac_required | ToggleSwitch | optional | Enable / 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);mutationdelete_api_keyRevoke an API key.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
api_key_id | String! | required | ID 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);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
idfield on every frame keeps streams separated. - Sign in again before the token expires. A token expires together with its API key (
expires_atreturned byservice_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_ordersafter reconnectingall_orders) so you do not miss updates that occurred while disconnected.
subscriptionorderbookReal-time spot order book.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
instrument_id | String! | required | Instrument to subscribe to. |
Each update
Fields of OrderbookUpdateResult selected in the operation below.
| Field | Type | Description |
|---|---|---|
instrument_id | String! | 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.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
instruments | [String!] | optional | Instrument IDs to follow; omit for all. |
Each update
Fields of Order selected in the operation below.
| Field | Type | Description |
|---|---|---|
order_id | String! | Order whose status changed. |
status | OrderStatus! | New order status. |
updated_at | String! | Update timestamp. |
GraphQL Operation
subscription all_orders {
all_orders {
order_id status updated_at
}
}
subscriptioninstrument_priceReal-time price ticks for spot instruments.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
instrument_id | String | optional | Instrument to follow; omit for all instruments. |
Each update
Fields of InstrumentPrice selected in the operation below.
| Field | Type | Description |
|---|---|---|
instrument_id | String! | The instrument this tick is for. |
ask | Float | Best ask price. |
bid | Float | Best bid price. |
price_24h_change | Float | Percent change over the last 24 hours. |
ts_iso | String! | 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.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
instrument_id | String! | required | Instrument to subscribe to. |
periodicity | InstrumentHistoryPeriodicity! | required | Bar interval. |
Each update
Fields of InstrumentPriceHistory selected in the operation below.
| Field | Type | Description |
|---|---|---|
instrument_id | String! | Instrument the bar applies to. |
open | Float! | Open price. |
high | Float! | High price. |
low | Float! | Low price. |
close | Float! | Close price. |
ts_iso | String! | 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).
Every message is a full snapshot of the book (not a delta). ts is the UTC timestamp in milliseconds, as a string.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
instrument_id | String! | required | Instrument to subscribe to. |
Each update
Fields of OrderbookUpdateResult selected in the operation below.
| Field | Type | Description |
|---|---|---|
instrument_id | String! | Instrument for this book |
ts | String! | 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.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
instrument_id | String! | required | Instrument to subscribe to. |
periodicity | MarginInstrumentHistoryPeriodicity! | required | Bar interval. |
Each update
Fields of MarginInstrumentPriceHistory selected in the operation below.
| Field | Type | Description |
|---|---|---|
margin_instrument_id | String! | Contract this bar applies to. |
open | Float | Open price. |
high | Float | High price. |
low | Float | Low price. |
close | Float | Close price. |
updated_at_iso | String! | 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.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
wallet_id | String | optional | Wallet to follow. Defaults to MAIN. |
Each update
Fields of MarginOrder selected in the operation below.
| Field | Type | Description |
|---|---|---|
margin_order_id | String! | The order whose state changed. |
margin_position_id | String | Linked position, if any. |
instrument_id | String! | Contract symbol. |
side | MarginPositionSide! | buy or sell. |
type | MarginOrderType! | market or limit. |
status | MarginOrderStatus! | New order status. |
leverage | Int! | Leverage applied. |
quantity | Float! | Order quantity. |
executed_quantity | Float! | Quantity filled so far. |
price | Float | Order price. |
limit_price | Float | Limit / stop price. |
stop_loss | Float | Stop-loss price. |
take_profit | Float | Take-profit price. |
fee_amount | Float | Fee charged so far. |
time_in_force | MarginOrderTimeInForce! | Time in force (fok, ioc, gtc, gtd). |
updated_at_iso | String! | Update timestamp (ISO-8601). |
wallet_id | String | Wallet 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.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
wallet_id | String | optional | Wallet to follow. Defaults to MAIN. |
Each update
Fields of MarginPosition selected in the operation below.
| Field | Type | Description |
|---|---|---|
margin_position_id | String! | Position the update applies to. |
instrument_id | String! | Contract symbol. |
side | MarginPositionSide! | buy (long) or sell (short). |
amount | Float! | Current position size. |
leverage | Int! | Leverage on the position. |
entry_price | Float! | Average entry price. |
exit_price | Float | Realised exit price (for closed legs). |
pnl | Float! | Unrealised P&L. |
total_pnl | Float! | Realised + unrealised P&L. |
margin | Float | Margin allocated to the position. |
margin_currency_id | String! | Currency of the margin. |
funding_fee_amount | Float! | Funding fee paid / received. |
stop_loss | Float | Stop-loss price. |
take_profit | Float | Take-profit price. |
close_reason | String | Close reason text (when closing). |
close_reason_code | String | Close reason machine code. |
updated_at_iso | String! | Update timestamp (ISO-8601). |
wallet_id | String | Wallet 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.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
wallet_id | String | optional | Wallet to follow. Defaults to MAIN. |
Each update
Fields of UserBalanceDetails selected in the operation below.
| Field | Type | Description |
|---|---|---|
free_balance | Float! | Available balance. |
equity | Float! | Total equity (balance + unrealised P&L). |
currently_used_margin | Float! | Margin currently locked by open positions. |
margin_call_left_margin | Float! | Margin remaining before margin call. |
liquidation_left_margin | Float! | Margin remaining before liquidation. |
margin_ratio_percentage | Float | Current margin ratio %. |
pnl | Float! | Unrealised P&L. |
total_pnl | Float! | Realised + unrealised P&L. |
unsettled_balance | Float | Balance 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.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
wallet_id | String | optional | Wallet to follow. Defaults to MAIN. |
Each update
Fields of MarginUserUpdate selected in the operation below.
| Field | Type | Description |
|---|---|---|
notification | MarginUserUpdateNotification! | Notification payload. |
GraphQL Operation
subscription margin_user_update {
margin_user_update {
notification { title body trigger }
}
}
subscriptionstop_preset_updateUpdates to the user's stop presets.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
wallet_id | String | optional | Wallet filter. |
Each update
Fields of MarginPositionStopPreset selected in the operation below.
| Field | Type | Description |
|---|---|---|
preset_id | String! | |
margin_position_id | String | |
order_id | String | Set for presets configured at order creation, before the position exists |
instrument_id | String! | |
preset_type | StopPresetType! | |
status | StopPresetStatus! | |
trigger_price | Float! | |
target_sl_price | Float | |
created_at | String! | |
updated_at | String! |
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.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
wallet_id | String | optional | Wallet filter. |
Each update
Fields of StopMarginOrder selected in the operation below.
| Field | Type | Description |
|---|---|---|
stop_order_id | String! | |
instrument_id | String! | |
side | MarginPositionSide! | |
stop_order_type | StopOrderType! | |
status | StopOrderStatus! | |
termination_reason | AdvancedOrderTerminationReason | |
termination_detail | String | |
quantity | Float! | |
leverage | Int! | |
wallet_id | String! | |
trigger_price | Float | |
trigger_direction | StopOrderTriggerDirection | |
limit_price | Float | |
retracement_type | TrailingStopRetracementType | |
callback_rate | Float | |
callback_distance | Float | |
activation_price | Float | |
best_price | Float | |
is_activated | Boolean | |
take_profit | Float | |
stop_loss | Float | |
autoscale_tp_sl | Boolean! | |
created_at | String! | |
updated_at | String! |
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.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
wallet_id | String | optional | Wallet filter. |
Each update
Fields of OcoMarginOrder selected in the operation below.
| Field | Type | Description |
|---|---|---|
oco_order_id | String! | |
instrument_id | String! | |
side | MarginPositionSide! | |
status | OcoOrderStatus! | |
termination_reason | AdvancedOrderTerminationReason | |
termination_detail | String | |
quantity | Float! | |
leverage | Int! | |
wallet_id | String! | |
tp_trigger_price | Float! | |
tp_trigger_direction | StopOrderTriggerDirection! | |
tp_order_type | MarginOrderType! | |
tp_limit_price | Float | |
sl_trigger_price | Float! | |
sl_trigger_direction | StopOrderTriggerDirection! | |
sl_order_type | MarginOrderType! | |
sl_limit_price | Float | |
triggered_leg | OcoTriggeredLeg | |
created_at | String! | |
updated_at | String! |
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.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
wallet_id | String | optional | Wallet filter. |
Each update
Fields of OtoMarginOrder selected in the operation below.
| Field | Type | Description |
|---|---|---|
oto_order_id | String! | |
instrument_id | String! | |
side | MarginPositionSide! | |
status | OtoOrderStatus! | |
leverage | Int! | |
wallet_id | String! | |
primary_order_type | MarginOrderType! | |
primary_price | Float | |
primary_quantity | Float! | |
secondary_side | MarginPositionSide! | |
secondary_order_type | MarginOrderType! | |
secondary_price | Float | |
secondary_quantity | Float! | |
primary_order_id | String | |
secondary_order_id | String | |
termination_reason | AdvancedOrderTerminationReason | |
termination_detail | String | |
created_at | String! | |
updated_at | String! |
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.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
wallet_id | String | optional | Wallet filter. |
Each update
Fields of TWAPMarginOrder selected in the operation below.
| Field | Type | Description |
|---|---|---|
twap_order_id | String! | |
instrument_id | String! | |
side | MarginPositionSide! | |
status | TWAPOrderStatus! | |
termination_reason | AdvancedOrderTerminationReason | |
termination_detail | String | |
total_quantity | Float! | |
executed_quantity | Float! | |
frequency | TWAPFrequency! | |
duration | Int! | |
total_slices | Int! | |
execution_strategy | TWAPExecutionStrategy! | |
slice_order_type | MarginOrderType! | |
start_time | String! | |
end_time | String! | |
next_execution_time | String | |
limit_price | Float | |
price_tolerance_percent | Float | |
slices_executed | Int! | |
slices_failed | Int! | |
average_execution_price | Float | |
leverage | Int! | |
wallet_id | String! | |
created_at | String! | |
updated_at | String! | |
progress_percent | Float! |
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.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
wallet_id | String | optional | Wallet filter. |
Each update
Fields of IcebergMarginOrder selected in the operation below.
| Field | Type | Description |
|---|---|---|
iceberg_order_id | String! | |
instrument_id | String! | |
side | MarginPositionSide! | |
status | IcebergOrderStatus! | |
termination_reason | AdvancedOrderTerminationReason | |
termination_detail | String | |
total_quantity | Float! | |
executed_quantity | Float! | |
display_quantity | Float! | |
placement_type | IcebergPlacementType! | |
limit_price | Float | |
leverage | Int! | |
wallet_id | String! | |
average_execution_price | Float | |
created_at | String! | |
updated_at | String! |
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.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
wallet_id | String | optional | Wallet filter. |
Each update
Fields of ScaledMarginOrder selected in the operation below.
| Field | Type | Description |
|---|---|---|
scaled_order_id | String! | |
instrument_id | String! | |
side | MarginPositionSide! | |
status | ScaledOrderStatus! | |
termination_reason | AdvancedOrderTerminationReason | |
termination_detail | String | |
total_quantity | Float! | |
executed_quantity | Float! | |
number_of_orders | Int! | |
price_range_start | Float! | |
price_range_end | Float! | |
leverage | Int! | |
wallet_id | String! | |
average_execution_price | Float | |
orders_executed | Int! | |
orders_failed | Int! | |
created_at | String! | |
updated_at | String! |
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.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
source_currency_id | String! | required | Source currency ID |
target_currency_id | String! | required | Target currency ID |
source_currency_amount | Float | optional | Amount to convert from source |
target_currency_amount | Float | optional | Amount to receive in target |
instrument_id | String | optional | Restrict the quote to this instrument. |
fees_in_price | Boolean | optional default true | When true (default), the user's taker fee is included in the quoted price. |
reference | String | optional | Client reference. |
ttl | Int | optional | Quote lifetime in seconds. Defaults to, and may not exceed, the instrument's maximum quote TTL. |
dry_run | ToggleSwitch | optional 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.
| Field | Type | Description |
|---|---|---|
conversion_quote_id | String! | Unique quote ID |
price | Float! | Exchange rate |
expires_at_iso | String! | Expiry time (ISO 8601). |
source_currency_amount | Float! | Amount in the source currency. |
target_currency_amount | Float! | 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);mutationcreate_conversion_orderExecute a conversion against a quote.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
conversion_quote_id | String! | required | Conversion quote ID from create_conversion_quote |
reference | String | optional | Client reference. |
source_currency_amount | Float | optional | Execute 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_amount | Float | optional | Execute only part of the quote (give at most one of the two amounts). |
return_on_complete | Boolean | optional default true | When true (default), the response is returned once the conversion has completed; with false it is returned immediately. |
wallet_id | String | optional | Wallet ID. |
Response
Fields of Conversion selected in the operation below.
| Field | Type | Description |
|---|---|---|
conversion_id | String! | Conversion ID. |
status | ConversionStatus! | Conversion status. |
created_at | String! | Creation time. |
price | Float! | Price. |
source_currency_id | String! | Currency converted from. |
target_currency_id | String! | Currency converted to. |
source_currency_amount | Float! | Amount in the source currency. |
target_currency_amount | Float! | 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);queryconversionsList conversion history.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
search | String | optional | Search term. |
reference | String | optional | Client reference. |
status_in | [ConversionStatus!] | optional | Filter: status in list. |
conversion_quote_id | String | optional | Filter by conversion_quote_id. |
source_currency_id | String | optional | Filter by source_currency_id. |
target_currency_id | String | optional | Filter by target_currency_id. |
pager | PagerInput | optional default {limit: 30, offset: 0} | Pagination (limit, offset). |
sort | SortInput | optional default {direction: DESC} | Sort order. |
dateRange | DateRangeInput | optional 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. |
serialIdRange | SerialIdRangeInput | optional default {} | Filter by serial ID range. |
wallet_id | String | optional | Wallet filter. |
instrument_id | String | optional | Instrument filter. |
currency_id | String | optional | Currency filter. |
Response
Fields of Conversion selected in the operation below.
| Field | Type | Description |
|---|---|---|
conversion_id | String! | Conversion ID |
source_currency_id | String! | Currency converted from. |
source_currency_amount | Float! | Amount in the source currency. |
target_currency_id | String! | Currency converted to. |
target_currency_amount | Float! | Amount in the target currency. |
price | Float! | Price. |
status | ConversionStatus! | Status. |
created_at_iso | String! | 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);querypayments_feesRead fee schedule for deposits / withdrawals.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
payment_route_id | String | optional | Filter by payment_route_id. |
currency_id | String | optional | Currency filter. |
pager | PagerInput | optional default {limit: 30, offset: 0} | Pagination (limit, offset). |
sort | SortInput | optional default {direction: DESC} | Sort order. |
calculation_type | FeeCalculationType | optional | Filter by calculation_type. |
Response
Fields of PaymentFee selected in the operation below.
| Field | Type | Description |
|---|---|---|
currency_id | String! | Currency code (BTC, ETH, USD, etc.) |
deposit_flat_fee | Float | Fixed fee for deposits |
deposit_progressive_fee | Float | Percentage-based deposit fee |
payment_route_id | String | Payment processor route identifier |
calculation_type | FeeCalculationType | How 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);querytrading_feesRead trading fees per instrument.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
instrument_id | String | optional | Instrument filter. |
pager | PagerInput | optional default {limit: 30, offset: 0} | Pagination (limit, offset). |
sort | SortInput | optional default {direction: DESC} | Sort order. |
Response
Fields of TradingFee selected in the operation below.
| Field | Type | Description |
|---|---|---|
instrument_id | String! | Instrument. |
maker_flat | Float! | Maker fee, flat part. |
maker_progressive | Float! | Maker fee, proportional part. |
taker_flat | Float! | Taker fee, flat part. |
taker_progressive | Float! | 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);mutationcalculate_payments_limitsCalculate the user's daily / weekly / monthly payment limits.
Declared as a mutation even though it only reads data.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
notion_currency | String! | required | Currency the limits are expressed in. |
currency_id | String! | required | Currency of the payment. |
type | PaymentType! | required | deposit or withdrawal. |
Response
Fields of LimitsStatus selected in the operation below.
| Field | Type | Description |
|---|---|---|
payments | LimitsStatusPeriods! | Payment limits by period (daily, weekly, monthly) |
aggregated | LimitsStatusPeriods | Aggregated 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);querypaymentsList deposit / withdrawal history.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
payment_id | String | optional | Filter by payment_id. |
remote_txid | String | optional | Filter by remote_txid. |
currency_id | String | optional | Currency filter. |
type | PaymentType | optional | Filter by payment type (deposit, withdrawal) |
payment_id_in | [String!] | optional | Filter: payment_id in list. |
payment_id_not_in | [String!] | optional | Filter: payment_id not in list. |
search | String | optional | Search term. |
status | [PaymentStatus!] | optional | Filter by payment status |
pager | PagerInput | optional default {limit: 30, offset: 0} | Pagination (limit, offset). |
sort | SortInput | optional default {direction: DESC} | Sort order. |
dateRange | DateRangeInput | optional 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. |
serialIdRange | SerialIdRangeInput | optional default {} | Filter by serial ID range. |
currency_type | CurrencyType | optional | Filter by currency_type. |
quote_currency_id | String | optional | Filter by quote_currency_id. |
reference | String | optional | Client reference. |
wallet_id | String | optional | Wallet filter. |
Response
Fields of Payment selected in the operation below.
| Field | Type | Description |
|---|---|---|
payment_id | String! | Payment ID |
currency_id | String! | Currency. |
amount | Float! | Amount. |
type | PaymentType! | Deposit or withdrawal |
status | PaymentStatus! | Status. |
crypto_transaction_id | String | On-chain transaction hash. |
crypto_address | String | Destination (withdrawal) or deposit address. |
fee_amount | Float | Fee amount. |
created_at | String! | 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);querypayments_routesList available deposit / withdrawal methods.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
payment_route_id | String | optional | Filter by payment_route_id. |
currency_id | String | optional | Currency filter. |
crypto_network | String | optional | Filter by network. |
verification_type | VerificationType | optional | Filter by verification_type. |
currency_type | CurrencyType | optional | Filter by currency_type. |
pager | PagerInput | optional default {limit: 30, offset: 0} | Pagination (limit, offset). |
sort | SortInput | optional default {direction: DESC} | Sort order. |
Response
Fields of PaymentRoute selected in the operation below.
| Field | Type | Description |
|---|---|---|
payment_route_id | String! | Unique payment route identifier |
currency_id | String! | Currency code |
name | String | Payment route name (e.g., Bank Transfer, Crypto Network) |
crypto_network | String | Network. |
crypto_address_generate_new | ToggleSwitch | Deposit-address generation setting of the route (on / off). |
crypto_address_tag_type | CryptoAddressTagType | Address tag type used on this route. |
fiat_iframe_deposit_url | String | Hosted deposit page URL, for routes that use one. |
fiat_iframe_withdrawal_url | String | Hosted withdrawal page URL, for routes that use one. |
fiat_transfer_type | String | Fiat transfer type. |
is_active | ToggleSwitch! | Whether this route is currently available |
extend_network_fee | ToggleSwitch | When on, the estimated network fee is added to the withdrawal fee. |
verification_type | VerificationType | Verification required for withdrawals on this route. |
deposit_enabled | ToggleSwitch | Indicates if deposits enabled on this route |
withdrawal_enabled | ToggleSwitch | Indicates if withdrawals enabled on this route |
is_crypto_to_fiat | ToggleSwitch | Indicates 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);mutationcreate_withdrawal_cryptoInitiate a crypto withdrawal to an external address.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
payment_route_id | String | optional | Payment route to use. If omitted, the route is resolved from currency_id (+ optional crypto_network). |
currency_id | String | optional | Currency ID. |
crypto_network | String | optional | Network to withdraw on (used to resolve the route when payment_route_id is omitted). |
amount | Float! | required | Amount to withdraw |
crypto_address | String! | required | Recipient wallet address |
crypto_address_tag_type | CryptoAddressTagType | optional | Tag type (memo, destination tag) |
crypto_address_tag_value | String | optional | Tag value (memo or destination tag) |
crypto_network_fee_preference | CryptoNetworkFeePreference | optional default medium | Network fee level (low, medium, high). Defaults to medium. |
reference | String | optional | Client reference. |
mfa_token | String | optional | MFA code, when the account requires one. |
fees_included | ToggleSwitch | optional default on | Include fees in withdrawal amount |
bank_id_session | String | optional | BankID session, when the payment route requires BankID verification. |
passkey_response | JSONObject | optional | Passkey assertion, when the payment route requires passkey verification. |
comment | String | optional | Free-text comment stored with the payment. |
message | String | optional | Optional note stored with the withdrawal. |
travel_rule_properties | TravelRulePropertiesArgs | optional | Travel-rule data; used only when travel rule is enabled on the platform. |
wallet_id | String! | optional default "MAIN" | Source wallet. Defaults to MAIN. |
vasp_id | String | optional | Beneficiary VASP; applied only together with travel_rule_properties. |
Response
Fields of Payment selected in the operation below.
| Field | Type | Description |
|---|---|---|
payment_id | String! | Payment/withdrawal ID |
currency_id | String! | Currency. |
amount | Float! | Amount. |
status | PaymentStatus! | Withdrawal status |
crypto_transaction_id | String | On-chain transaction hash. |
crypto_address | String | Destination (withdrawal) or deposit address. |
fee_amount | Float | Fee amount. |
created_at | String! | 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);mutationcreate_withdrawal_fiatInitiate a fiat withdrawal via bank transfer.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
amount | Float! | required | Amount to withdraw |
payment_route_id | String | optional | Payment route to use. If omitted, the route is resolved from currency_id. |
currency_id | String | optional | Currency ID. |
mfa_token | String | optional | MFA code, when the account requires one. |
passkey_response | JSONObject | optional | Passkey 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_id | String! | optional default "MAIN" | Source wallet. Defaults to MAIN. |
vasp_id | String | optional | Beneficiary VASP. |
message | String | optional | Free-text message stored on the payment. |
Response
Fields of Payment selected in the operation below.
| Field | Type | Description |
|---|---|---|
payment_id | String! | Payment/withdrawal ID |
amount | Float! | Amount. |
status | PaymentStatus! | Status. |
created_at | String! | 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);querydeposit_address_cryptoGet (or generate, if none exists) a crypto deposit address.
Declared as a query, but generates a new address when none exists yet.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
currency_id | String! | required | Currency filter. |
network | String | optional | Network of the address. |
reference | String | optional | Client reference. |
address_type | String | optional | Address type. |
payment_route_id | String | optional | Payment route ID for the currency |
Response
Fields of DepositAddressCrypto selected in the operation below.
| Field | Type | Description |
|---|---|---|
deposit_address_crypto_id | String! | Deposit address ID. |
currency_id | String! | Currency. |
address | String | Deposit wallet address |
address_tag_type | CryptoAddressTagType | Tag type (memo, destination tag, etc.) |
address_tag_value | String | Address tag / memo value, for networks that use one. |
network | String | Blockchain network |
created_at | String! | 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);Orders & Trades
Place and manage spot orders, browse instruments, and preview order cost before placement.
mutationcreate_orderPlace a spot order (market, limit, stop).
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
wallet_id | String! | optional default "MAIN" | Wallet to trade from. Defaults to MAIN. |
client_order_id | String | optional | Client-supplied order identifier. |
instrument_id | String! | required | Instrument ID. |
quantity | Float! | required | Order quantity in base currency |
quantity_mode | OrderQuantityMode | optional default base | base (default) or quote; quote is allowed only with fok / ioc. |
type | OrderType! | required | market, limit, stop_market or stop_limit. |
side | OrderSide! | required | Order side: buy or sell |
time_in_force | OrderTimeInForce! | required | Required. market: fok or ioc. limit / stop_market / stop_limit: any value; gtd requires expires_at. |
price | Float | optional | Order price (limit / stop_limit orders). |
expires_at | String | optional | ISO date-time; required when time_in_force is gtd (at least 5 s in the future), ignored otherwise. |
notes | String | optional | Free-text note. Cannot be combined with post_only. |
stop_price | Float | optional | Required and positive for stop_limit / stop_market. |
post_only | ToggleSwitch | optional | Applies to limit orders only. |
take_profit | ConditionalOrderLegInput | optional | Take-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_loss | ConditionalOrderLegInput | optional | Stop-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.
| Field | Type | Description |
|---|---|---|
order_id | String! | Unique order ID |
type | OrderType! | Type. |
side | OrderSide! | Side (buy / sell). |
status | OrderStatus! | Order status. |
price | Float | Price. |
stop_price | Float | Trigger price for stop orders. |
quantity | Float! | Quantity. |
executed_quantity | Float! | Executed quantity. |
remaining_quantity | Float! | Quantity not yet executed. |
quantity_mode | OrderQuantityMode! | base or quote: which currency quantity is expressed in. |
instrument_id | String! | Instrument. |
message | String | Status / rejection message. |
updated_at | String! | Last update time. |
created_at | String! | Order creation timestamp |
expires_at | String | Expiry time. |
expires_at_iso | String | Expiry time (ISO 8601). |
time_in_force | OrderTimeInForce! | Time in force. |
vwap | Float | Volume-weighted average execution price. |
wallet_id | String | Wallet. |
instrument | Instrument | Instrument 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);mutationcancel_orderCancel a single open spot order.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
order_id | String! | required | Order ID to cancel |
message | String | optional | Optional 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);mutationupdate_open_orderAmend an open spot order's quantity, price, stop price or expiry.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
order_id | String! | required | Order to amend. |
quantity | Float! | required | New quantity (required, restate it if unchanged). |
price | Float | optional | New limit price. |
stop_price | Float | optional | New stop price. |
expires_at | String | optional | New expiry for gtd orders. |
Response
Fields of Order selected in the operation below.
| Field | Type | Description |
|---|---|---|
order_id | String! | |
status | OrderStatus! | |
price | Float | |
stop_price | Float | |
quantity | Float! | |
expires_at | String |
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);mutationcancel_multiple_ordersCancel several open spot orders in one call.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
order_ids | [String!]! | required | Orders to cancel. |
message | String | optional | Optional 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);mutationcancel_all_ordersCancel all of the user's open spot orders.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
wallet_id | String | optional | Only 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);mutationcreate_conditional_orderPlace a standalone spot take-profit, stop-loss or OCO (both legs) on a quantity you hold.
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
| Name | Type | Required | Description |
|---|---|---|---|
wallet_id | String! | optional default "MAIN" | Wallet to act on; defaults to MAIN. |
client_conditional_order_id | String | optional | Your own id for this condition. |
instrument_id | String! | required | Spot instrument. |
side | OrderSide! | required | Order side. |
quantity | Float! | required | Quantity to protect. |
quantity_mode | OrderQuantityMode! | optional default base | Whether quantity is in base or quote currency. |
take_profit | ConditionalOrderLegInput | optional | Take-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_loss | ConditionalOrderLegInput | optional | Stop-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_at | DateTime | optional | Optional expiry (ISO 8601). |
Response
Fields of ConditionalOrder selected in the operation below.
| Field | Type | Description |
|---|---|---|
serial_id | Int | Internal monotonically increasing database identifier. |
conditional_order_id | String! | Globally unique conditional-order identifier. |
client_conditional_order_id | String | Optional ID supplied by the client for reconciliation. |
wallet_id | String! | Wallet that owns the collateral reservation. |
instrument_id | String! | Instrument monitored by the trigger engine. |
entry_order_id | String | Ordinary entry order that activates this condition as it fills. |
attachment_type | ConditionalOrderAttachmentType! | Whether this condition is standalone or attached to an entry order. |
type | ConditionalOrderType! | Derived shape: Take Profit, Stop Loss, or OCO. |
side | OrderSide! | Side of each spot child order created by a triggered leg. |
quantity_mode | OrderQuantityMode! | Unit used by the quantity fields. |
requested_quantity | Float! | Total quantity originally requested by the client. |
activated_quantity | Float! | Entry-order quantity currently activated for protection; equals requested_quantity for standalone orders. |
executed_quantity | Float! | Cumulative quantity executed by conditional child orders. |
remaining_quantity | Float! | Activated quantity that still requires protection or execution. |
status | ConditionalOrderStatus! | Current parent lifecycle status. |
status_reason | String | Machine-readable or diagnostic reason for the current status. |
expires_at | DateTime | Expiry passed to a future GTD limit child order. |
created_at | DateTime! | Time at which the conditional order was created. |
updated_at | DateTime! | 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);mutationcancel_conditional_orderCancel an untriggered conditional order and release its reserved quantity.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
conditional_order_id | String! | required | Conditional order. |
Response
Fields of ConditionalOrder selected in the operation below.
| Field | Type | Description |
|---|---|---|
serial_id | Int | Internal monotonically increasing database identifier. |
conditional_order_id | String! | Globally unique conditional-order identifier. |
client_conditional_order_id | String | Optional ID supplied by the client for reconciliation. |
wallet_id | String! | Wallet that owns the collateral reservation. |
instrument_id | String! | Instrument monitored by the trigger engine. |
entry_order_id | String | Ordinary entry order that activates this condition as it fills. |
attachment_type | ConditionalOrderAttachmentType! | Whether this condition is standalone or attached to an entry order. |
type | ConditionalOrderType! | Derived shape: Take Profit, Stop Loss, or OCO. |
side | OrderSide! | Side of each spot child order created by a triggered leg. |
quantity_mode | OrderQuantityMode! | Unit used by the quantity fields. |
requested_quantity | Float! | Total quantity originally requested by the client. |
activated_quantity | Float! | Entry-order quantity currently activated for protection; equals requested_quantity for standalone orders. |
executed_quantity | Float! | Cumulative quantity executed by conditional child orders. |
remaining_quantity | Float! | Activated quantity that still requires protection or execution. |
status | ConditionalOrderStatus! | Current parent lifecycle status. |
status_reason | String | Machine-readable or diagnostic reason for the current status. |
expires_at | DateTime | Expiry passed to a future GTD limit child order. |
created_at | DateTime! | Time at which the conditional order was created. |
updated_at | DateTime! | 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);queryconditional_ordersList the user's spot conditional orders.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
instrument_id | String | optional | Instrument filter. |
wallet_id | String | optional | Wallet filter. |
status | [ConditionalOrderStatus!] | optional | Status filter (several allowed). |
pager | PagerInput | optional default {limit: 30, offset: 0} | Pagination (limit, offset). |
Response
Fields of ConditionalOrder selected in the operation below.
| Field | Type | Description |
|---|---|---|
serial_id | Int | Internal monotonically increasing database identifier. |
conditional_order_id | String! | Globally unique conditional-order identifier. |
client_conditional_order_id | String | Optional ID supplied by the client for reconciliation. |
wallet_id | String! | Wallet that owns the collateral reservation. |
instrument_id | String! | Instrument monitored by the trigger engine. |
entry_order_id | String | Ordinary entry order that activates this condition as it fills. |
attachment_type | ConditionalOrderAttachmentType! | Whether this condition is standalone or attached to an entry order. |
type | ConditionalOrderType! | Derived shape: Take Profit, Stop Loss, or OCO. |
side | OrderSide! | Side of each spot child order created by a triggered leg. |
quantity_mode | OrderQuantityMode! | Unit used by the quantity fields. |
requested_quantity | Float! | Total quantity originally requested by the client. |
activated_quantity | Float! | Entry-order quantity currently activated for protection; equals requested_quantity for standalone orders. |
executed_quantity | Float! | Cumulative quantity executed by conditional child orders. |
remaining_quantity | Float! | Activated quantity that still requires protection or execution. |
status | ConditionalOrderStatus! | Current parent lifecycle status. |
status_reason | String | Machine-readable or diagnostic reason for the current status. |
expires_at | DateTime | Expiry passed to a future GTD limit child order. |
created_at | DateTime! | Time at which the conditional order was created. |
updated_at | DateTime! | 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);queryconditional_order_policyConditional-order rules for an instrument: enabled, execution types, slippage range, max open conditions.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
instrument_id | String! | required | Spot instrument. |
Response
Fields of ConditionalOrderPolicy selected in the operation below.
| Field | Type | Description |
|---|---|---|
enabled | ToggleSwitch! | |
allow_market_execution | ToggleSwitch! | |
allow_limit_execution | ToggleSwitch! | |
default_price_reference | ConditionalOrderPriceReference! | |
default_slippage_bps | Int! | |
min_slippage_bps | Int! | |
max_slippage_bps | Int! | |
max_open_orders_per_user | Int! | |
trigger_confirmation_ms | Int! |
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);queryopen_ordersList currently open spot orders.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
order_id | String | optional | Filter by order_id. |
client_order_id | String | optional | Filter by client_order_id. |
time_in_force | OrderTimeInForce | optional | Filter by time_in_force. |
type | OrderType | optional | Filter by type. |
side | OrderSide | optional | Filter by side (buy or sell) |
instrument_id | String | optional | Instrument filter. |
message | String | optional | Prefix match on the order message. |
parent_order_id | String | optional | Filter by parent_order_id. |
search | String | optional | Search term. |
status | [OrderStatus!] | optional | Filter by order statuses |
pager | PagerInput | optional default {limit: 30, offset: 0} | Pagination (limit, offset). |
sort | SortInput | optional default {direction: DESC} | Sort order. |
dateRange | DateRangeInput | optional | Filter by creation date (time_from, time_to). |
serialIdRange | SerialIdRangeInput | optional default {} | Filter by serial ID range. |
wallet_id | String | optional | Wallet filter. |
currency_id | String | optional | Currency filter. |
Response
Fields of Order selected in the operation below.
| Field | Type | Description |
|---|---|---|
order_id | String! | Order ID |
type | OrderType! | Type. |
side | OrderSide! | Side (buy / sell). |
status | OrderStatus! | Current order status |
price | Float | Price. |
stop_price | Float | Trigger price for stop orders. |
quantity | Float! | Quantity. |
executed_quantity | Float! | Executed quantity. |
remaining_quantity | Float! | Quantity not yet executed. |
instrument_id | String! | Instrument. |
created_at | String! | Creation time. |
updated_at | String! | Last update time. |
time_in_force | OrderTimeInForce! | Time in force. |
wallet_id | String | Wallet. |
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);queryclosed_ordersList completed / cancelled / rejected / expired spot orders.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
order_id | String | optional | Filter by order_id. |
client_order_id | String | optional | Filter by client_order_id. |
time_in_force | OrderTimeInForce | optional | Filter by time_in_force. |
type | OrderType | optional | Filter by type. |
side | OrderSide | optional | Filter by side (buy or sell) |
instrument_id | String | optional | Instrument filter. |
message | String | optional | Prefix match on the order message. |
parent_order_id | String | optional | Filter by parent_order_id. |
search | String | optional | Search term. |
status | [OrderStatus!] | optional | Filter by order statuses |
pager | PagerInput | optional default {limit: 30, offset: 0} | Pagination (limit, offset). |
sort | SortInput | optional default {direction: DESC} | Sort order. |
dateRange | DateRangeInput | optional | 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. |
serialIdRange | SerialIdRangeInput | optional default {} | Filter by serial ID range. |
wallet_id | String | optional | Wallet filter. |
currency_id | String | optional | Currency filter. |
Response
Fields of Order selected in the operation below.
| Field | Type | Description |
|---|---|---|
order_id | String! | Order ID |
type | OrderType! | Type. |
side | OrderSide! | Side (buy / sell). |
status | OrderStatus! | Final order status |
price | Float | Price. |
quantity | Float! | Quantity. |
executed_quantity | Float! | Executed quantity. |
instrument_id | String! | Instrument. |
created_at | String! | Creation time. |
updated_at | String! | Last update time. |
total | Float | Get 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);querytradesList the user's spot trades (executions).
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
| Name | Type | Required | Description |
|---|---|---|---|
trade_id | String | optional | Trade filter. |
instrument_id | String | optional | Instrument filter. |
order_id | String | optional | Only trades of this order. |
side | OrderSide | optional | Side filter. |
search | String | optional | Search term. |
pager | PagerInput | optional default {limit: 30, offset: 0} | Pagination (limit, offset). |
sort | SortInput | optional default {direction: DESC} | Sort order. |
dateRange | DateRangeInput | optional default {} | Date range; see the note above. |
serialIdRange | SerialIdRangeInput | optional default {} | Serial id range. |
wallet_id | String | optional | Wallet filter. |
Response
Fields of Trade selected in the operation below.
| Field | Type | Description |
|---|---|---|
trade_id | String! | |
order_id | String! | |
instrument_id | String! | |
side | OrderSide | |
quantity | Float! | |
price | Float! | |
created_at_iso | String! | |
wallet_id | String |
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);queryestimate_orderPreview price, quantity and fees before placing an order.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
source_currency_id | String! | required | Source currency ID (the one being spent) |
source_currency_amount | Float | optional | Amount in source currency |
target_currency_id | String! | required | Target currency ID (the one being received) |
target_currency_amount | Float | optional | Amount in target currency |
price | Float | optional | Expected price |
instrument_id | String | optional | Instrument filter. |
Response
Fields of EstimateOrderResult selected in the operation below.
| Field | Type | Description |
|---|---|---|
type | OrderType! | Estimated order type |
price | Float! | Estimated price |
quantity | Float! | Quantity. |
side | OrderSide! | Side (buy / sell). |
quantity_mode | OrderQuantityMode! | 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);queryinstrumentsList trading pairs with metadata and current prices.
Authentication is optional.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
instrument_id | String | optional | Return a single instrument. |
is_active | ToggleSwitch | optional | Filter by active status |
search | String | optional | Search term. |
page | Int | optional | Page number (1-based). |
limit | Int! | optional default 100 | Page size (default 100). |
sort | SortInput | optional default {direction: DESC} | Sort order. |
omit_currencies | [String!] | optional | Filter by omit_currencies. |
Response
Fields of Instrument selected in the operation below.
| Field | Type | Description |
|---|---|---|
name | String! | Instrument name. |
base_currency_id | String! | Base currency of pair |
quote_currency_id | String! | Quote currency of pair |
instrument_id | String! | Unique instrument ID |
quantity_decimals | Int | Quantity precision (decimal places). |
price_decimals | Float! | Price precision (decimal places). |
min_quantity | Float! | Minimum order quantity. |
max_quantity | Float! | Maximum order quantity. |
is_active | ToggleSwitch! | Active flag. |
price | InstrumentPrice | Price. |
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);querycurrenciesList supported currencies.
Authentication is optional.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
search | String | optional | Search term. |
type | CurrencyType | optional | Filter by type. |
is_active | ToggleSwitch | optional | Filter by is_active. |
page | Int | optional | Page number (1-based). |
limit | Int! | optional default 100 | Page size (default 100); applied only when page is set. |
omit_currencies | [String!] | optional | Filter by omit_currencies. |
Response
Fields of Currency selected in the operation below.
| Field | Type | Description |
|---|---|---|
currency_id | String! | Unique currency ID |
name | String | Name. |
precision | Int! | Decimal precision |
type | CurrencyType! | Type. |
is_active | ToggleSwitch! | 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);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.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
vault_id | String | optional | Filter by specific vault |
currency_id | String | optional | Currency filter. |
is_active | ToggleSwitch | optional | Filter by active status. |
withdrawal_enabled | ToggleSwitch | optional | Filter by withdrawal status |
deposit_enabled | ToggleSwitch | optional | Filter by deposit status |
lock_strategy | VaultLockStrategy | optional | Filter by lock_strategy. |
rate_type | VaultRateType | optional | Filter by rate_type. |
withdrawal_policy | VaultWithdrawalPolicy | optional | Filter by withdrawal_policy. |
search | String | optional | Search term. |
pager | PagerInput | optional default {limit: 1000, offset: 0} | Pagination (limit, offset). |
sort | SortInput | optional default {direction: DESC} | Sort order. |
Response
Fields of Vault selected in the operation below.
| Field | Type | Description |
|---|---|---|
serial_id | Int | Sequential record ID. |
vault_id | String! | Vault unique identifier |
currency_id | String! | Currency. |
name | String | Vault name and asset |
annual_rate_percent | Float! | APY percentage |
max_withdrawal_amount | Float! | Maximum withdrawal amount. |
max_deposit_amount | Float! | Maximum deposit amount. |
min_withdrawal_amount | Float! | Minimum withdrawal amount. |
min_deposit_amount | Float! | Minimum deposit required |
cut_off_time_seconds | Int! | The minimum amount of time in seconds before first reward is given |
lock_in_period_seconds | Int | The 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_from | String! | Start of the vault's effective period. |
effective_date_to | String | End of the vault's effective period. |
rate_type | VaultRateType! | Type of rate for the vault, flexible allows to withdraw at any time, fixed has a lock-in period. |
is_active | ToggleSwitch! | Active flag. |
withdrawal_enabled | ToggleSwitch! | Withdrawals enabled. |
deposit_enabled | ToggleSwitch! | Deposits enabled. |
last_interest_at | String | Time interest was last paid. |
created_at | String! | Creation time. |
updated_at | String! | Last update time. |
total_balance | Float! | Total balance. |
withdrawal_policy | VaultWithdrawalPolicy! | 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_seconds | Int | Effective only if withdrawal_policy is delayed. The minimum amount of time before funds are withdrawn to user wallet after a withdrawal request is made. |
meta | String | Additional metadata. |
level5_apy | Float | APY with the level-5 yield boost applied (null when no boost applies). |
currency | Currency | Currency 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);queryvaults_accountsRead the user's vault account balances.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
vault_account_id | String | optional | Specific account filter |
vault_id | String | optional | Vault filter |
currency_id | String | optional | Currency filter. |
hide_zero_balances | ToggleSwitch | optional default off | Filter by hide_zero_balances. |
search | String | optional | Search term. |
pager | PagerInput | optional default {limit: 30, offset: 0} | Pagination (limit, offset). |
sort | SortInput | optional default {direction: DESC} | Sort order. |
wallet_id | String | optional | Wallet filter. |
Response
Fields of VaultAccount selected in the operation below.
| Field | Type | Description |
|---|---|---|
vault_account_id | String! | Account unique ID |
vault_id | String! | Vault. |
balance | Float! | Current vault balance |
free_balance | Float | Account free balance (current balance minus pending requests) |
exposed_vault_balance | Float | Account exposed vault balance |
created_at_iso | String! | Creation time (ISO 8601). |
updated_at_iso | String! | 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);queryvaults_transactionsRead vault deposit / withdrawal / interest history.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
vault_id | String | optional | Vault filter |
vault_transaction_id | String | optional | Specific transaction |
account_transaction_id | String | optional | Filter by account_transaction_id. |
transaction_type | AccountTransactionType | optional | Filter by debit / credit. |
transaction_class | VaultsTransactionClass | optional | Transaction class |
search | String | optional | Search term. |
currency_id | String | optional | Currency filter. |
pager | PagerInput | optional default {limit: 30, offset: 0} | Pagination (limit, offset). |
date_range | DateRangeInput | optional | Date range |
sort | SortInput | optional default {direction: DESC} | Sort order. |
wallet_id | String | optional | Wallet filter. |
Response
Fields of VaultTransaction selected in the operation below.
| Field | Type | Description |
|---|---|---|
vault_transaction_id | String! | Transaction ID |
amount | Float! | Transaction amount |
currency_id | String | Currency. |
transaction_class | VaultsTransactionClass! | Type of transaction |
created_at_iso | String! | Transaction timestamp |
is_delayed | ToggleSwitch | Whether execution is delayed. |
delayed_until_iso | String | Time a delayed transaction is executed (ISO 8601). |
apy | Float | The vault APY (annual percentage yield) that was active at the time of this transaction, or of the request that produced it |
vault | Vault | Vault 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);mutationcreate_vault_depositDeposit funds into a vault.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
vault_id | String! | required | Vault to deposit into |
amount | Float! | required | Deposit amount |
use_all_funds | Boolean | optional | Not used for deposits; amount is always required. |
wallet_id | String! | optional default "MAIN" | Wallet to debit. Defaults to MAIN. |
Response
Fields of VaultRequestResponse selected in the operation below.
| Field | Type | Description |
|---|---|---|
message | String! | Operation message |
status | String! | Operation status |
transaction | VaultTransaction | Executed vault transaction, when the operation was executed immediately. |
request | VaultTransactionRequest | Vault 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);mutationcreate_vault_withdrawalWithdraw funds from a vault.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
vault_id | String! | required | Vault to withdraw from |
amount | Float! | required | Withdrawal amount |
use_all_funds | Boolean | optional | Withdraw the full free vault balance (overrides amount). |
wallet_id | String! | optional default "MAIN" | Wallet to credit. Defaults to MAIN. |
Response
Fields of VaultRequestResponse selected in the operation below.
| Field | Type | Description |
|---|---|---|
message | String! | Withdrawal status message |
status | String! | Request status |
transaction | VaultTransaction | Executed vault transaction, when the operation was executed immediately. |
request | VaultTransactionRequest | Vault 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);queryvaults_transactions_requestsList vault transaction requests.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
serial_id | Int | optional | Filter by serial_id. |
request_id | String | optional | Filter by request_id. |
vault_id | String | optional | Vault filter |
transaction_type | AccountTransactionType | optional | Filter by debit / credit. |
transaction_class | VaultsTransactionClass | optional | Transaction class |
status | VaultTransactionRequestStatus | optional | Filter by status. |
search | String | optional | Search term. |
pager | PagerInput | optional default {limit: 30, offset: 0} | Pagination (limit, offset). |
date_range | DateRangeInput | optional | Date range |
sort | SortInput | optional default {direction: DESC} | Sort order. |
currency_id | String | optional | Currency filter. |
wallet_id | String | optional | Wallet filter. |
Response
Fields of VaultTransactionRequest selected in the operation below.
| Field | Type | Description |
|---|---|---|
serial_id | Int | Sequential record ID. |
request_id | String! | Request identifier |
vault_id | String! | Vault. |
amount | Float! | Request amount |
transaction_class | VaultsTransactionClass! | Transaction class. |
status | VaultTransactionRequestStatus! | Approval status |
created_at_iso | String! | Request timestamp |
updated_at_iso | String! | Last update time (ISO 8601). |
approved_at | String | Approval time. |
vault | Vault! | Vault details. |
apy | Float | The 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);mutationcancel_vault_transaction_requestCancel a pending vault transaction request.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
request_id | String! | required | Request 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);queryestimate_vault_interestsEstimate interest on a planned deposit into a fixed vault.
Fixed vaults only.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
vault_id | String! | required | Vault ID |
amount | Float! | required | Deposit amount |
duration_seconds | Int | optional | Deposit 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);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.
Authentication is optional. Without a token, the default limit group's instrument list is returned.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
search | String | optional | Search term. |
pager | PagerInput | optional default {limit: 30, offset: 0} | Pagination (limit, offset). |
sort | SortInput | optional default {direction: ASC} | Sort order. |
margin_instrument_id | String | optional | Filter by margin_instrument_id. |
is_active | ToggleSwitch | optional | Filter by active status. |
class | MarginInstrumentClass | optional | Filter by instrument class. |
Response
Fields of MarginInstrument selected in the operation below.
| Field | Type | Description |
|---|---|---|
margin_instrument_id | String! | Unique instrument identifier |
name | String! | Instrument display name. |
base_currency_id | String! | Base currency. |
quote_currency_id | String! | Quote currency. |
min_leverage | Int! | Minimum leverage. |
max_leverage | Int! | Maximum leverage. |
min_quantity | Float! | Minimum order quantity. |
max_quantity | Float! | Maximum order quantity. |
price_24h_change | Float | 24-hour price change. |
price_24h_low | Float | 24-hour low. |
price_24h_high | Float | 24-hour high. |
is_trading_on | Boolean! | Whether trading is currently open for the user. |
market_status | MarketStatus! | Current market status. |
class | MarginInstrumentClass! | Instrument class. |
lot_size | Float | Contract lot size. |
step_size | Float! | Quantity step size. |
cross_quote_price | Float | Conversion rate from the instrument's quote currency to the margin currency. |
close_only | ToggleSwitch! | When on, the instrument is in close-only mode. |
base_currency | MarginCurrency | Base currency details. |
quote_currency | MarginCurrency | Quote currency details. |
price | MarginInstrumentPrice | Current bid/ask pricing |
funding_data | MarginInstrumentFundingData | |
meta | String! | Additional metadata. |
market_hours | TraderCalendarData! | 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);querymargin_instruments_pricesCurrent bid and ask of every derivatives instrument.
Response
Fields of MarginInstrumentPrice selected in the operation below.
| Field | Type | Description |
|---|---|---|
margin_instrument_id | String! | |
ask | Float | |
bid | Float | |
updated_at | String! | |
updated_at_iso | String |
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);querymargin_instrument_price_barsOHLC price history (mid price) of a derivatives instrument.
Bars carry their timestamp in updated_at_iso.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
periodicity | MarginInstrumentHistoryPeriodicity | optional default day | Bar interval. |
limit | Int | optional default 1000 | Maximum number of bars. |
date_range | DateRangeInput | optional | Window to read (time_from, time_to). |
instrument_id | String! | required | Derivatives instrument ID (margin_instrument_id from margin_instruments). |
Response
Fields of MarginInstrumentPriceHistory selected in the operation below.
| Field | Type | Description |
|---|---|---|
margin_instrument_id | String! | |
open | Float | |
high | Float | |
low | Float | |
close | Float | |
updated_at_iso | String! |
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);querymargin_advanced_order_types_enabledWhich advanced order types are switched on.
A type reporting false is switched off platform-wide; its create operation is rejected.
Response
Fields of AdvancedOrderTypesEnabled selected in the operation below.
| Field | Type | Description |
|---|---|---|
stop | Boolean! | Stop Market & Stop Limit orders (does not cover Trailing Stop) |
trailing_stop | Boolean! | Trailing Stop orders (independent of `stop`) |
scaled | Boolean! | |
oco | Boolean! | |
oto | Boolean! | |
twap | Boolean! | |
iceberg | Boolean! | |
stop_presets | Boolean! | Stop break-even and stop-win presets on open positions (Smart Protection) |
trailing_presets | Boolean! | Trailing stop presets attached to open positions |
multi_tp_sl | Boolean! | 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);queryopen_margin_ordersList currently open margin orders.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
search | String | optional | Search term. |
pager | PagerInput | optional default {limit: 30, offset: 0} | Pagination (limit, offset). |
sort | SortInput | optional default {direction: ASC} | Sort order. |
dateRange | DateRangeInput | optional default {} | Filter by created_at (format YYYY-MM-DD HH:mm:ss). |
side | MarginPositionSide | optional | buy or sell |
status | MarginOrderStatus | optional | Filter by order status. |
time_in_force | MarginOrderTimeInForce | optional | Filter by time in force. |
type | MarginOrderType | optional | market or limit |
instrument_id | String | optional | Instrument filter. |
instruments_ids | [String!] | optional | Multiple instrument IDs |
wallet_id | String | optional | Wallet filter. |
currency_id | String | optional | Filter orders by base currency ID |
Response
Fields of MarginOrder selected in the operation below.
| Field | Type | Description |
|---|---|---|
margin_order_id | String! | Order unique identifier |
margin_position_id | String | Position the order belongs to. |
instrument_id | String! | Instrument. |
side | MarginPositionSide! | buy or sell. |
type | MarginOrderType! | market or limit. |
status | MarginOrderStatus! | Order status. |
leverage | Int! | Leverage multiplier |
quantity | Float! | Order size |
price | Float | Price. |
limit_price | Float | Limit price. |
message | String | Status / rejection message. |
created_at_timestamp | String! | Creation time, Unix milliseconds. |
stop_loss | Float | Stop-loss price. |
take_profit | Float | Take-profit price. |
ask | Float | Ask price. |
bid | Float | Bid price. |
executed_quantity | Float! | Executed quantity. |
fee_amount | Float | Trading fee charged |
time_in_force | MarginOrderTimeInForce! | Time in force. |
expires_at_iso | String | Expiry time (ISO 8601). |
updated_at_iso | String! | Last update time (ISO 8601). |
cross_quote_price | Float | Conversion rate from the instrument's quote currency to the margin currency. |
wallet_id | String | Wallet. |
margin_instrument | MarginInstrument | Instrument 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);queryclosed_margin_ordersList completed / cancelled / rejected margin orders.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
search | String | optional | Search term. |
pager | PagerInput | optional default {limit: 30, offset: 0} | Pagination (limit, offset). |
sort | SortInput | optional default {direction: ASC} | Sort order. |
dateRange | DateRangeInput | optional 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. |
side | MarginPositionSide | optional | buy or sell |
status | MarginOrderStatus | optional | Filter by order status. |
time_in_force | MarginOrderTimeInForce | optional | Filter by time in force. |
type | MarginOrderType | optional | market or limit |
instrument_id | String | optional | Instrument filter. |
instruments_ids | [String!] | optional | Multiple instruments |
wallet_id | String | optional | Wallet filter. |
currency_id | String | optional | Filter orders by base currency ID |
Response
Fields of MarginOrder selected in the operation below.
| Field | Type | Description |
|---|---|---|
margin_order_id | String! | Order ID |
margin_position_id | String | Position the order belongs to. |
instrument_id | String! | Instrument. |
side | MarginPositionSide! | Side (buy / sell). |
type | MarginOrderType! | Type. |
status | MarginOrderStatus! | Order status. |
leverage | Int! | Leverage. |
quantity | Float! | Quantity. |
price | Float | Price. |
limit_price | Float | Limit price. |
message | String | Status / rejection message. |
created_at_timestamp | String! | Creation time, Unix milliseconds. |
stop_loss | Float | Stop-loss price. |
take_profit | Float | Take-profit price. |
ask | Float | Ask price. |
bid | Float | Bid price. |
executed_quantity | Float! | Amount actually filled |
fee_amount | Float | Trading fees |
time_in_force | MarginOrderTimeInForce! | Time in force. |
expires_at_iso | String | Expiry time (ISO 8601). |
updated_at_iso | String! | Last update time (ISO 8601). |
cross_quote_price | Float | Conversion rate from the instrument's quote currency to the margin currency. |
wallet_id | String | Wallet. |
value | Float | Total notional value |
margin_instrument | MarginInstrument | Instrument 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);querymargin_orderOne derivatives order by id.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
margin_order_id | String! | required | Order id. |
Response
Fields of MarginOrder selected in the operation below.
| Field | Type | Description |
|---|---|---|
margin_order_id | String! | |
margin_position_id | String | |
instrument_id | String! | |
side | MarginPositionSide! | |
type | MarginOrderType! | |
status | MarginOrderStatus! | |
time_in_force | MarginOrderTimeInForce! | |
leverage | Int! | |
quantity | Float! | |
executed_quantity | Float! | |
fee_amount | Float | |
price | Float | |
limit_price | Float | |
message | String | |
created_at | String! | |
updated_at | String! | |
created_at_timestamp | String! | |
updated_at_timestamp | String! | |
stop_loss | Float | |
take_profit | Float | |
take_profit_percent | Float | |
stop_loss_percent | Float | |
ask | Float | |
bid | Float | |
expires_at | String | |
cross_quote_price | Float | |
wallet_id | String | |
margin_currency_id | String! | |
advanced_type | AdvancedOrderType | |
advanced_order_id | String | |
origin | MarginOrigin | |
autoscale_tp_sl | Boolean! | |
value | Float | |
created_at_iso | String! | |
updated_at_iso | String! | |
expires_at_iso | String | |
duration | String! | |
slippage | String |
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);querymargin_tradesList the user's derivatives trades (executions).
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
| Name | Type | Required | Description |
|---|---|---|---|
search | String | optional | Search term. |
pager | PagerInput | optional default {limit: 30, offset: 0} | Pagination (limit, offset). |
sort | SortInput | optional default {direction: ASC} | Sort order. |
dateRange | DateRangeInput | optional default {} | Date range; see the note above. |
side | MarginPositionSide | optional | Side filter. |
type | MarginOrderType | optional | Order type filter. |
instrument_id | String | optional | Derivatives instrument ID (margin_instrument_id from margin_instruments). |
instruments_ids | [String!] | optional | Several instruments. |
wallet_id | String | optional | Wallet filter. |
margin_order_id | String | optional | Only trades of this order. |
Response
Fields of MarginTrade selected in the operation below.
| Field | Type | Description |
|---|---|---|
margin_trade_id | String! | |
margin_order_id | String! | |
margin_position_id | String | |
advanced_order_id | String | |
wallet_id | String | |
instrument_id | String! | |
side | MarginPositionSide! | |
type | MarginOrderType! | |
quantity | Float! | |
price | Float! | |
fee_amount | Float | |
margin_currency_id | String! | |
ask | Float! | |
bid | Float! | |
ts | DateTime! | |
created_at | DateTime! |
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);mutationcreate_margin_orderPlace a margin order.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
instrument_id | String! | required | Instrument ID. |
side | MarginPositionSide! | required | buy (long) or sell (short). |
type | MarginOrderType! | required | market or limit |
leverage | Int! | required | Leverage multiplier |
quantity | Float! | required | Order size |
price | Float | optional | Limit price (required for limit orders) |
stop_loss | Float | optional | Stop loss trigger price |
take_profit | Float | optional | Take profit target price |
take_profit_percent | Float | optional | Take-profit as a fraction, resolved at fill. Use one TP mode per order: scalar, percent or array. |
stop_loss_percent | Float | optional | Stop-loss as a fraction, resolved at fill. Use one SL mode per order: scalar, percent or array. |
wallet_id | String | optional | Wallet to trade from. Defaults to MAIN. |
time_in_force | MarginOrderTimeInForce | optional | Optional. When omitted: ioc for market, gtc for limit. limit also accepts gtd (requires expires_at). |
expires_at | String | optional | Required when time_in_force is gtd. |
all_in | ToggleSwitch | optional | Size the margin reservation for a non-limit order from the maximum available margin. |
take_profits | [TakeProfitInput!] | optional | Multi-level take-profits (price, quantity per level). |
stop_losses | [StopLossInput!] | optional | Multi-level stop-losses (price, quantity per level). |
autoscale_tp_sl | Boolean | optional | Scale the TP/SL level quantities with the position size. |
stop_preset | OrderStopPresetInput | optional | Stop preset (break_even / stop_win) activated when the order fills. |
trailing_preset | OrderTrailingPresetInput | optional | Trailing 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.
| Field | Type | Description |
|---|---|---|
margin_order_id | String! | ID of the created order |
margin_position_id | String | Position the order belongs to. |
instrument_id | String! | Instrument. |
side | MarginPositionSide! | Side (buy / sell). |
type | MarginOrderType! | Type. |
status | MarginOrderStatus! | Status. |
time_in_force | MarginOrderTimeInForce! | Time in force. |
leverage | Int! | Leverage. |
quantity | Float! | Quantity. |
price | Float | Price. |
created_at_timestamp | String! | 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);mutationcancel_margin_orderCancel an open margin limit order.
Only limit orders can be cancelled.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
margin_order_id | String! | required | Order 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);mutationcancel_all_margin_ordersCancel all open margin limit orders in a wallet.
Cancels open limit orders (status open / execution_ready) of the authenticated user in the given wallet.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
wallet_id | String | optional | Wallet 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);mutationedit_margin_orderAmend an open (pending) derivatives order.
leverage and quantity are required: restate them when only the price or TP/SL changes.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
margin_order_id | String! | required | Order to amend. |
leverage | Int! | required | Leverage (required). |
quantity | Float! | required | Quantity (required). |
price | Float | optional | New limit price. |
stop_loss | Float | optional | Single stop-loss price. |
take_profit | Float | optional | Single take-profit price. |
expires_at | String | optional | New expiry for gtd orders. |
take_profits | [TakeProfitInput!] | optional | Several take-profit levels, each { price, quantity }. |
stop_losses | [StopLossInput!] | optional | Several stop-loss levels, each { price, quantity }. |
autoscale_tp_sl | Boolean | optional | Scale 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);queryestimate_margin_user_positionPreview required margin, fees and size limits before placing a margin order.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
instrument_id | String! | required | Instrument ID. |
side | MarginPositionSide! | required | buy (long) or sell (short). |
leverage | Int! | required | Leverage. |
quantity | Float! | required | Position size to estimate |
limit_price | Float | optional | Target entry price for limit orders |
wallet_id | String | optional | Wallet filter. |
use_cached_price | ToggleSwitch | optional | With on, the last known price is used instead of a fresh quote. |
all_in | ToggleSwitch | optional | With on, quantity is replaced by the maximum the user's margin allows. |
Response
Fields of MarginOrderEstimation selected in the operation below.
| Field | Type | Description |
|---|---|---|
order_required_margin | Float! | Margin needed to place order |
fee | Float! | Total trading fee |
order_available_margin | Float! | Available margin after trade |
order_value | Float! | Notional order value |
max_position_size_base | Float! | Maximum position size allowed |
min_position_size_base | Float! | 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);queryestimate_liquidation_priceEstimated liquidation price for an order before placing it (regular and advanced types).
A null price means no estimate is available (see unavailable_reason). OCO returns one leg per side.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
wallet_id | String | optional | Wallet to act on; defaults to MAIN. |
instrument_id | String! | required | Derivatives instrument ID (margin_instrument_id from margin_instruments). |
side | MarginPositionSide! | required | Order side. |
leverage | Int! | required | Leverage. |
quantity | Float! | required | Quantity. |
kind | LiquidationEstimateOrderKind! | required | Order kind being estimated. |
limit_price | Float | optional | Limit price (limit, stop limit). |
trigger_price | Float | optional | Trigger price (stop types). |
slices_config | [ScaledOrderSliceConfigInput!] | optional | Scaled: the slices. |
iceberg_placement_type | IcebergPlacementType | optional | Iceberg: placement type. |
tp_trigger_price | Float | optional | OCO: take-profit trigger. |
tp_order_type | MarginOrderType | optional | OCO: take-profit leg type. |
tp_limit_price | Float | optional | OCO: take-profit limit price. |
sl_trigger_price | Float | optional | OCO: stop-loss trigger. |
sl_order_type | MarginOrderType | optional | OCO: stop-loss leg type. |
sl_limit_price | Float | optional | OCO: stop-loss limit price. |
primary_order_type | MarginOrderType | optional | OTO: primary order type. |
primary_price | Float | optional | OTO: primary price. |
primary_quantity | Float | optional | OTO: primary quantity. |
use_cached_price | ToggleSwitch | optional | Use the last cached market price instead of a fresh one. |
Response
Fields of LiquidationEstimate selected in the operation below.
| Field | Type | Description |
|---|---|---|
estimated_liquidation_price | Float | Convenience copy of legs[0].estimated_liquidation_price. Null for OCO — use legs. |
unavailable_reason | LiquidationEstimateUnavailableReason | |
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);queryopen_margin_positionsList currently open margin positions.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
search | String | optional | Search term. |
pager | PagerInput | optional default {limit: 30, offset: 0} | Pagination (limit, offset). |
sort | SortInput | optional default {direction: ASC} | Sort order. |
dateRange | DateRangeInput | optional default {} | Filter by start_ts (format YYYY-MM-DD HH:mm:ss). |
side | MarginPositionSide | optional | buy or sell. |
instrument_id | String | optional | Instrument filter. |
instruments_ids | [String!] | optional | Multiple instruments |
wallet_id | String | optional | Wallet filter. |
Response
Fields of MarginPosition selected in the operation below.
| Field | Type | Description |
|---|---|---|
margin_position_id | String! | Position unique ID |
instrument_id | String! | Instrument. |
side | MarginPositionSide! | buy (long) or sell (short). |
leverage | Int! | Current leverage |
amount | Float! | Position size in base asset |
value | Float | Position value. |
funding_fee_amount | Float! | Accrued funding fees |
entry_price | Float! | Average entry price |
start_price_ts | String! | Price timestamp at open. |
end_price_ts | String | Price timestamp at close. |
start_ask_price | Float! | Ask price at open. |
start_bid_price | Float! | Bid price at open. |
duration | String! | Position duration. |
end_ask_price | Float | Ask price at close. |
pnl | Float! | Unrealized P&L |
stop_loss | Float | Stop-loss price. |
take_profit | Float | Take-profit price. |
start_ts_timestamp | String! | Open time, Unix milliseconds. |
close_reason | String | Close reason. |
updated_at_iso | String! | Last update time (ISO 8601). |
wallet_id | String | Wallet. |
margin_currency_id | String! | Margin currency. |
exit_price | Float | Exit price. |
margin | Float | Margin. |
total_pnl | Float! | Total P&L. |
cross_quote_price | Float! | Conversion rate from the instrument's quote currency to the margin currency. |
end_bid_price | Float | Bid price at close. |
close_reason_code | String | Close reason code. |
margin_instrument | MarginInstrument | Instrument 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);queryclosed_margin_positionsList closed margin positions.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
search | String | optional | Search term. |
pager | PagerInput | optional default {limit: 30, offset: 0} | Pagination (limit, offset). |
sort | SortInput | optional default {direction: ASC} | Sort order. |
dateRange | DateRangeInput | optional 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. |
side | MarginPositionSide | optional | buy or sell. |
instrument_id | String | optional | Instrument filter. |
instruments_ids | [String!] | optional | Multiple instruments |
wallet_id | String | optional | Wallet filter. |
Response
Fields of MarginPosition selected in the operation below.
| Field | Type | Description |
|---|---|---|
margin_position_id | String! | Position ID |
instrument_id | String! | Instrument. |
side | MarginPositionSide! | Side (buy / sell). |
leverage | Int! | Leverage. |
amount | Float! | Amount. |
value | Float | Position value. |
funding_fee_amount | Float! | Accumulated funding / financing fees. |
entry_price | Float! | Entry price. |
start_price_ts | String! | Price timestamp at open. |
end_price_ts | String | Price timestamp at close. |
start_ask_price | Float! | Ask price at open. |
start_bid_price | Float! | Bid price at open. |
duration | String! | Position duration. |
end_ask_price | Float | Ask price at close. |
pnl | Float! | Realized P&L |
stop_loss | Float | Stop-loss price. |
take_profit | Float | Take-profit price. |
start_ts_timestamp | String! | Open time, Unix milliseconds. |
close_reason | String | Why position closed |
updated_at_iso | String! | Last update time (ISO 8601). |
wallet_id | String | Wallet. |
margin_currency_id | String! | Margin currency. |
exit_price | Float | Closing price |
margin | Float | Margin. |
total_pnl | Float! | Total P&L. |
cross_quote_price | Float! | Conversion rate from the instrument's quote currency to the margin currency. |
end_bid_price | Float | Bid price at close. |
close_reason_code | String | Close reason code. |
end_ts_iso | String | Close timestamp |
margin_instrument | MarginInstrument | Instrument 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);mutationupdate_open_margin_positionChange leverage and take-profit / stop-loss on an open position.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
margin_position_id | String! | required | Position ID to update |
leverage | Int! | required | Required. To change only take-profit / stop-loss, send the position's current leverage; a different value changes the position leverage. |
stop_loss | Float | optional | Stop-loss price; send null to clear, omit to leave unchanged. |
take_profit | Float | optional | Take-profit price; send null to clear, omit to leave unchanged. |
take_profits | [TakeProfitInput!] | optional | Multi-level take-profits; an empty array clears them. |
stop_losses | [StopLossInput!] | optional | Multi-level stop-losses; an empty array clears them. |
Response
Fields of MarginPosition selected in the operation below.
| Field | Type | Description |
|---|---|---|
margin_position_id | String! | Updated position ID |
instrument_id | String! | Instrument. |
side | MarginPositionSide! | Side (buy / sell). |
leverage | Int! | Leverage. |
amount | Float! | Amount. |
stop_loss | Float | Stop-loss price. |
take_profit | Float | Take-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);mutationclose_margin_positionClose an open margin position, fully or partially.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
margin_position_id | String! | required | Position to close. |
wallet_id | String | optional default "MAIN" | Wallet holding the position. Defaults to MAIN. |
percentage | Percentage | optional default percent100 | Portion to close. Defaults to percent100. Use custom together with amount. |
amount | Float | optional | Quantity (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);mutationclose_all_margin_positionsClose every open margin position in a wallet.
Closes every open position of the authenticated user in the given wallet, in full.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
wallet_id | String | optional 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);mutationset_stop_presetSet a break-even or stop-win preset on an open position (replaces any existing one).
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
| Name | Type | Required | Description |
|---|---|---|---|
margin_position_id | String! | required | Position. |
preset_type | StopPresetType! | required | break_even or stop_win. |
trigger_price | Float! | required | Price that activates the preset. |
target_sl_price | Float | optional | New stop-loss price (stop_win). |
Response
Fields of MarginPositionStopPreset selected in the operation below.
| Field | Type | Description |
|---|---|---|
preset_id | String! | |
margin_position_id | String | |
order_id | String | Set for presets configured at order creation, before the position exists |
instrument_id | String! | |
preset_type | StopPresetType! | |
status | StopPresetStatus! | |
trigger_price | Float! | |
target_sl_price | Float | |
created_at | String! | |
updated_at | String! |
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);mutationedit_pending_stop_presetEdit a stop preset set at order creation while its order waits to fill.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
preset_id | String! | required | Preset. |
preset_type | StopPresetType! | required | break_even or stop_win. |
trigger_price | Float! | required | Price that activates the preset. |
target_sl_price | Float | optional | New stop-loss price (stop_win). |
Response
Fields of MarginPositionStopPreset selected in the operation below.
| Field | Type | Description |
|---|---|---|
preset_id | String! | |
margin_position_id | String | |
order_id | String | Set for presets configured at order creation, before the position exists |
instrument_id | String! | |
preset_type | StopPresetType! | |
status | StopPresetStatus! | |
trigger_price | Float! | |
target_sl_price | Float | |
created_at | String! | |
updated_at | String! |
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);mutationcancel_stop_presetCancel an active stop preset.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
preset_id | String! | required | Preset. |
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);querystop_presetsList the user's stop presets.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
margin_position_id | String | optional | Position filter. |
status | StopPresetStatus | optional | Status filter. |
Response
Fields of MarginPositionStopPreset selected in the operation below.
| Field | Type | Description |
|---|---|---|
preset_id | String! | |
margin_position_id | String | |
order_id | String | Set for presets configured at order creation, before the position exists |
instrument_id | String! | |
preset_type | StopPresetType! | |
status | StopPresetStatus! | |
trigger_price | Float! | |
target_sl_price | Float | |
created_at | String! | |
updated_at | String! |
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);mutationset_trailing_presetSet a trailing stop on an open position (replaces any existing one).
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
| Name | Type | Required | Description |
|---|---|---|---|
margin_position_id | String! | required | Position. |
retracement_type | TrailingStopRetracementType! | required | percentage or distance. |
callback_rate | Float | optional | Retracement in percent. |
callback_distance | Float | optional | Retracement in price. |
activation_price | Float | optional | Price that starts the trailing. |
Response
Fields of MarginPositionTrailingPreset selected in the operation below.
| Field | Type | Description |
|---|---|---|
preset_id | String! | |
margin_position_id | String | |
order_id | String | Set for presets configured at order creation, before the position exists |
instrument_id | String! | |
status | TrailingPresetStatus! | |
retracement_type | TrailingStopRetracementType! | |
callback_rate | Float | Percent callback (e.g. 1.5 = 1.5%) when retracement_type=percentage |
callback_distance | Float | Absolute price distance when retracement_type=distance |
activation_price | Float | Optional activation price; tracking starts only after it is reached |
action_price | Float | Persisted 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_activated | Boolean | |
created_at | String! | |
updated_at | String! |
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);mutationcancel_trailing_presetCancel an active trailing stop.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
preset_id | String! | required | Preset. |
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);querytrailing_presetsList the user's trailing stops.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
margin_position_id | String | optional | Position filter. |
status | TrailingPresetStatus | optional | Status filter. |
Response
Fields of MarginPositionTrailingPreset selected in the operation below.
| Field | Type | Description |
|---|---|---|
preset_id | String! | |
margin_position_id | String | |
order_id | String | Set for presets configured at order creation, before the position exists |
instrument_id | String! | |
status | TrailingPresetStatus! | |
retracement_type | TrailingStopRetracementType! | |
callback_rate | Float | Percent callback (e.g. 1.5 = 1.5%) when retracement_type=percentage |
callback_distance | Float | Absolute price distance when retracement_type=distance |
activation_price | Float | Optional activation price; tracking starts only after it is reached |
action_price | Float | Persisted 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_activated | Boolean | |
created_at | String! | |
updated_at | String! |
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);querymargin_funding_feesRead funding / financing fees charged or paid on positions.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
pager | PagerInput | optional default {limit: 30, offset: 0} | Pagination (limit, offset). |
sort | SortInput | optional default {direction: ASC} | Sort order. |
wallet_id | String | optional | Wallet filter. |
margin_position_id | String | optional | Filter by specific position |
margin_instrument_id | String | optional | Filter by margin_instrument_id. |
dateRange | DateRangeInput | optional default {} | Filter by updated_at (format YYYY-MM-DD HH:mm:ss). |
Response
Fields of MarginFundingFee selected in the operation below.
| Field | Type | Description |
|---|---|---|
amount | Float! | Funding fee paid/received |
updated_at_iso | String! | Fee calculation time |
margin_position_id | String! | Position ID |
position_size | Float! | Position size the fee was charged on. |
rate | Float! | Funding rate at time of charge |
currency_id | String! | Currency. |
rate_type | RateType! | 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);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.
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
| Name | Type | Required | Description |
|---|---|---|---|
instrument_id | String! | required | Derivatives instrument ID (margin_instrument_id from margin_instruments). |
side | MarginPositionSide! | required | Side. |
stop_order_type | StopOrderType! | required | Order type. |
quantity | Float! | required | Quantity. |
leverage | Int! | required | Leverage. |
trigger_price | Float | optional | Trigger price (stop market, stop limit). |
limit_price | Float | optional | Limit price (stop limit). |
retracement_type | TrailingStopRetracementType | optional | Trailing: percentage or distance. |
callback_rate | Float | optional | Trailing retracement in percent. |
callback_distance | Float | optional | Trailing retracement in price. |
activation_price | Float | optional | Trailing: price that starts the trailing. |
take_profit | Float | optional | Single take-profit price. |
stop_loss | Float | optional | Single stop-loss price. |
wallet_id | String | optional | Wallet to act on; defaults to MAIN. |
autoscale_tp_sl | Boolean | optional | Scale the TP/SL level quantities with the position size. |
take_profits | [TakeProfitInput!] | optional | Several take-profit levels, each { price, quantity }. |
stop_losses | [StopLossInput!] | optional | Several stop-loss levels, each { price, quantity }. |
Response
Fields of StopMarginOrder selected in the operation below.
| Field | Type | Description |
|---|---|---|
stop_order_id | String! | |
instrument_id | String! | |
side | MarginPositionSide! | |
stop_order_type | StopOrderType! | |
status | StopOrderStatus! | |
termination_reason | AdvancedOrderTerminationReason | |
termination_detail | String | |
quantity | Float! | |
leverage | Int! | |
wallet_id | String! | |
trigger_price | Float | |
trigger_direction | StopOrderTriggerDirection | |
limit_price | Float | |
retracement_type | TrailingStopRetracementType | |
callback_rate | Float | |
callback_distance | Float | |
activation_price | Float | |
best_price | Float | |
is_activated | Boolean | |
take_profit | Float | |
stop_loss | Float | |
autoscale_tp_sl | Boolean! | |
created_at | String! | |
updated_at | String! |
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);mutationedit_stop_order_tp_slReplace the TP/SL attached to a stop order that has not triggered yet.
Omitted TP/SL fields are cleared: sending none detaches TP/SL entirely.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
stop_order_id | String! | required | Order. |
take_profit | Float | optional | Single take-profit price. |
stop_loss | Float | optional | Single stop-loss price. |
take_profits | [TakeProfitInput!] | optional | Several take-profit levels, each { price, quantity }. |
stop_losses | [StopLossInput!] | optional | Several stop-loss levels, each { price, quantity }. |
autoscale_tp_sl | Boolean | optional | Scale the TP/SL level quantities with the position size. |
Response
Fields of StopMarginOrder selected in the operation below.
| Field | Type | Description |
|---|---|---|
stop_order_id | String! | |
instrument_id | String! | |
side | MarginPositionSide! | |
stop_order_type | StopOrderType! | |
status | StopOrderStatus! | |
termination_reason | AdvancedOrderTerminationReason | |
termination_detail | String | |
quantity | Float! | |
leverage | Int! | |
wallet_id | String! | |
trigger_price | Float | |
trigger_direction | StopOrderTriggerDirection | |
limit_price | Float | |
retracement_type | TrailingStopRetracementType | |
callback_rate | Float | |
callback_distance | Float | |
activation_price | Float | |
best_price | Float | |
is_activated | Boolean | |
take_profit | Float | |
stop_loss | Float | |
autoscale_tp_sl | Boolean! | |
created_at | String! | |
updated_at | String! |
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);mutationcancel_stop_orderCancel an active stop order.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
stop_order_id | String! | required | Order. |
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);querystop_ordersList the user's stop orders.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
search | String | optional | Search term. |
pager | PagerInput | optional default {limit: 30, offset: 0} | Pagination (limit, offset). |
sort | SortInput | optional default {direction: ASC} | Sort order. |
instrument_id | String | optional | Derivatives instrument ID (margin_instrument_id from margin_instruments). |
status | StopOrderStatus | optional | Status filter. |
stop_order_type | StopOrderType | optional | Type filter. |
wallet_id | String | optional | Wallet filter. |
dateRange | DateRangeInput | optional | Date range. |
Response
Fields of StopMarginOrder selected in the operation below.
| Field | Type | Description |
|---|---|---|
stop_order_id | String! | |
instrument_id | String! | |
side | MarginPositionSide! | |
stop_order_type | StopOrderType! | |
status | StopOrderStatus! | |
termination_reason | AdvancedOrderTerminationReason | |
termination_detail | String | |
quantity | Float! | |
leverage | Int! | |
wallet_id | String! | |
trigger_price | Float | |
trigger_direction | StopOrderTriggerDirection | |
limit_price | Float | |
retracement_type | TrailingStopRetracementType | |
callback_rate | Float | |
callback_distance | Float | |
activation_price | Float | |
best_price | Float | |
is_activated | Boolean | |
take_profit | Float | |
stop_loss | Float | |
autoscale_tp_sl | Boolean! | |
created_at | String! | |
updated_at | String! |
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);querystop_orderOne stop order by id.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
stop_order_id | String! | required | Order. |
Response
Fields of StopMarginOrder selected in the operation below.
| Field | Type | Description |
|---|---|---|
stop_order_id | String! | |
instrument_id | String! | |
side | MarginPositionSide! | |
stop_order_type | StopOrderType! | |
status | StopOrderStatus! | |
termination_reason | AdvancedOrderTerminationReason | |
termination_detail | String | |
quantity | Float! | |
leverage | Int! | |
wallet_id | String! | |
trigger_price | Float | |
trigger_direction | StopOrderTriggerDirection | |
limit_price | Float | |
retracement_type | TrailingStopRetracementType | |
callback_rate | Float | |
callback_distance | Float | |
activation_price | Float | |
best_price | Float | |
is_activated | Boolean | |
take_profit | Float | |
stop_loss | Float | |
autoscale_tp_sl | Boolean! | |
created_at | String! | |
updated_at | String! |
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);mutationcreate_oco_orderPlace an OCO (one-cancels-the-other) order: a take-profit and a stop-loss leg.
When one leg triggers, the other is cancelled. Each leg is market or limit; a limit leg needs its *_limit_price.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
instrument_id | String! | required | Derivatives instrument ID (margin_instrument_id from margin_instruments). |
side | MarginPositionSide! | required | Side. |
quantity | Float! | required | Quantity. |
leverage | Int! | required | Leverage. |
tp_trigger_price | Float! | required | Take-profit trigger. |
tp_order_type | MarginOrderType! | required | Take-profit leg type. |
tp_limit_price | Float | optional | Take-profit limit price. |
sl_trigger_price | Float! | required | Stop-loss trigger. |
sl_order_type | MarginOrderType! | required | Stop-loss leg type. |
sl_limit_price | Float | optional | Stop-loss limit price. |
wallet_id | String | optional | Wallet to act on; defaults to MAIN. |
Response
Fields of OcoMarginOrder selected in the operation below.
| Field | Type | Description |
|---|---|---|
oco_order_id | String! | |
instrument_id | String! | |
side | MarginPositionSide! | |
status | OcoOrderStatus! | |
termination_reason | AdvancedOrderTerminationReason | |
termination_detail | String | |
quantity | Float! | |
leverage | Int! | |
wallet_id | String! | |
tp_trigger_price | Float! | |
tp_trigger_direction | StopOrderTriggerDirection! | |
tp_order_type | MarginOrderType! | |
tp_limit_price | Float | |
sl_trigger_price | Float! | |
sl_trigger_direction | StopOrderTriggerDirection! | |
sl_order_type | MarginOrderType! | |
sl_limit_price | Float | |
triggered_leg | OcoTriggeredLeg | |
created_at | String! | |
updated_at | String! |
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);mutationcancel_oco_orderCancel an active OCO order.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
oco_order_id | String! | required | Order. |
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);queryoco_ordersList the user's OCO orders.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
search | String | optional | Search term. |
pager | PagerInput | optional default {limit: 30, offset: 0} | Pagination (limit, offset). |
sort | SortInput | optional default {direction: ASC} | Sort order. |
instrument_id | String | optional | Derivatives instrument ID (margin_instrument_id from margin_instruments). |
status | OcoOrderStatus | optional | Status filter. |
wallet_id | String | optional | Wallet filter. |
dateRange | DateRangeInput | optional | Date range. |
Response
Fields of OcoMarginOrder selected in the operation below.
| Field | Type | Description |
|---|---|---|
oco_order_id | String! | |
instrument_id | String! | |
side | MarginPositionSide! | |
status | OcoOrderStatus! | |
termination_reason | AdvancedOrderTerminationReason | |
termination_detail | String | |
quantity | Float! | |
leverage | Int! | |
wallet_id | String! | |
tp_trigger_price | Float! | |
tp_trigger_direction | StopOrderTriggerDirection! | |
tp_order_type | MarginOrderType! | |
tp_limit_price | Float | |
sl_trigger_price | Float! | |
sl_trigger_direction | StopOrderTriggerDirection! | |
sl_order_type | MarginOrderType! | |
sl_limit_price | Float | |
triggered_leg | OcoTriggeredLeg | |
created_at | String! | |
updated_at | String! |
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);queryoco_orderOne OCO order by id.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
oco_order_id | String! | required | Order. |
Response
Fields of OcoMarginOrder selected in the operation below.
| Field | Type | Description |
|---|---|---|
oco_order_id | String! | |
instrument_id | String! | |
side | MarginPositionSide! | |
status | OcoOrderStatus! | |
termination_reason | AdvancedOrderTerminationReason | |
termination_detail | String | |
quantity | Float! | |
leverage | Int! | |
wallet_id | String! | |
tp_trigger_price | Float! | |
tp_trigger_direction | StopOrderTriggerDirection! | |
tp_order_type | MarginOrderType! | |
tp_limit_price | Float | |
sl_trigger_price | Float! | |
sl_trigger_direction | StopOrderTriggerDirection! | |
sl_order_type | MarginOrderType! | |
sl_limit_price | Float | |
triggered_leg | OcoTriggeredLeg | |
created_at | String! | |
updated_at | String! |
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);mutationcreate_oto_orderPlace an OTO (one-triggers-the-other) order: a secondary order placed once the primary fills.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
instrument_id | String! | required | Derivatives instrument ID (margin_instrument_id from margin_instruments). |
side | MarginPositionSide! | required | Side. |
leverage | Int! | required | Leverage. |
primary_order_type | MarginOrderType! | required | Primary order type. |
primary_price | Float | optional | Primary limit price. |
primary_quantity | Float! | required | Primary quantity. |
secondary_side | MarginPositionSide! | required | Secondary side. |
secondary_order_type | MarginOrderType! | required | Secondary order type. |
secondary_price | Float | optional | Secondary limit price. |
secondary_quantity | Float! | required | Secondary quantity. |
wallet_id | String | optional | Wallet to act on; defaults to MAIN. |
Response
Fields of OtoMarginOrder selected in the operation below.
| Field | Type | Description |
|---|---|---|
oto_order_id | String! | |
instrument_id | String! | |
side | MarginPositionSide! | |
status | OtoOrderStatus! | |
leverage | Int! | |
wallet_id | String! | |
primary_order_type | MarginOrderType! | |
primary_price | Float | |
primary_quantity | Float! | |
secondary_side | MarginPositionSide! | |
secondary_order_type | MarginOrderType! | |
secondary_price | Float | |
secondary_quantity | Float! | |
primary_order_id | String | |
secondary_order_id | String | |
termination_reason | AdvancedOrderTerminationReason | |
termination_detail | String | |
created_at | String! | |
updated_at | String! |
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);mutationcancel_oto_orderCancel an active OTO order.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
oto_order_id | String! | required | Order. |
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);queryoto_ordersList the user's OTO orders.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
search | String | optional | Search term. |
pager | PagerInput | optional default {limit: 30, offset: 0} | Pagination (limit, offset). |
sort | SortInput | optional default {direction: ASC} | Sort order. |
instrument_id | String | optional | Derivatives instrument ID (margin_instrument_id from margin_instruments). |
status | OtoOrderStatus | optional | Status filter. |
wallet_id | String | optional | Wallet filter. |
dateRange | DateRangeInput | optional | Date range. |
Response
Fields of OtoMarginOrder selected in the operation below.
| Field | Type | Description |
|---|---|---|
oto_order_id | String! | |
instrument_id | String! | |
side | MarginPositionSide! | |
status | OtoOrderStatus! | |
leverage | Int! | |
wallet_id | String! | |
primary_order_type | MarginOrderType! | |
primary_price | Float | |
primary_quantity | Float! | |
secondary_side | MarginPositionSide! | |
secondary_order_type | MarginOrderType! | |
secondary_price | Float | |
secondary_quantity | Float! | |
primary_order_id | String | |
secondary_order_id | String | |
termination_reason | AdvancedOrderTerminationReason | |
termination_detail | String | |
created_at | String! | |
updated_at | String! |
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);queryoto_orderOne OTO order by id.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
oto_order_id | String! | required | Order. |
Response
Fields of OtoMarginOrder selected in the operation below.
| Field | Type | Description |
|---|---|---|
oto_order_id | String! | |
instrument_id | String! | |
side | MarginPositionSide! | |
status | OtoOrderStatus! | |
leverage | Int! | |
wallet_id | String! | |
primary_order_type | MarginOrderType! | |
primary_price | Float | |
primary_quantity | Float! | |
secondary_side | MarginPositionSide! | |
secondary_order_type | MarginOrderType! | |
secondary_price | Float | |
secondary_quantity | Float! | |
primary_order_id | String | |
secondary_order_id | String | |
termination_reason | AdvancedOrderTerminationReason | |
termination_detail | String | |
created_at | String! | |
updated_at | String! |
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);mutationcreate_twap_orderPlace a TWAP order: the quantity is split into slices executed at a fixed frequency over a duration.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
instrument_id | String! | required | Derivatives instrument ID (margin_instrument_id from margin_instruments). |
side | MarginPositionSide! | required | Side. |
total_quantity | Float! | required | Total quantity. |
leverage | Int! | required | Leverage. |
frequency | TWAPFrequency! | required | Interval between slices. |
duration | Int! | required | Total duration, in seconds. |
execution_strategy | TWAPExecutionStrategy! | required | uniform slices or randomized sizes. |
slice_order_type | MarginOrderType! | required | Slice order type. |
limit_price | Float | optional | Limit price for limit slices. |
price_tolerance_percent | Float | optional | Maximum price deviation for a slice, in percent. |
wallet_id | String | optional | Wallet to act on; defaults to MAIN. |
Response
Fields of TWAPMarginOrder selected in the operation below.
| Field | Type | Description |
|---|---|---|
twap_order_id | String! | |
instrument_id | String! | |
side | MarginPositionSide! | |
status | TWAPOrderStatus! | |
termination_reason | AdvancedOrderTerminationReason | |
termination_detail | String | |
total_quantity | Float! | |
executed_quantity | Float! | |
frequency | TWAPFrequency! | |
duration | Int! | |
total_slices | Int! | |
execution_strategy | TWAPExecutionStrategy! | |
slice_order_type | MarginOrderType! | |
start_time | String! | |
end_time | String! | |
next_execution_time | String | |
limit_price | Float | |
price_tolerance_percent | Float | |
slices_executed | Int! | |
slices_failed | Int! | |
average_execution_price | Float | |
leverage | Int! | |
wallet_id | String! | |
created_at | String! | |
updated_at | String! | |
progress_percent | Float! |
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);mutationpause_twap_orderPause an active TWAP order.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
twap_order_id | String! | required | Order. |
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);mutationresume_twap_orderResume a paused TWAP order.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
twap_order_id | String! | required | Order. |
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);mutationcancel_twap_orderCancel an active TWAP order.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
twap_order_id | String! | required | Order. |
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);querytwap_ordersList the user's TWAP orders.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
search | String | optional | Search term. |
pager | PagerInput | optional default {limit: 30, offset: 0} | Pagination (limit, offset). |
sort | SortInput | optional default {direction: ASC} | Sort order. |
instrument_id | String | optional | Derivatives instrument ID (margin_instrument_id from margin_instruments). |
status | TWAPOrderStatus | optional | Status filter. |
wallet_id | String | optional | Wallet filter. |
dateRange | DateRangeInput | optional | Date range. |
Response
Fields of TWAPMarginOrder selected in the operation below.
| Field | Type | Description |
|---|---|---|
twap_order_id | String! | |
instrument_id | String! | |
side | MarginPositionSide! | |
status | TWAPOrderStatus! | |
termination_reason | AdvancedOrderTerminationReason | |
termination_detail | String | |
total_quantity | Float! | |
executed_quantity | Float! | |
frequency | TWAPFrequency! | |
duration | Int! | |
total_slices | Int! | |
execution_strategy | TWAPExecutionStrategy! | |
slice_order_type | MarginOrderType! | |
start_time | String! | |
end_time | String! | |
next_execution_time | String | |
limit_price | Float | |
price_tolerance_percent | Float | |
slices_executed | Int! | |
slices_failed | Int! | |
average_execution_price | Float | |
leverage | Int! | |
wallet_id | String! | |
created_at | String! | |
updated_at | String! | |
progress_percent | Float! |
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);querytwap_orderOne TWAP order by id.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
twap_order_id | String! | required | Order. |
Response
Fields of TWAPMarginOrder selected in the operation below.
| Field | Type | Description |
|---|---|---|
twap_order_id | String! | |
instrument_id | String! | |
side | MarginPositionSide! | |
status | TWAPOrderStatus! | |
termination_reason | AdvancedOrderTerminationReason | |
termination_detail | String | |
total_quantity | Float! | |
executed_quantity | Float! | |
frequency | TWAPFrequency! | |
duration | Int! | |
total_slices | Int! | |
execution_strategy | TWAPExecutionStrategy! | |
slice_order_type | MarginOrderType! | |
start_time | String! | |
end_time | String! | |
next_execution_time | String | |
limit_price | Float | |
price_tolerance_percent | Float | |
slices_executed | Int! | |
slices_failed | Int! | |
average_execution_price | Float | |
leverage | Int! | |
wallet_id | String! | |
created_at | String! | |
updated_at | String! | |
progress_percent | Float! |
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);mutationcreate_iceberg_orderPlace an iceberg order: only a slice of the total quantity shows at a time.
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
| Name | Type | Required | Description |
|---|---|---|---|
instrument_id | String! | required | Derivatives instrument ID (margin_instrument_id from margin_instruments). |
side | MarginPositionSide! | required | Side. |
total_quantity | Float! | required | Total quantity. |
display_quantity | Float | optional | Quantity shown per slice. |
number_of_slices | Int | optional | Number of slices. |
placement_type | IcebergPlacementType! | required | fixed_price at limit_price, or chase_taker. |
limit_price | Float | optional | Limit price (fixed_price). |
leverage | Int! | required | Leverage. |
wallet_id | String | optional | Wallet to act on; defaults to MAIN. |
Response
Fields of IcebergMarginOrder selected in the operation below.
| Field | Type | Description |
|---|---|---|
iceberg_order_id | String! | |
instrument_id | String! | |
side | MarginPositionSide! | |
status | IcebergOrderStatus! | |
termination_reason | AdvancedOrderTerminationReason | |
termination_detail | String | |
total_quantity | Float! | |
executed_quantity | Float! | |
display_quantity | Float! | |
placement_type | IcebergPlacementType! | |
limit_price | Float | |
leverage | Int! | |
wallet_id | String! | |
average_execution_price | Float | |
created_at | String! | |
updated_at | String! |
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);queryestimate_iceberg_orderCompute the slice count or slice size of an iceberg order.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
instrument_id | String! | required | Derivatives instrument ID (margin_instrument_id from margin_instruments). |
total_quantity | Float! | required | Total quantity. |
display_quantity | Float | optional | Slice size (give this or number_of_orders). |
number_of_orders | Int | optional | Slice count. |
Response
Fields of EstimateIcebergOrderResult selected in the operation below.
| Field | Type | Description |
|---|---|---|
total_quantity | Float! | Total quantity (rounded to instrument step_size) |
display_quantity | Float! | Quantity per order / slice (rounded to instrument step_size) |
number_of_orders | Int! | 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);mutationcancel_iceberg_orderCancel an active iceberg order.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
iceberg_order_id | String! | required | Order. |
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);queryiceberg_ordersList the user's iceberg orders.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
search | String | optional | Search term. |
pager | PagerInput | optional default {limit: 30, offset: 0} | Pagination (limit, offset). |
sort | SortInput | optional default {direction: ASC} | Sort order. |
instrument_id | String | optional | Derivatives instrument ID (margin_instrument_id from margin_instruments). |
status | IcebergOrderStatus | optional | Status filter. |
wallet_id | String | optional | Wallet filter. |
dateRange | DateRangeInput | optional | Date range. |
Response
Fields of IcebergMarginOrder selected in the operation below.
| Field | Type | Description |
|---|---|---|
iceberg_order_id | String! | |
instrument_id | String! | |
side | MarginPositionSide! | |
status | IcebergOrderStatus! | |
termination_reason | AdvancedOrderTerminationReason | |
termination_detail | String | |
total_quantity | Float! | |
executed_quantity | Float! | |
display_quantity | Float! | |
placement_type | IcebergPlacementType! | |
limit_price | Float | |
leverage | Int! | |
wallet_id | String! | |
average_execution_price | Float | |
created_at | String! | |
updated_at | String! |
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);queryiceberg_orderOne iceberg order by id.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
iceberg_order_id | String! | required | Order. |
Response
Fields of IcebergMarginOrder selected in the operation below.
| Field | Type | Description |
|---|---|---|
iceberg_order_id | String! | |
instrument_id | String! | |
side | MarginPositionSide! | |
status | IcebergOrderStatus! | |
termination_reason | AdvancedOrderTerminationReason | |
termination_detail | String | |
total_quantity | Float! | |
executed_quantity | Float! | |
display_quantity | Float! | |
placement_type | IcebergPlacementType! | |
limit_price | Float | |
leverage | Int! | |
wallet_id | String! | |
average_execution_price | Float | |
created_at | String! | |
updated_at | String! |
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);mutationcreate_scaled_orderPlace a scaled order: several limit orders spread across a price range.
Build slices_config with estimate_scaled_order, or pass your own slices.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
instrument_id | String! | required | Derivatives instrument ID (margin_instrument_id from margin_instruments). |
side | MarginPositionSide! | required | Side. |
total_quantity | Float! | required | Total quantity. |
number_of_orders | Int! | required | Number of limit orders. |
price_range_start | Float! | required | First price of the range. |
price_range_end | Float! | required | Last price of the range. |
slices_config | [ScaledOrderSliceConfigInput!]! | required | One { index, price, rate, amount } per order. |
leverage | Int! | required | Leverage. |
wallet_id | String | optional | Wallet to act on; defaults to MAIN. |
Response
Fields of ScaledMarginOrder selected in the operation below.
| Field | Type | Description |
|---|---|---|
scaled_order_id | String! | |
instrument_id | String! | |
side | MarginPositionSide! | |
status | ScaledOrderStatus! | |
termination_reason | AdvancedOrderTerminationReason | |
termination_detail | String | |
total_quantity | Float! | |
executed_quantity | Float! | |
number_of_orders | Int! | |
price_range_start | Float! | |
price_range_end | Float! | |
leverage | Int! | |
wallet_id | String! | |
average_execution_price | Float | |
orders_executed | Int! | |
orders_failed | Int! | |
created_at | String! | |
updated_at | String! |
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);queryestimate_scaled_orderCompute the slices of a scaled order for a distribution.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
instrument_id | String! | required | Derivatives instrument ID (margin_instrument_id from margin_instruments). |
distribution_type | ScaledDistributionType! | required | Size distribution across the range. |
total_quantity | Float! | required | Total quantity. |
number_of_orders | Int! | required | Number of orders. |
price_range_start | Float! | required | First price. |
price_range_end | Float! | required | Last price. |
variance | Int | optional default 25 | Steepness for increasing / decreasing distributions. |
Response
Fields of ScaledOrderSliceConfig selected in the operation below.
| Field | Type | Description |
|---|---|---|
index | Int! | |
price | Float! | |
rate | Float! | |
amount | Float! |
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);mutationcancel_scaled_orderCancel an active scaled order.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
scaled_order_id | String! | required | Order. |
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);queryscaled_ordersList the user's scaled orders.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
search | String | optional | Search term. |
pager | PagerInput | optional default {limit: 30, offset: 0} | Pagination (limit, offset). |
sort | SortInput | optional default {direction: ASC} | Sort order. |
instrument_id | String | optional | Derivatives instrument ID (margin_instrument_id from margin_instruments). |
status | ScaledOrderStatus | optional | Status filter. |
wallet_id | String | optional | Wallet filter. |
dateRange | DateRangeInput | optional | Date range. |
Response
Fields of ScaledMarginOrder selected in the operation below.
| Field | Type | Description |
|---|---|---|
scaled_order_id | String! | |
instrument_id | String! | |
side | MarginPositionSide! | |
status | ScaledOrderStatus! | |
termination_reason | AdvancedOrderTerminationReason | |
termination_detail | String | |
total_quantity | Float! | |
executed_quantity | Float! | |
number_of_orders | Int! | |
price_range_start | Float! | |
price_range_end | Float! | |
leverage | Int! | |
wallet_id | String! | |
average_execution_price | Float | |
orders_executed | Int! | |
orders_failed | Int! | |
created_at | String! | |
updated_at | String! |
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);queryscaled_orderOne scaled order by id.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
scaled_order_id | String! | required | Order. |
Response
Fields of ScaledMarginOrder selected in the operation below.
| Field | Type | Description |
|---|---|---|
scaled_order_id | String! | |
instrument_id | String! | |
side | MarginPositionSide! | |
status | ScaledOrderStatus! | |
termination_reason | AdvancedOrderTerminationReason | |
termination_detail | String | |
total_quantity | Float! | |
executed_quantity | Float! | |
number_of_orders | Int! | |
price_range_start | Float! | |
price_range_end | Float! | |
leverage | Int! | |
wallet_id | String! | |
average_execution_price | Float | |
orders_executed | Int! | |
orders_failed | Int! | |
created_at | String! | |
updated_at | String! |
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);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
| Field | Type | Required | Description |
|---|---|---|---|
trigger_price | Float! | required | Reference price at which this leg becomes eligible to trigger. |
execution_type | ConditionalOrderExecutionType! | optional default market | Execution strategy used after the trigger: protected market-style or explicit limit. |
limit_price | Float | optional | Required child-order price when execution_type is limit. |
price_reference | ConditionalOrderPriceReference! | optional default orderbook | Price stream evaluated against trigger_price. |
slippage_bps | Int | optional default 100 | Maximum market-style execution deviation in basis points. 100 equals 1%. |
time_in_force | OrderTimeInForce! | optional default gtc | Time-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
| Field | Type | Required | Description |
|---|---|---|---|
time_from | String | optional | Time FROM filter, YYYY-MM-DD HH:mm:ss |
time_to | String | optional | Time TO filter, YYYY-MM-DD HH:mm:ss |
enum FeeCalculationType
sum max
input FiatDepositPropertyInput
| Field | Type | Required | Description |
|---|---|---|---|
name | String! | required | |
value | String! | 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
| Field | Type | Required | Description |
|---|---|---|---|
limit | Int | optional default 30 | pager limit, default 30 |
offset | Int | optional default 0 | pager 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
| Field | Type | Required | Description |
|---|---|---|---|
serial_id_from | Int | optional | Serial ID FROM filter |
serial_id_to | Int | optional | Serial ID TO filter |
enum SortDirection
ASC DESC
input SortInput
| Field | Type | Required | Description |
|---|---|---|---|
direction | SortDirection | optional default DESC | Sort direction |
property | String | optional | Sort property |
enum ToggleSwitch
on off
input TravelRuleAddress
| Field | Type | Required | Description |
|---|---|---|---|
country | String | optional | |
post_code | String | optional | |
town | String | optional | |
street | String | optional | |
state | String | optional | |
building_number | String | optional | |
flat_number | String | optional |
input TravelRuleCounterParty
| Field | Type | Required | Description |
|---|---|---|---|
fullName | String! | required | |
crypto_address | String! | required | |
vasp_id | String | optional | |
place_of_birth | String | optional | |
date_of_birth | String | optional | |
address | TravelRuleAddress | optional |
input TravelRulePropertiesArgs
| Field | Type | Required | Description |
|---|---|---|---|
counterparty | TravelRuleCounterParty! | 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
| Field | Type | Required | Description |
|---|---|---|---|
time_from | String | optional | Time FROM filter, YYYY-MM-DD HH:mm:ss |
time_to | String | optional | Time 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 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
| Field | Type | Required | Description |
|---|---|---|---|
preset_type | StopPresetType! | required | |
trigger_price | Float! | required | |
target_sl_price | Float | optional | Required for stop_win; ignored for break_even |
input OrderTrailingPresetInput
| Field | Type | Required | Description |
|---|---|---|---|
retracement_type | TrailingStopRetracementType! | required | |
callback_rate | Float | optional | Required for percentage retracement (0.01-50%) |
callback_distance | Float | optional | Required for distance retracement (absolute price units) |
activation_price | Float | optional | Optional; tracking starts only after this level is reached |
enum OtoOrderStatus
active primary_executed completed cancelled
input PagerInput
| Field | Type | Required | Description |
|---|---|---|---|
limit | Int | optional default 30 | |
offset | Int | optional 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
| Field | Type | Required | Description |
|---|---|---|---|
index | Int! | required | |
price | Float! | required | |
rate | Float! | required | |
amount | Float! | required |
enum ScaledOrderStatus
active completed cancelled
enum SortDirection
ASC DESC
input SortInput
| Field | Type | Required | Description |
|---|---|---|---|
direction | SortDirection | optional default ASC | |
field | String | optional |
input StopLossInput
| Field | Type | Required | Description |
|---|---|---|---|
price | Float! | required | |
quantity | Float! | 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
| Field | Type | Required | Description |
|---|---|---|---|
price | Float! | required | |
quantity | Float! | 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, withexpires_atin Unix seconds (sliding).service_signinis still supported. - Added session management:
user_sessions,revoke_current_session,revoke_session,revoke_other_sessions. - Added
portfolio_history_v2anduser_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_walletandcreate_wallet_transferto 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 instrumentsBTCUSD;create_twap_orderdurationis 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_priceandmargin_advanced_order_types_enabled. - Added spot conditional orders (take-profit, stop-loss, OCO):
create_conditional_order,cancel_conditional_order,conditional_orders,conditional_order_policy, andtake_profit/stop_lossoncreate_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 aspropertiesname/value pairs, not as separate arguments. - Fixed
wallets:is_activeandtypetake strings. - Inputs, defaults and types are now generated from the platform schema.