### Get Positions - Swift Example Source: https://docs.sandbox.gemini.com/prediction-markets/positions Provides a Swift example for fetching current positions. This utilizes `URLSession` to construct and execute the POST request to the Gemini API. ```swift // Swift example for fetching positions would go here. // This would typically involve using URLSession // to make a POST request to the /v1/prediction-markets/positions endpoint. ``` -------------------------------- ### Get Order Status using Java Source: https://docs.sandbox.gemini.com/rest/orders This Java code provides an example of how to call the Gemini API to get order status. It demonstrates setting up the HTTP request, including authentication headers and the request body. ```java import okhttp3.*; import org.json.JSONObject; import java.io.IOException; public class GetOrderStatus { public static void main(String[] args) throws IOException { String apiKey = ""; String apiSecret = ""; long nonce = System.currentTimeMillis(); JSONObject payload = new JSONObject(); payload.put("request", "/v1/order/status"); payload.put("nonce", nonce); payload.put("order_id", 123456789012345L); payload.put("include_trades", true); String payloadString = payload.toString(); String encodedPayload = java.util.Base64.getEncoder().encodeToString(payloadString.getBytes()); String signature = hmacSha384(encodedPayload, apiSecret); OkHttpClient client = new OkHttpClient(); MediaType JSON = MediaType.get("application/json; charset=utf-8"); RequestBody body = RequestBody.create(payloadString, JSON); Request request = new Request.Builder() .url("https://api.sandbox.gemini.com/v1/order/status") .post(body) .addHeader("X-GEMINI-APIKEY", apiKey) .addHeader("X-GEMINI-PAYLOAD", encodedPayload) .addHeader("X-GEMINI-SIGNATURE", signature) .addHeader("Content-Type", "application/json") .build(); try (Response response = client.newCall(request).execute()) { if (!response.isSuccessful()) throw new IOException("Unexpected code " + response); System.out.println(response.body().string()); } } private static String hmacSha384(String data, String secret) { try { Mac mac = Mac.getInstance("HmacSHA384"); SecretKeySpec secretKeySpec = new SecretKeySpec(secret.getBytes(), "HmacSHA384"); mac.init(secretKeySpec); byte[] digest = mac.doFinal(data.getBytes()); StringBuilder hexString = new StringBuilder(); for (byte b : digest) { String hex = Integer.toHexString(0xff & b); if (hex.length() == 1) { hexString.append('0'); } hexString.append(hex); } return hexString.toString(); } catch (Exception e) { throw new RuntimeException(e); } } } ``` -------------------------------- ### Get Open Positions Example Response - JSON Source: https://docs.sandbox.gemini.com/rest/derivatives Example JSON response for a successful request to get open positions. It details the structure of the returned data, including symbol, instrument type, quantity, PNL, and pricing information for each open position. ```json [ { "symbol": "btcgusdperp", "instrument_type": "perp", "quantity": "0.2", "notional_value": "4000.036", "realised_pnl": "1234.5678", "unrealised_pnl": "999.946", "average_cost": "15000.45", "mark_price": "20000.18" } ] ``` -------------------------------- ### Get Positions - C# Example Source: https://docs.sandbox.gemini.com/prediction-markets/positions Provides a C# example for fetching current positions. This involves using `HttpClient` to perform a POST request to the positions endpoint and handle the response. ```csharp // C# example for fetching positions would go here. // This would typically involve using HttpClient // to make a POST request to the /v1/prediction-markets/positions endpoint. ``` -------------------------------- ### Example JSON Response for Get Funding Amount Source: https://docs.sandbox.gemini.com/rest-api An example of a JSON response for the 'Get Funding Amount' endpoint, detailing funding information for a specific symbol. ```json { "symbol": "BTCGUSDPERP", "fundingDateTime": "2025-04-22T18:00:00.000Z", "fundingTimestampMilliSecs": 1745344800000, "nextFundingTimestamp": 1745348400000, "fundingAmount": -1.50991, "estimatedFundingAmount": -2.10595 } ``` -------------------------------- ### Get Order Status using Go Source: https://docs.sandbox.gemini.com/rest/orders This Go code example demonstrates how to implement the Gemini API call to retrieve order status. It includes generating the signature and making the POST request. ```go package main import ( "bytes" "crypto/hmac" "crypto/sha256" // Note: Gemini uses SHA384, adjust if needed "encoding/base64" "encoding/hex" "encoding/json" "fmt" "io/ioutil" "net/http" "strconv" "time" ) func main() { apiKey := "" apiSecret := "" nonce := strconv.FormatInt(time.Now().UnixNano(), 10) payload := map[string]interface{}{ "request": "/v1/order/status", "nonce": nonce, "order_id": 123456789012345, "include_trades": true, } payloadBytes, _ := json.Marshal(payload) encodedPayload := base64.StdEncoding.EncodeToString(payloadBytes) ssignature := hmacSha384(encodedPayload, apiSecret) client := &http.Client{} req, err := http.NewRequest("POST", "https://api.sandbox.gemini.com/v1/order/status", bytes.NewBuffer(payloadBytes)) if err != nil { fmt.Printf("Error creating request: %s\n", err) return } req.Header.Set("Content-Type", "application/json") req.Header.Set("X-GEMINI-APIKEY", apiKey) req.Header.Set("X-GEMINI-PAYLOAD", encodedPayload) req.Header.Set("X-GEMINI-SIGNATURE", signature) resp, err := client.Do(req) if err != nil { fmt.Printf("Error sending request: %s\n", err) return } defer resp.Body.Close() body, err := ioutil.ReadAll(resp.Body) if err != nil { fmt.Printf("Error reading response body: %s\n", err) return } fmt.Println(string(body)) } func hmacSha384(data, secret string) string { key := []byte(secret) hmac := hmac.New(sha256.New, key) // Use sha384.New for SHA384 hmac.Write([]byte(data)) return hex.EncodeToString(hmac.Sum(nil)) } ``` -------------------------------- ### Get Order History - Go Example Source: https://docs.sandbox.gemini.com/prediction-markets/positions Presents a Go example for retrieving order history. This typically involves using Go's standard `net/http` package to create a client, build the request, and send it to the specified API endpoint. ```go // Go example for fetching order history would go here. // This would typically involve using the net/http package // to make a POST request to the /v1/prediction-markets/orders/history endpoint. ``` -------------------------------- ### Get Positions - Go Example Source: https://docs.sandbox.gemini.com/prediction-markets/positions Presents a Go example for retrieving current positions. Using Go's standard `net/http` package, this code would construct and send a POST request to the specified API endpoint. ```go // Go example for fetching positions would go here. // This would typically involve using the net/http package // to make a POST request to the /v1/prediction-markets/positions endpoint. ``` -------------------------------- ### Get Roles - Request Body Example Source: https://docs.sandbox.gemini.com/rest/account-administration An example of the JSON request body for the /v1/roles endpoint, which requires a 'request' path and a 'nonce'. ```json { "request": "/v1/roles", "nonce": "" } ``` -------------------------------- ### Get Positions - Python Example Source: https://docs.sandbox.gemini.com/prediction-markets/positions Provides a Python example for retrieving current positions. It would use the `requests` library to send a POST request to the positions endpoint, processing the returned data. ```python # Python example for fetching positions would go here. # This would typically involve using the 'requests' library # to make a POST request to the /v1/prediction-markets/positions endpoint. ``` -------------------------------- ### Get Positions - Ruby Example Source: https://docs.sandbox.gemini.com/prediction-markets/positions Presents a Ruby example for retrieving current positions. This typically uses `Net::HTTP` or gems like `httparty` to make the POST request to the positions endpoint. ```ruby # Ruby example for fetching positions would go here. # This would typically involve using Net::HTTP or 'httparty' gem # to make a POST request to the /v1/prediction-markets/positions endpoint. ``` -------------------------------- ### Get Positions - JavaScript Example Source: https://docs.sandbox.gemini.com/prediction-markets/positions Offers a JavaScript example for fetching current positions. This involves making a POST request to the /v1/prediction-markets/positions endpoint, likely using `fetch` or a similar API. ```javascript // JavaScript example for fetching positions would go here. // This would typically involve using fetch or a library like axios // to make a POST request to the /v1/prediction-markets/positions endpoint. ``` -------------------------------- ### Get Order Status using Ruby Source: https://docs.sandbox.gemini.com/rest/orders This Ruby snippet provides an example of how to call the Gemini API to get order status. It demonstrates creating the signed request with API credentials and payload. ```ruby require 'net/http' require 'uri' require 'openssl' require 'base64' require 'json' def get_gemini_order_status(api_key, api_secret) uri = URI.parse('https://api.sandbox.gemini.com/v1/order/status') nonce = Time.now.to_i * 1000 # Nonce in milliseconds payload = { request: '/v1/order/status', nonce: nonce, order_id: 123456789012345, include_trades: true } payload_json = payload.to_json encoded_payload = Base64.strict_encode64(payload_json) signature = OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha384'), api_secret, encoded_payload) http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true request = Net::HTTP::Post.new(uri.request_uri) request['Content-Type'] = 'application/json' request['X-GEMINI-APIKEY'] = api_key request['X-GEMINI-PAYLOAD'] = encoded_payload request['X-GEMINI-SIGNATURE'] = signature request.body = payload_json response = http.request(request) return JSON.parse(response.body) if response.is_a?(Net::HTTPSuccess) puts "HTTP Error: #{response.code} #{response.message}" puts "Response: #{response.body}" nil end api_key = '' api_secret = '' order_status = get_gemini_order_status(api_key, api_secret) if order_status puts JSON.pretty_generate(order_status) end ``` -------------------------------- ### Get Order History - Swift Example Source: https://docs.sandbox.gemini.com/prediction-markets/positions Provides a Swift example for fetching order history. This would leverage `URLSession` to construct and execute the POST request to the Gemini API, handling the JSON response. ```swift // Swift example for fetching order history would go here. // This would typically involve using URLSession // to make a POST request to the /v1/prediction-markets/orders/history endpoint. ``` -------------------------------- ### Get Order History - C# Example Source: https://docs.sandbox.gemini.com/prediction-markets/positions Provides a C# example for fetching order history. This usually involves using `HttpClient` to send a POST request to the Gemini API, ensuring the request body and headers are correctly formatted. ```csharp // C# example for fetching order history would go here. // This would typically involve using HttpClient // to make a POST request to the /v1/prediction-markets/orders/history endpoint. ``` -------------------------------- ### Get Positions - Java Example Source: https://docs.sandbox.gemini.com/prediction-markets/positions Shows a Java implementation for fetching current positions. This example would use Java's HTTP client capabilities to send a POST request to the positions endpoint. ```java // Java example for fetching positions would go here. // This would typically involve using HttpClient or OkHttp // to make a POST request to the /v1/prediction-markets/positions endpoint. ``` -------------------------------- ### Get Order History - Ruby Example Source: https://docs.sandbox.gemini.com/prediction-markets/positions Presents a Ruby example for retrieving order history. This typically uses the built-in `Net::HTTP` library or gems like `httparty` to make the POST request to the specified API endpoint. ```ruby # Ruby example for fetching order history would go here. # This would typically involve using Net::HTTP or 'httparty' gem # to make a POST request to the /v1/prediction-markets/orders/history endpoint. ``` -------------------------------- ### Get Risk Stats Example Response - JSON Source: https://docs.sandbox.gemini.com/rest/derivatives Example JSON response for a successful request to get risk statistics. It includes details such as product type, mark price, index price, and open interest for the requested symbol. ```json { "product_type": "PerpetualSwapContract", "mark_price": "30080.00", "index_price": "30079.046", "open_interest": "14.439", "open_interest_notional": "434325.12" } ``` -------------------------------- ### Fetch Order History - Request Body Example Source: https://docs.sandbox.gemini.com/rest/orders Provides an example of the JSON payload structure for requesting order history. It includes the 'request' path, a unique 'nonce', and the 'limit_orders' parameter. ```json { "request": "/v1/orders/history", "nonce": "", "limit_orders": 50 } ``` -------------------------------- ### Get Notional Balances Request Body Example Source: https://docs.sandbox.gemini.com/rest/fund-management An example of the JSON request body required for the 'Get Notional Balances' API endpoint. It specifies the request path and a nonce for authentication. This can be used to fetch balances for a specific currency like USD. ```json { "request": "/v1/notionalbalances/usd", "nonce": "" } ``` -------------------------------- ### cURL Request Example Source: https://docs.sandbox.gemini.com/authentication/api-key Example of how to construct and send a request using cURL, including generating the nonce, base64-encoding the payload, calculating the signature, and setting the necessary headers. ```APIDOC ## Generating payload and signature header examples ### cURL ```bash # Create a proper payload with a single nonce value NONCE=$(date +%s.%N) PAYLOAD=$(echo -n "{\"request\":\"/v2/fxrate/EURUSD/2025-04-16T23:07:27.189Z\",\"nonce\":$NONCE}" | base64 | tr -d '\n') SIGNATURE=$(echo -n "$PAYLOAD" | openssl dgst -sha384 -hmac "GEMINI_API_SECRET" | cut -d ' ' -f2) # Execute the command with the calculated values curl -X GET "https://api.gemini.com/v2/fxrate/EURUSD/2025-04-16T23:07:27.189Z" \ -H "Content-Type: text/plain" \ -H "Content-Length: 0" \ -H "X-GEMINI-APIKEY: GEMINI_API_KEY" \ -H "X-GEMINI-PAYLOAD: $PAYLOAD" \ -H "X-GEMINI-SIGNATURE: $SIGNATURE" \ -H "Cache-Control: no-cache" ``` ``` -------------------------------- ### Get Account Detail Response Example (200 OK) Source: https://docs.sandbox.gemini.com/rest/account-administration Example successful JSON response for the 'Get Account Detail' endpoint. It contains account information, a list of users associated with the account, and potentially a memo reference code and virtual account number. ```json { "account": { "accountName": "Primary", "shortName": "primary", "type": "exchange", "created": "1498245007981" }, "users": [ { "name": "Satoshi Nakamoto", "lastSignIn": "2020-07-21T13:37:39.453Z", "status": "Active", "countryCode": "US", "isVerified": true }, { "name": "Gemini Support", "lastSignIn": "2018-07-11T20:04:36.073Z", "status": "Suspended", "countryCode": "US", "isVerified": false } ], "memo_reference_code": "GEMPJBRDZ", "virtual_account_number": "123456" } ``` -------------------------------- ### Python Request Example Source: https://docs.sandbox.gemini.com/authentication/api-key Illustrates how to generate the payload and signature for an API request using Python, including setting up the necessary libraries and variables. ```APIDOC ### Python ```python import json import base64 import hmac import hashlib import time url = "https://api.gemini.com/v2/fxrate/EURUSD/2025-04-16T23:07:27.189Z" gemini_api_secret = "GEMINI_API_SECRET".encode() gemini_api_key= "GEMINI_API_KEY" payload_nonce = time.time() # Extract path from URL _, path = url.split(".com") # Create payload object payload = {"request": path, "nonce": payload_nonce} # (Further Python code for encoding and signing would follow here) ``` ``` -------------------------------- ### List Past Trades Example Response (JSON) Source: https://docs.sandbox.gemini.com/rest/orders Example JSON response from the /v1/mytrades endpoint, detailing individual trades with price, amount, timestamp, fees, and order information. This structure is returned when trades are found for the specified symbol. ```json [ { "price": "3648.09", "amount": "0.0027343246", "timestamp": 1547232911, "timestampms": 1547232911021, "type": "Buy", "aggressor": true, "fee_currency": "USD", "fee_amount": "0.024937655575035", "tid": 107317526, "order_id": "107317524", "exchange": "gemini", "is_clearing_fill": false, "symbol": "BTCUSD" }, { "price": "3633.00", "amount": "0.00423677", "timestamp": 1547220640, "timestampms": 1547220640195, "type": "Buy", "aggressor": false, "fee_currency": "USD", "fee_amount": "0.038480463525", "tid": 106921823, "order_id": "106817811", "exchange": "gemini", "is_clearing_fill": false, "symbol": "BTCUSD" } ] ``` -------------------------------- ### Example JSON Response for List Prices Source: https://docs.sandbox.gemini.com/rest-api An example of a JSON response for the 'List Prices' endpoint, showing the structure for multiple trading pairs. ```json [ { "pair": "BTCUSD", "price": "9500.00", "percentChange24h": "5.23" }, { "pair": "ETHUSD", "price": "257.54", "percentChange24h": "4.85" }, { "pair": "BCHUSD", "price": "450.10", "percentChange24h": "-2.91" }, { "pair": "LTCUSD", "price": "79.50", "percentChange24h": "7.63" } ] ``` -------------------------------- ### Execute Instant Order via cURL Source: https://docs.sandbox.gemini.com/rest/instant This snippet demonstrates how to execute an instant order using cURL. It includes the necessary POST request, URL, headers (API key, payload, signature), and the JSON data payload with order details. Ensure the nonce is unique for each request. ```curl curl --request POST \ --url https://api.sandbox.gemini.com/v1/instant/execute \ --header 'Content-Type: application/json' \ --header 'X-GEMINI-APIKEY: ' \ --header 'X-GEMINI-PAYLOAD: ' \ --header 'X-GEMINI-SIGNATURE: ' \ --data \ '{ "request": "/v1/instant/execute", "nonce": "", "symbol": "BTCUSD", "side": "buy", "quantity": "0.01505181", "price": "6445.07", "fee": "2.9900309233", "quoteId": 1328 }' ``` -------------------------------- ### List Payment Methods via Go Source: https://docs.sandbox.gemini.com/rest/fund-management This Go program demonstrates how to list payment methods for a Gemini account using the `net/http` package. It sends a POST request with the necessary headers and a JSON payload. ```go package main import ( "bytes" "fmt" "net/http" ) func main() { url := "https://api.sandbox.gemini.com/v1/payments/methods" requestBody := []byte(`{ "request": "/v1/payments/methods", "account": "primary", "nonce": "" }`) req, err := http.NewRequest("POST", url, bytes.NewBuffer(requestBody)) if err != nil { fmt.Println("Error creating request:", err) return } req.Header.Set("Content-Type", "application/json") req.Header.Set("X-GEMINI-APIKEY", "") req.Header.Set("X-GEMINI-PAYLOAD", "") req.Header.Set("X-GEMINI-SIGNATURE", "") client := &http.Client{} resp, err := client.Do(req) if err != nil { fmt.Println("Error sending request:", err) return } defer resp.Body.Close() fmt.Println("Response Status:", resp.Status) // ... (handle response body) } ``` -------------------------------- ### Get Positions - Objective-C Example Source: https://docs.sandbox.gemini.com/prediction-markets/positions Offers an Objective-C example for retrieving current positions. This would use `URLSession` or other networking APIs to make the POST request to the positions endpoint. ```objective-c // Objective-C example for fetching positions would go here. // This would typically involve using NSURLSession // to make a POST request to the /v1/prediction-markets/positions endpoint. ``` -------------------------------- ### Get Account Detail Request Body Example Source: https://docs.sandbox.gemini.com/rest/account-administration A JSON object representing the request body for the 'Get Account Detail' endpoint. It includes the 'request' path, an optional 'account' name, and a 'nonce'. ```json { "request": "/v1/account", "account": "primary", "nonce": "" } ``` -------------------------------- ### List Payment Methods via C# Source: https://docs.sandbox.gemini.com/rest/fund-management This C# code example demonstrates how to list payment methods for a Gemini account using `HttpClient`. It sends a POST request with the required headers and JSON payload. ```csharp using System; using System.Net.Http; using System.Text; using System.Threading.Tasks; public class GeminiApi { public static async Task ListPaymentMethodsAsync() { using (var client = new HttpClient()) { var url = "https://api.sandbox.gemini.com/v1/payments/methods"; var jsonBody = @"{ \"request\": \"/v1/payments/methods\", \"account\": \"primary\", \"nonce\": \"\" }"; var content = new StringContent(jsonBody, Encoding.UTF8, "application/json"); client.DefaultRequestHeaders.Add("X-GEMINI-APIKEY", ""); client.DefaultRequestHeaders.Add("X-GEMINI-PAYLOAD", ""); client.DefaultRequestHeaders.Add("X-GEMINI-SIGNATURE", ""); var response = await client.PostAsync(url, content); var responseString = await response.Content.ReadAsStringAsync(); Console.WriteLine(responseString); } } } ``` -------------------------------- ### List Payment Methods via Swift Source: https://docs.sandbox.gemini.com/rest/fund-management This Swift code example demonstrates how to list payment methods for a Gemini account using `URLSession`. It constructs a POST request with the required headers and JSON body. ```swift import Foundation func listPaymentMethods() { guard let url = URL(string: "https://api.sandbox.gemini.com/v1/payments/methods") else { return } var request = URLRequest(url: url) request.httpMethod = "POST" request.setValue("application/json", forHTTPHeaderField: "Content-Type") request.setValue("", forHTTPHeaderField: "X-GEMINI-APIKEY") request.setValue("", forHTTPHeaderField: "X-GEMINI-PAYLOAD") request.setValue("", forHTTPHeaderField: "X-GEMINI-SIGNATURE") let body: [String: Any] = [ "request": "/v1/payments/methods", "account": "primary", "nonce": "" ] do { request.httpBody = try JSONSerialization.data(withJSONObject: body, options: []) } catch { print("Error serializing JSON: \(error)") return } URLSession.shared.dataTask(with: request) { data, response, error in if let error = error { print("Error: \(error)") return } guard let data = data else { return } print(String(data: data, encoding: .utf8) ?? "") }.resume() } ``` -------------------------------- ### List Payment Methods via Python Source: https://docs.sandbox.gemini.com/rest/fund-management This Python example demonstrates how to list payment methods for a Gemini account using the `requests` library. It sends a POST request with the required headers and a JSON payload. ```python import requests import json url = "https://api.sandbox.gemini.com/v1/payments/methods" headers = { "Content-Type": "application/json", "X-GEMINI-APIKEY": "", "X-GEMINI-PAYLOAD": "", "X-GEMINI-SIGNATURE": "" } data = { "request": "/v1/payments/methods", "account": "primary", "nonce": "" } response = requests.post(url, headers=headers, data=json.dumps(data)) print(response.json()) ``` -------------------------------- ### Get Symbol Details - Swift Source: https://docs.sandbox.gemini.com/rest/market-data This Swift code example illustrates how to get detailed information for a specific trading symbol using the Gemini API. Replace '{symbol}' with the trading pair you need details for. ```swift import Foundation let symbol = "BTCUSD" // Replace with your desired symbol let urlString = "https://api.sandbox.gemini.com/v1/symbols/details/(symbol)" let url = URL(string: urlString)! let task = URLSession.shared.dataTask(with: url) { data, response, error in if let error = error { print("Error: \(error.localizedDescription)\n") return } guard let data = data else { print("No data received\n") return } if let jsonString = String(data: data, encoding: .utf8) { print(jsonString) } } task.resume() ``` -------------------------------- ### List Active Orders - Request Body Examples Source: https://docs.sandbox.gemini.com/rest/orders Provides examples of the JSON request body used when calling the Gemini API to list active orders. It shows a basic request and one that includes an account parameter. ```json { "request": "/v1/orders", "nonce": "" } ``` ```json { "request": "/v1/orders", "nonce": "", "account": "primary" } ``` -------------------------------- ### Limit Order Response (JSON) Source: https://docs.sandbox.gemini.com/rest/orders Example JSON response for a successfully created limit order. Contains details such as order ID, symbol, execution price, timestamps, and amounts. ```json { "order_id": "106817811", "id": "106817811", "symbol": "BTCUSD", "exchange": "gemini", "avg_execution_price": "3632.8508430064554", "side": "buy", "type": "exchange limit", "timestamp": "1547220404", "timestampms": 1547220404836, "is_live": true, "is_cancelled": false, "is_hidden": false, "was_forced": false, "executed_amount": "3.7567928949", "remaining_amount": "1.2432071051", "client_order_id": "20190110-4738721", "options": [], "price": "3633.00", "original_amount": "5" } ``` -------------------------------- ### Get Order History - Objective-C Example Source: https://docs.sandbox.gemini.com/prediction-markets/positions Offers an Objective-C example for retrieving order history. This would typically involve using `URLSession` or other networking libraries to perform the POST request to the API endpoint. ```objective-c // Objective-C example for fetching order history would go here. // This would typically involve using NSURLSession // to make a POST request to the /v1/prediction-markets/orders/history endpoint. ``` -------------------------------- ### Get Risk Stats Request - cURL Source: https://docs.sandbox.gemini.com/rest/derivatives Example cURL request to retrieve risk statistics for a specific symbol from the Gemini API sandbox. This request uses the GET method and specifies the symbol in the URL path. ```shell curl --request GET \ --url https://api.sandbox.gemini.com/v1/riskstats/:symbol ``` -------------------------------- ### Get Account Margin - Example Response Body Source: https://docs.sandbox.gemini.com/rest/derivatives This JSON object illustrates a successful response from the 'Get Account Margin' endpoint. It provides various margin-related details such as available margin, leverage, and liquidation price. ```json { "margin_assets_value": "9800", "initial_margin": "6000", "available_margin": "3800", "margin_maintenance_limit": "5800", "leverage": "12.34567", "notional_value": "1300", "estimated_liquidation_price": "1300", "initial_margin_positions": "3500", "reserved_margin": "2500", "reserved_margin_buys": "1800", "reserved_margin_sells": "700", "buying_power": "0.19", "selling_power": "0.19" } ``` -------------------------------- ### Get Instant Quote - Example Request Body Source: https://docs.sandbox.gemini.com/rest/instant This JSON object represents a sample request body for obtaining an instant quote. It includes essential parameters such as the request path, a nonce for security, the trading symbol, the desired side (buy or sell), and the total amount to spend. ```json { "request": "/v1/instant/quote", "nonce": "", "symbol": "btcusd", "side": "buy", "totalSpend": "100" } ``` -------------------------------- ### List Symbols - Swift Source: https://docs.sandbox.gemini.com/rest/market-data This Swift code example illustrates how to get a list of all available trading symbols using the Gemini API. It utilizes URLSession to make a GET request to the /v1/symbols endpoint and prints the JSON response. ```swift import Foundation let url = URL(string: "https://api.sandbox.gemini.com/v1/symbols")! let task = URLSession.shared.dataTask(with: url) { data, response, error in if let error = error { print("Error: \(error.localizedDescription)\n") return } guard let data = data else { print("No data received\n") return } if let jsonString = String(data: data, encoding: .utf8) { print(jsonString) } } task.resume() ``` -------------------------------- ### Get Account Margin - Example Request Body Source: https://docs.sandbox.gemini.com/rest/derivatives This JSON object represents a sample request body for the 'Get Account Margin' endpoint. It specifies the API endpoint path, a nonce (timestamp), and the trading pair symbol. ```json { "request": "/v1/margin", "nonce": "", "symbol": "BTC-GUSD-PERP" } ```