### Get All Initial Leverage via REST Source: https://api-docs.grvt.io/trading_api Examples for retrieving initial leverage using REST API endpoints. ```bash curl --location 'https://trades.testnet.grvt.io/lite/v1/get_all_initial_leverage' \ --header "Cookie: $GRVT_COOKIE" \ --header "X-Grvt-Account-Id: $GRVT_ACCOUNT_ID" \ --data '{ "sa": "'$GRVT_SUB_ACCOUNT_ID'" } ' ``` ```bash curl --location 'https://trades.grvt.io/full/v1/get_all_initial_leverage' \ --header "Cookie: $GRVT_COOKIE" \ --header "X-Grvt-Account-Id: $GRVT_ACCOUNT_ID" \ --data '{ "sub_account_id": "'$GRVT_SUB_ACCOUNT_ID'" } ' ``` ```bash curl --location 'https://trades.grvt.io/lite/v1/get_all_initial_leverage' \ --header "Cookie: $GRVT_COOKIE" \ --header "X-Grvt-Account-Id: $GRVT_ACCOUNT_ID" \ --data '{ "sa": "'$GRVT_SUB_ACCOUNT_ID'" } ' ``` -------------------------------- ### Get All Initial Leverage via JSONRPC Source: https://api-docs.grvt.io/trading_api Examples for retrieving initial leverage using JSONRPC over WebSockets. ```bash -H "Cookie: $GRVT_COOKIE" \ -H "X-Grvt-Account-Id: $GRVT_ACCOUNT_ID" \ -x ' { "jsonrpc": "2.0", "method": "v1/get_all_initial_leverage", "params": { "sub_account_id": "'$GRVT_SUB_ACCOUNT_ID'" }, "id": 123 } ' -w 360 ``` ```bash wscat -c "wss://trades.testnet.grvt.io/ws/lite" \ -H "Cookie: $GRVT_COOKIE" \ -H "X-Grvt-Account-Id: $GRVT_ACCOUNT_ID" \ -x ' { "j": "2.0", "m": "v1/get_all_initial_leverage", "p": { "sa": "'$GRVT_SUB_ACCOUNT_ID'" }, "i": 123 } ' -w 360 ``` ```bash wscat -c "wss://trades.grvt.io/ws/full" \ -H "Cookie: $GRVT_COOKIE" \ -H "X-Grvt-Account-Id: $GRVT_ACCOUNT_ID" \ -x ' { "jsonrpc": "2.0", "method": "v1/get_all_initial_leverage", "params": { "sub_account_id": "'$GRVT_SUB_ACCOUNT_ID'" }, "id": 123 } ' -w 360 ``` ```bash wscat -c "wss://trades.grvt.io/ws/lite" \ -H "Cookie: $GRVT_COOKIE" \ -H "X-Grvt-Account-Id: $GRVT_ACCOUNT_ID" \ -x ' { "j": "2.0", "m": "v1/get_all_initial_leverage", "p": { "sa": "'$GRVT_SUB_ACCOUNT_ID'" }, "i": 123 } ' -w 360 ``` -------------------------------- ### Get Authorized Builders - Full Response Example Source: https://api-docs.grvt.io/trading_api Example response for the full endpoint, listing authorized builders and their fee rates. ```json { "results": [{ "builder_account_id": "'$GRVT_MAIN_ACCOUNT_ID'", "max_futures_fee_rate": 0.001, "max_spot_fee_rate": 0.0001 }] } ``` -------------------------------- ### REST API Call: Get All Initial Leverage (Full) Source: https://api-docs.grvt.io/trading_api Example of fetching all initial leverage data using the REST API (Full mode). Requires GRVT_COOKIE and X-Grvt-Account-Id headers, and sub_account_id in the payload. ```bash curl --location 'https://trades.dev.gravitymarkets.io/full/v1/get_all_initial_leverage' \ --header "Cookie: $GRVT_COOKIE" \ --header "X-Grvt-Account-Id: $GRVT_ACCOUNT_ID" \ --data '{ \ "sub_account_id": "'$GRVT_SUB_ACCOUNT_ID'" \ } ' ``` -------------------------------- ### REST API Call: Get All Initial Leverage (Lite) Source: https://api-docs.grvt.io/trading_api Example of fetching all initial leverage data using the REST API (Lite mode). Requires GRVT_COOKIE and X-Grvt-Account-Id headers, and 'sa' (sub_account_id) in the payload. ```bash curl --location 'https://trades.dev.gravitymarkets.io/lite/v1/get_all_initial_leverage' \ --header "Cookie: $GRVT_COOKIE" \ --header "X-Grvt-Account-Id: $GRVT_ACCOUNT_ID" \ --data '{ \ "sa": "'$GRVT_SUB_ACCOUNT_ID'" \ } ' ``` -------------------------------- ### JSONRPC API Call: Get All Initial Leverage (Testnet Full) Source: https://api-docs.grvt.io/trading_api Example of fetching all initial leverage data using JSONRPC (Testnet environment, Full mode). Requires GRVT_COOKIE and X-Grvt-Account-Id headers, and sub_account_id in the params. ```bash wscat -c "wss://trades.testnet.grvt.io/ws/full" \ -H "Cookie: $GRVT_COOKIE" \ -H "X-Grvt-Account-Id: $GRVT_ACCOUNT_ID" \ -x ' { "jsonrpc": "2.0", "method": "v1/get_all_initial_leverage", "params": { "sub_account_id": "'$GRVT_SUB_ACCOUNT_ID'" }, "id": 123 } ' -w 360 ``` -------------------------------- ### JSONRPC API Call: Get All Initial Leverage (Full) Source: https://api-docs.grvt.io/trading_api Example of fetching all initial leverage data using JSONRPC (Full mode). Requires GRVT_COOKIE and X-Grvt-Account-Id headers, and sub_account_id in the params. ```bash wscat -c "wss://trades.dev.gravitymarkets.io/ws/full" \ -H "Cookie: $GRVT_COOKIE" \ -H "X-Grvt-Account-Id: $GRVT_ACCOUNT_ID" \ -x ' { "jsonrpc": "2.0", "method": "v1/get_all_initial_leverage", "params": { "sub_account_id": "'$GRVT_SUB_ACCOUNT_ID'" }, "id": 123 } ' -w 360 ``` -------------------------------- ### JSONRPC API Call: Get All Initial Leverage (Lite) Source: https://api-docs.grvt.io/trading_api Example of fetching all initial leverage data using JSONRPC (Lite mode). Requires GRVT_COOKIE and X-Grvt-Account-Id headers, and 'p.sa' (sub_account_id) in the params. ```bash wscat -c "wss://trades.dev.gravitymarkets.io/ws/lite" \ -H "Cookie: $GRVT_COOKIE" \ -H "X-Grvt-Account-Id: $GRVT_ACCOUNT_ID" \ -x ' { "j": "2.0", "m": "v1/get_all_initial_leverage", "p": { "sa": "'$GRVT_SUB_ACCOUNT_ID'" }, "i": 123 } ' -w 360 ``` -------------------------------- ### Example Response for Get Point Summary Source: https://api-docs.grvt.io/referral_data Example JSON response for the Get Point Summary API, detailing the total points and community referral points earned by the account. ```json { "total_points": 1500.5, "community_referral_points": 320.25 } ``` -------------------------------- ### Example Response for Get Referral Data Source: https://api-docs.grvt.io/referral_data Example JSON response for the Get Referral Data API, illustrating the structure of referral data including account details, trading volume, fees, and earnings. ```json { "referrals": [ { "account_id": "ACC:1234abcd", "username": "trader_one", "funding_account_address": "0xAbCd1234...", "total_trading_volume": 50000.0, "total_trading_fee": 125.0, "total_eligible_trading_fee": 62.5, "earning_from_referral": 31.25 } ], "total": 42, "page_number": 0, "page_size": 20, "total_trading_volume": 150000.0 } ``` -------------------------------- ### Subscribe to Full Ticker Data (STAGING) Source: https://api-docs.grvt.io/market_data_streams Connect to the STAGING environment to subscribe to full ticker data for BTC_USDT_Perp. Ensure wscat is installed. ```bash wscat -c "wss://market-data.staging.gravitymarkets.io/ws/full" \ -x \ '{ "jsonrpc": "2.0", "method": "subscribe", "params": { "stream": "v1.ticker.d", "selectors": ["BTC_USDT_Perp@500"] }, "id": 123 }' -w 360 ``` -------------------------------- ### Get Authorized Builders (JSONRPC Full) Source: https://api-docs.grvt.io/trading_api This example shows how to use the JSONRPC Full WebSocket interface to get authorized builders. ```APIDOC ## GET /ws/full (JSONRPC Full) ### Description Retrieves a list of authorized builders using the JSONRPC Full WebSocket interface. ### Method WebSocket (JSONRPC Full) ### Endpoint `wss://trades.grvt.io/ws/full` ### Headers - **Cookie**: `$GRVT_COOKIE` - **X-Grvt-Account-Id**: `$GRVT_ACCOUNT_ID` ### Request Body ```json { "jsonrpc": "2.0", "method": "v1/get_authorized_builders", "params": {}, "id": 123 } ``` ### Response Example (Success response structure not provided in source text) ### Error Handling (Error response structure not provided in source text) ``` -------------------------------- ### Set Initial Leverage (Staging) Source: https://api-docs.grvt.io/trading_api Examples for setting leverage in the Staging environment using REST and JSONRPC. ```bash curl --location 'https://trades.staging.gravitymarkets.io/full/v1/set_initial_leverage' \ --header "Cookie: $GRVT_COOKIE" \ --header "X-Grvt-Account-Id: $GRVT_ACCOUNT_ID" \ --data '{ "sub_account_id": "'$GRVT_SUB_ACCOUNT_ID'", "instrument": "BTC_USDT_Perp", "leverage": "10" } ' ``` ```bash wscat -c "wss://trades.staging.gravitymarkets.io/ws/full" \ -H "Cookie: $GRVT_COOKIE" \ -H "X-Grvt-Account-Id: $GRVT_ACCOUNT_ID" \ -x ' { "jsonrpc": "2.0", "method": "v1/set_initial_leverage", "params": { "sub_account_id": "'$GRVT_SUB_ACCOUNT_ID'", "instrument": "BTC_USDT_Perp", "leverage": "10" }, "id": 123 } ' -w 360 ``` ```bash curl --location 'https://trades.staging.gravitymarkets.io/lite/v1/set_initial_leverage' \ --header "Cookie: $GRVT_COOKIE" \ --header "X-Grvt-Account-Id: $GRVT_ACCOUNT_ID" \ --data '{ "sa": "'$GRVT_SUB_ACCOUNT_ID'", "i": "BTC_USDT_Perp", "l": "10" } ' ``` ```bash wscat -c "wss://trades.staging.gravitymarkets.io/ws/lite" \ -H "Cookie: $GRVT_COOKIE" \ -H "X-Grvt-Account-Id: $GRVT_ACCOUNT_ID" \ -x ' { "j": "2.0", "m": "v1/set_initial_leverage", "p": { "sa": "'$GRVT_SUB_ACCOUNT_ID'", "i": "BTC_USDT_Perp", "l": "10" }, "i": 123 } ' -w 360 ``` -------------------------------- ### REST API Call: Get All Initial Leverage (Staging Full) Source: https://api-docs.grvt.io/trading_api Example of fetching all initial leverage data using the REST API (Staging environment, Full mode). Requires GRVT_COOKIE and X-Grvt-Account-Id headers, and sub_account_id in the payload. ```bash curl --location 'https://trades.staging.gravitymarkets.io/full/v1/get_all_initial_leverage' \ --header "Cookie: $GRVT_COOKIE" \ --header "X-Grvt-Account-Id: $GRVT_ACCOUNT_ID" \ --data '{ \ "sub_account_id": "'$GRVT_SUB_ACCOUNT_ID'" \ } ' ``` -------------------------------- ### REST API Call: Get All Initial Leverage (Testnet Full) Source: https://api-docs.grvt.io/trading_api Example of fetching all initial leverage data using the REST API (Testnet environment, Full mode). Requires GRVT_COOKIE and X-Grvt-Account-Id headers, and sub_account_id in the payload. ```bash curl --location 'https://trades.testnet.grvt.io/full/v1/get_all_initial_leverage' \ --header "Cookie: $GRVT_COOKIE" \ --header "X-Grvt-Account-Id: $GRVT_ACCOUNT_ID" \ --data '{ \ "sub_account_id": "'$GRVT_SUB_ACCOUNT_ID'" \ } ' ``` -------------------------------- ### Get Authorized Builders - Lite Response Example Source: https://api-docs.grvt.io/trading_api Example response for the lite endpoint, providing a condensed list of authorized builders and their fee rates. ```json { "r": [{ "ba": "'$GRVT_MAIN_ACCOUNT_ID'", "mf": 0.001, "ms": 0.0001 }] } ``` -------------------------------- ### Set Initial Leverage (Dev) Source: https://api-docs.grvt.io/trading_api Examples for setting leverage in the Dev environment using REST and JSONRPC. ```bash curl --location 'https://trades.dev.gravitymarkets.io/full/v1/set_initial_leverage' \ --header "Cookie: $GRVT_COOKIE" \ --header "X-Grvt-Account-Id: $GRVT_ACCOUNT_ID" \ --data '{ "sub_account_id": "'$GRVT_SUB_ACCOUNT_ID'", "instrument": "BTC_USDT_Perp", "leverage": "10" } ' ``` ```bash wscat -c "wss://trades.dev.gravitymarkets.io/ws/full" \ -H "Cookie: $GRVT_COOKIE" \ -H "X-Grvt-Account-Id: $GRVT_ACCOUNT_ID" \ -x ' { "jsonrpc": "2.0", "method": "v1/set_initial_leverage", "params": { "sub_account_id": "'$GRVT_SUB_ACCOUNT_ID'", "instrument": "BTC_USDT_Perp", "leverage": "10" }, "id": 123 } ' -w 360 ``` ```bash curl --location 'https://trades.dev.gravitymarkets.io/lite/v1/set_initial_leverage' \ --header "Cookie: $GRVT_COOKIE" \ --header "X-Grvt-Account-Id: $GRVT_ACCOUNT_ID" \ --data '{ "sa": "'$GRVT_SUB_ACCOUNT_ID'", "i": "BTC_USDT_Perp", "l": "10" } ' ``` ```bash wscat -c "wss://trades.dev.gravitymarkets.io/ws/lite" \ -H "Cookie: $GRVT_COOKIE" \ -H "X-Grvt-Account-Id: $GRVT_ACCOUNT_ID" \ -x ' { "j": "2.0", "m": "v1/set_initial_leverage", "p": { "sa": "'$GRVT_SUB_ACCOUNT_ID'", "i": "BTC_USDT_Perp", "l": "10" }, "i": 123 } ' -w 360 ``` -------------------------------- ### Example Response for List Epochs Source: https://api-docs.grvt.io/referral_data Example JSON response structure for the List Epochs API endpoint, showing a list of epoch objects with their start and end times. ```json { "epochs": [ { "epoch": 1, "start_time": "2025-01-01T00:00:00Z", "end_time": "2025-01-07T23:59:59Z" }, { "epoch": 2, "start_time": "2025-01-08T00:00:00Z", "end_time": "2025-01-14T23:59:59Z" } ] } ``` -------------------------------- ### Get Filtered Instruments Success Response Source: https://api-docs.grvt.io/market_data_api Example of a successful response containing instrument details. ```json { "result": [{ "instrument": "BTC_USDT_Perp", "instrument_hash": "0x030501", "base": "BTC", "quote": "USDT", "kind": "PERPETUAL", "venues": ["ORDERBOOK"], "settlement_period": "PERPETUAL", "base_decimals": 3, "quote_decimals": 3, ``` -------------------------------- ### REST API Call: Get All Initial Leverage (Staging Lite) Source: https://api-docs.grvt.io/trading_api Example of fetching all initial leverage data using the REST API (Staging environment, Lite mode). Requires GRVT_COOKIE and X-Grvt-Account-Id headers, and 'sa' (sub_account_id) in the payload. ```bash curl --location 'https://trades.staging.gravitymarkets.io/lite/v1/get_all_initial_leverage' \ --header "Cookie: $GRVT_COOKIE" \ --header "X-Grvt-Account-Id: $GRVT_ACCOUNT_ID" \ --data '{ \ "sa": "'$GRVT_SUB_ACCOUNT_ID'" \ } ' ``` -------------------------------- ### Get Instrument - Lite Request Example Source: https://api-docs.grvt.io/market_data_api Use the 'i' parameter for lite requests to specify the instrument name. ```json { "i": "BTC_USDT_Perp" } ``` -------------------------------- ### Subscribe to Lite Ticker Data (STAGING) Source: https://api-docs.grvt.io/market_data_streams Connect to the STAGING environment to subscribe to lite ticker data for BTC_USDT_Perp. Ensure wscat is installed. ```bash wscat -c "wss://market-data.staging.gravitymarkets.io/ws/lite" \ -x \ '{ "j": "2.0", "m": "subscribe", "p": { "s": "v1.ticker.d", "s1": ["BTC_USDT_Perp@500"] }, "i": 123 }' -w 360 ``` -------------------------------- ### Get Instrument - Full Request Example Source: https://api-docs.grvt.io/market_data_api Use the 'instrument' parameter for full requests to specify the instrument name. ```json { "instrument": "BTC_USDT_Perp" } ``` -------------------------------- ### API Key Authentication Setup Source: https://api-docs.grvt.io/trading_streams Environment variables and endpoint configuration for API key authentication. ```bash # These are the variables you will need to set manually GRVT_API_KEY="" GRVT_SUB_ACCOUNT_ID="" ``` ```bash # dev GRVT_AUTH_ENDPOINT="https://edge.dev.gravitymarkets.io/auth/api_key/login" # staging GRVT_AUTH_ENDPOINT="https://edge.staging.gravitymarkets.io/auth/api_key/login" ``` -------------------------------- ### Legacy Subscribe to State Stream (Full, Production) Source: https://api-docs.grvt.io/trading_streams This example shows how to subscribe to the 'v1.state' stream using the legacy format on the production environment. It specifies full data and requires authentication. ```bash wscat -c "wss://trades.grvt.io/ws" \ -H "Cookie: $GRVT_COOKIE" \ -H "X-Grvt-Account-Id: $GRVT_ACCOUNT_ID" \ -x \ '{ "request_id":1, "stream":"v1.state", "feed":["'$GRVT_SUB_ACCOUNT_ID'-BTC_USDT_Perp"], "method":"subscribe", "is_full":true }' -w 360 ``` -------------------------------- ### Get Instrument - Lite Response Example Source: https://api-docs.grvt.io/market_data_api The lite response provides a condensed version of instrument details using shorter key names. ```json { "r": { "i": "BTC_USDT_Perp", "ih": "0x030501", "b": "BTC", "q": "USDT", "k": "PERPETUAL", "v": ["ORDERBOOK"], "sp1": "PERPETUAL", "bd": 3, "qd": 3, "ts": "0.01", "ms": "0.01", "ct": "1697788800000000000", "mp": "100.0", "fi": 8, "af": 2.5, "af1": -2.5, "mn": "20.0" } } ``` -------------------------------- ### Get Instrument - Full Response Example Source: https://api-docs.grvt.io/market_data_api The full response includes detailed instrument information such as base currency, quote currency, kind, venues, and more. ```json { "result": { "instrument": "BTC_USDT_Perp", "instrument_hash": "0x030501", "base": "BTC", "quote": "USDT", "kind": "PERPETUAL", "venues": ["ORDERBOOK"], "settlement_period": "PERPETUAL", "base_decimals": 3, "quote_decimals": 3, "tick_size": "0.01", "min_size": "0.01", "create_time": "1697788800000000000", "max_position_size": "100.0", "funding_interval_hours": 8, "adjusted_funding_rate_cap": 2.5, "adjusted_funding_rate_floor": -2.5, "min_notional": "20.0" } } ``` -------------------------------- ### JSONRPC API Call: Get All Initial Leverage (Staging Full) Source: https://api-docs.grvt.io/trading_api Example of fetching all initial leverage data using JSONRPC (Staging environment, Full mode). Requires GRVT_COOKIE and X-Grvt-Account-Id headers, and sub_account_id in the params. ```bash wscat -c "wss://trades.staging.gravitymarkets.io/ws/full" \ -H "Cookie: $GRVT_COOKIE" \ -H "X-Grvt-Account-Id: $GRVT_ACCOUNT_ID" \ -x ' { "jsonrpc": "2.0", "method": "v1/get_all_initial_leverage", "params": { "sub_account_id": "'$GRVT_SUB_ACCOUNT_ID'" }, "id": 123 } ' -w 360 ``` -------------------------------- ### Get Sub Accounts (JSONRPC Full - Testnet) Source: https://api-docs.grvt.io/trading_api Example of fetching sub-accounts using the JSONRPC API in the testnet environment. Requires GRVT_COOKIE and X-Grvt-Account-Id headers. ```bash wscat -c "wss://trades.testnet.grvt.io/ws/full" \ -H "Cookie: $GRVT_COOKIE" \ -H "X-Grvt-Account-Id: $GRVT_ACCOUNT_ID" \ -x ' { "jsonrpc": "2.0", "method": "v1/get_sub_accounts", "params": { }, "id": 123 } ' -w 360 ``` -------------------------------- ### Get Sub Accounts (REST Full - Testnet) Source: https://api-docs.grvt.io/trading_api Example of fetching sub-accounts using the REST API in the testnet environment. Requires GRVT_COOKIE and X-Grvt-Account-Id headers. ```curl curl --location 'https://trades.testnet.grvt.io/full/v1/get_sub_accounts' \ --header "Cookie: $GRVT_COOKIE" \ --header "X-Grvt-Account-Id: $GRVT_ACCOUNT_ID" \ --data '{ } ' ``` -------------------------------- ### Legacy Subscribe to State Stream (Lite, Production) Source: https://api-docs.grvt.io/trading_streams This example demonstrates subscribing to the 'v1.state' stream with lite data using the legacy format on the production environment. It uses 'is_full': false. ```bash wscat -c "wss://trades.grvt.io/ws" \ -H "Cookie: $GRVT_COOKIE" \ -H "X-Grvt-Account-Id: $GRVT_ACCOUNT_ID" \ -x \ '{ "request_id":1, "stream":"v1.state", "feed":["'$GRVT_SUB_ACCOUNT_ID'-BTC_USDT_Perp"], "method":"subscribe", "is_full":false }' -w 360 ``` -------------------------------- ### Get Sub Accounts (JSONRPC Full - Staging) Source: https://api-docs.grvt.io/trading_api Example of fetching sub-accounts using the JSONRPC API in the staging environment. Requires GRVT_COOKIE and X-Grvt-Account-Id headers. ```bash wscat -c "wss://trades.staging.gravitymarkets.io/ws/full" \ -H "Cookie: $GRVT_COOKIE" \ -H "X-Grvt-Account-Id: $GRVT_ACCOUNT_ID" \ -x ' { "jsonrpc": "2.0", "method": "v1/get_sub_accounts", "params": { }, "id": 123 } ' -w 360 ``` -------------------------------- ### Subscribe to Full Market Data Stream (Dev Environment) Source: https://api-docs.grvt.io/market_data_streams Use this command to subscribe to a full market data stream in the development environment. Ensure you have `wscat` installed and replace placeholders as needed. ```bash wscat -c "wss://market-data.dev.gravitymarkets.io/ws/full" \ -x \ '\ {\ "jsonrpc": "2.0",\ "method": "subscribe",\ "params": {\ "stream": "v1.book.d",\ "selectors": ["BTC_USDT_Perp@500"]\ },\ "id": 123\ }' -w 360 ``` -------------------------------- ### Get Sub Accounts (REST Full - Staging) Source: https://api-docs.grvt.io/trading_api Example of fetching sub-accounts using the REST API in the staging environment. Requires GRVT_COOKIE and X-Grvt-Account-Id headers. ```curl curl --location 'https://trades.staging.gravitymarkets.io/full/v1/get_sub_accounts' \ --header "Cookie: $GRVT_COOKIE" \ --header "X-Grvt-Account-Id: $GRVT_ACCOUNT_ID" \ --data '{ } ' ``` -------------------------------- ### Subscribe to Full Market Data Stream (Staging) Source: https://api-docs.grvt.io/market_data_streams Use this command to subscribe to the full market data stream on the staging environment. Ensure you have wscat installed. ```bash wscat -c "wss://market-data.staging.gravitymarkets.io/ws/full" \ -x \ ' \ { "jsonrpc": "2.0", "method": "subscribe", "params": { "stream": "v1.trade", "selectors": ["BTC_USDT_Perp@500"] }, "id": 123 }' -w 360 ``` -------------------------------- ### Get Sub Accounts (JSONRPC Full - Dev) Source: https://api-docs.grvt.io/trading_api Example of fetching sub-accounts using the JSONRPC API in the development environment. Requires GRVT_COOKIE and X-Grvt-Account-Id headers. ```bash wscat -c "wss://trades.dev.gravitymarkets.io/ws/full" \ -H "Cookie: $GRVT_COOKIE" \ -H "X-Grvt-Account-Id: $GRVT_ACCOUNT_ID" \ -x ' { "jsonrpc": "2.0", "method": "v1/get_sub_accounts", "params": { }, "id": 123 } ' -w 360 ``` -------------------------------- ### Staging Environment Requests Source: https://api-docs.grvt.io/trading_api Examples for accessing authorized builders in the staging environment. ```bash curl --location 'https://trades.staging.gravitymarkets.io/full/v1/get_authorized_builders' \ --header "Cookie: $GRVT_COOKIE" \ --header "X-Grvt-Account-Id: $GRVT_ACCOUNT_ID" \ --data '{ } ' ``` ```bash wscat -c "wss://trades.staging.gravitymarkets.io/ws/full" \ -H "Cookie: $GRVT_COOKIE" \ -H "X-Grvt-Account-Id: $GRVT_ACCOUNT_ID" \ -x ' { "jsonrpc": "2.0", "method": "v1/get_authorized_builders", "params": { }, "id": 123 } ' -w 360 ``` ```bash curl --location 'https://trades.staging.gravitymarkets.io/lite/v1/get_authorized_builders' \ --header "Cookie: $GRVT_COOKIE" \ --header "X-Grvt-Account-Id: $GRVT_ACCOUNT_ID" \ --data '{ } ' ``` ```bash wscat -c "wss://trades.staging.gravitymarkets.io/ws/lite" \ -H "Cookie: $GRVT_COOKIE" \ -H "X-Grvt-Account-Id: $GRVT_ACCOUNT_ID" \ -x ' { "j": "2.0", "m": "v1/get_authorized_builders", "p": { }, "i": 123 } ' -w 360 ``` -------------------------------- ### Get Sub Accounts (REST Full - Dev) Source: https://api-docs.grvt.io/trading_api Example of fetching sub-accounts using the REST API in the development environment. Requires GRVT_COOKIE and X-Grvt-Account-Id headers. ```curl curl --location 'https://trades.dev.gravitymarkets.io/full/v1/get_sub_accounts' \ --header "Cookie: $GRVT_COOKIE" \ --header "X-Grvt-Account-Id: $GRVT_ACCOUNT_ID" \ --data '{ } ' ``` -------------------------------- ### Get Sub Accounts Response (Full) Source: https://api-docs.grvt.io/trading_api Example of a successful response from the 'get_sub_accounts' endpoint using the full API specification, listing accessible sub-account IDs. ```json { "sub_account_ids": ["4724219064482495","2095919380","1170592370"] } ``` -------------------------------- ### Subscribe to Full Ticker Data (TESTNET) Source: https://api-docs.grvt.io/market_data_streams Connect to the TESTNET environment to subscribe to full ticker data for BTC_USDT_Perp. Ensure wscat is installed. ```bash wscat -c "wss://market-data.testnet.grvt.io/ws/full" \ -x \ '{ "jsonrpc": "2.0", "method": "subscribe", "params": { "stream": "v1.ticker.d", "selectors": ["BTC_USDT_Perp@500"] }, "id": 123 }' -w 360 ``` -------------------------------- ### Get Margin Rules - REST Lite Request (TESTNET) Source: https://api-docs.grvt.io/market_data_api Example of a cURL command to make a REST request for margin rules using the lite API on the TESTNET environment. ```bash curl --location 'https://market-data.testnet.grvt.io/lite/v1/margin_rules' \ --data '{ "i": "BTC_USDT_Perp" } ' ``` -------------------------------- ### JSONRPC API Call: Get All Initial Leverage (Staging Lite) Source: https://api-docs.grvt.io/trading_api Example of fetching all initial leverage data using JSONRPC (Staging environment, Lite mode). Requires GRVT_COOKIE and X-Grvt-Account-Id headers, and 'p.sa' (sub_account_id) in the params. ```bash wscat -c "wss://trades.staging.gravitymarkets.io/ws/lite" \ -H "Cookie: $GRVT_COOKIE" \ -H "X-Grvt-Account-Id: $GRVT_ACCOUNT_ID" \ -x ' { "j": "2.0", "m": "v1/get_all_initial_leverage", "p": { "sa": "'$GRVT_SUB_ACCOUNT_ID'" }, "i": 123 } ' -w 360 ``` -------------------------------- ### Get Margin Rules - JSONRPC Full Request (TESTNET) Source: https://api-docs.grvt.io/market_data_api Example of a wscat command to make a JSONRPC request for margin rules using the full API on the TESTNET environment. ```bash wscat -c "wss://market-data.testnet.grvt.io/ws/full" \ -x ' { "jsonrpc": "2.0", "method": "v1/margin_rules", "params": { "instrument": "BTC_USDT_Perp" }, "id": 123 } ' -w 360 ``` -------------------------------- ### Get Margin Rules - REST Full Request (TESTNET) Source: https://api-docs.grvt.io/market_data_api Example of a cURL command to make a REST request for margin rules using the full API on the TESTNET environment. ```bash curl --location 'https://market-data.testnet.grvt.io/full/v1/margin_rules' \ --data '{ "instrument": "BTC_USDT_Perp" } ' ``` -------------------------------- ### Subscribe to Full Ticker Data (DEV) Source: https://api-docs.grvt.io/market_data_streams Connect to the DEV environment to subscribe to full ticker data for BTC_USDT_Perp. Ensure wscat is installed. ```bash wscat -c "wss://market-data.dev.gravitymarkets.io/ws/full" \ -x \ '{ "jsonrpc": "2.0", "method": "subscribe", "params": { "stream": "v1.ticker.d", "selectors": ["BTC_USDT_Perp@500"] }, "id": 123 }' -w 360 ``` -------------------------------- ### Subscribe to Lite Market Data Stream (Staging) Source: https://api-docs.grvt.io/market_data_streams Use this command to subscribe to the lite market data stream on the staging environment. Ensure you have wscat installed. ```bash wscat -c "wss://market-data.staging.gravitymarkets.io/ws/lite" \ -x \ ' \ { "j": "2.0", "m": "subscribe", "p": { "s": "v1.trade", "s1": ["BTC_USDT_Perp@500"] }, "i": 123 }' -w 360 ``` -------------------------------- ### Get Margin Rules - JSONRPC Lite Request (STAGING) Source: https://api-docs.grvt.io/market_data_api Example of a wscat command to make a JSONRPC request for margin rules using the lite API on the STAGING environment. ```bash wscat -c "wss://market-data.staging.gravitymarkets.io/ws/lite" \ -x ' { "j": "2.0", "m": "v1/margin_rules", "p": { "i": "BTC_USDT_Perp" }, "i": 123 } ' -w 360 ``` -------------------------------- ### Get Margin Rules - REST Lite Request (STAGING) Source: https://api-docs.grvt.io/market_data_api Example of a cURL command to make a REST request for margin rules using the lite API on the STAGING environment. ```bash curl --location 'https://market-data.staging.gravitymarkets.io/lite/v1/margin_rules' \ --data '{ "i": "BTC_USDT_Perp" } ' ``` -------------------------------- ### Subscribe to Full Market Data Stream (Staging Environment) Source: https://api-docs.grvt.io/market_data_streams Use this command to subscribe to a full market data stream in the staging environment. This is similar to the dev environment but targets the staging infrastructure. ```bash wscat -c "wss://market-data.staging.gravitymarkets.io/ws/full" \ -x \ '\ {\ "jsonrpc": "2.0",\ "method": "subscribe",\ "params": {\ "stream": "v1.book.d",\ "selectors": ["BTC_USDT_Perp@500"]\ },\ "id": 123\ }' -w 360 ``` -------------------------------- ### Subscribe to Lite Market Data Stream (Staging Environment) Source: https://api-docs.grvt.io/market_data_streams Use this command to subscribe to a lite market data stream in the staging environment. This provides a more compact data format for testing. ```bash wscat -c "wss://market-data.staging.gravitymarkets.io/ws/lite" \ -x \ '\ {\ "j": "2.0",\ "m": "subscribe",\ "p": {\ "s": "v1.book.d",\ "s1": ["BTC_USDT_Perp@500"]\ },\ "i": 123\ }' -w 360 ``` -------------------------------- ### Get Margin Rules - JSONRPC Full Request (STAGING) Source: https://api-docs.grvt.io/market_data_api Example of a wscat command to make a JSONRPC request for margin rules using the full API on the STAGING environment. ```bash wscat -c "wss://market-data.staging.gravitymarkets.io/ws/full" \ -x ' { "jsonrpc": "2.0", "method": "v1/margin_rules", "params": { "instrument": "BTC_USDT_Perp" }, "id": 123 } ' -w 360 ``` -------------------------------- ### Legacy Subscribe to Full Market Data (Staging) Source: https://api-docs.grvt.io/market_data_streams Use this command for legacy subscriptions to the full market data stream on the staging environment. Ensure you have wscat installed. ```bash wscat -c "wss://market-data.staging.gravitymarkets.io/ws" \ -x \ ' \ { "request_id":1, "stream":"v1.trade", "feed":["BTC_USDT_Perp@500"], "method":"subscribe", "is_full":true }' -w 360 ```