OpenFX provides a robust and secure API suite engineered for high performance and reliability, enabling programmatic access to real-time market data, trade execution, and money movement functionalities. This guide will walk through the step-by-step process of deposits, quoting, trading, settlements and monitoring using OpenFX APIs.
Overview of OpenFX APIs (v1.0.0)
https://api.sandbox.openfx.com/
- OpenFX API Server
https://api.sandbox.openfx.com/v1/brokerage/{orgId}/generate_quote
- curl
- JavaScript
- Node.js
- Python
- Java
- Go
- PHP
curl -i -X POST \
'https://api.sandbox.openfx.com/v1/brokerage/{orgId}/generate_quote' \
-H 'Authorization: Bearer <YOUR_JWT_HERE>' \
-H 'Content-Type: application/json' \
-d '{
"amount": 1000,
"buy": "USDC",
"sell": "USD",
"referencedUnit": "USDC"
}'success
Unique identifier for the quote
Unique identifier of the user who generated the quote
Input amount in the referenced unit provided by the user
Calculated amount the user will receive or pay, based on the reference amount
UTC Timestamp when the quote was generated
{ "status": "success", "data": { "quote": { "id": "123e4567-e89b-12d3-a456-426614174000", "userId": "123e4567-e89b-12d3-a456-426614174001", "buy": "USD", "sell": "USDC", "referencedUnit": "USD", "referencedAmount": 1000, "quoteAmount": 999.800000007998, "createdAt": "2024-11-25T15:05:34.945Z", "expiryTimeinSeconds": 15 } } }
- OpenFX API Server
https://api.sandbox.openfx.com/v1/brokerage/{orgId}/trades
- curl
- JavaScript
- Node.js
- Python
- Java
- Go
- PHP
curl -i -X GET \
'https://api.sandbox.openfx.com/v1/brokerage/{orgId}/trades?page=1&limit=10' \
-H 'Authorization: Bearer <YOUR_JWT_HERE>'success
Unique identifier for the trade
Currency pair involved in the trade, in the format QUOTE/BASE
Final calculated amount of the counter currency
UTC Timestamp when the trade was created
UTC Timestamp when the trade was last updated
{ "status": "success", "data": [ { "id": "b6e537a3-e673-4cd4-832a-cb67b66eb425", "tradingPair": "USDC/USD", "referencedUnit": "USDC", "tradeDirection": "BUY", "amount": 3333, "computedAmount": 3359.4960168, "createdAtUtc": "2025-01-21T17:36:33.310Z", "updatedAtUtc": "2025-01-21T17:36:33.310Z", "orderType": "MARKET", "status": "EXECUTED", "source": "GUI" }, { "id": "93f7189a-0c14-4bf4-8004-1266bd14fbbf", "tradingPair": "USDC/USD", "referencedUnit": "USD", "tradeDirection": "SELL", "amount": 30507.8873260065, "computedAmount": 18914.8854134015, "createdAtUtc": "2025-01-16T04:52:18.167Z", "updatedAtUtc": "2025-01-16T04:52:18.167Z", "orderType": "MARKET", "status": "EXECUTED", "source": "API" } ], "meta": { "pagination": { "total": 2, "start": 1, "end": 2, "page": 1, "limit": 2 } } }
- OpenFX API Server
https://api.sandbox.openfx.com/v1/brokerage/{orgId}/trade/{id}
- curl
- JavaScript
- Node.js
- Python
- Java
- Go
- PHP
curl -i -X GET \
'https://api.sandbox.openfx.com/v1/brokerage/{orgId}/trade/{id}' \
-H 'Authorization: Bearer <YOUR_JWT_HERE>'{ "status": "success", "data": { "id": "b6e537a3-e673-4cd4-832a-cb67b66eb425", "tradingPair": "USDC/USD", "referencedUnit": "USDC", "tradeDirection": "BUY", "amount": 3333, "computedAmount": 3359.4960168, "createdAtUtc": "2025-01-21T17:36:33.310Z", "updatedAtUtc": "2025-01-21T17:36:33.310Z", "orderType": "MARKET", "status": "EXECUTED", "source": "GUI" } }
- OpenFX API Server
https://api.sandbox.openfx.com/v1/brokerage/{orgId}/trade
- curl
- JavaScript
- Node.js
- Python
- Java
- Go
- PHP
curl -i -X POST \
'https://api.sandbox.openfx.com/v1/brokerage/{orgId}/trade' \
-H 'Authorization: Bearer <YOUR_JWT_HERE>' \
-H 'Content-Type: application/json' \
-d '{
"quoteId": "d8bc9618-2830-1822-9ae2-414aaf2b2de3"
}'success
Updated user balances after the trade, keyed by currency symbol
Unique identifier of the executed trade
Currency symbol used to specify the original trade input amount
The amount the trade was based on, in the referenced currency
UTC Timestamp when the trade was executed
{ "status": "success", "data": { "balances": { "USD": -596064.969940321, "USDC": -9893214.59296976, "USDT": 8654884.42360652 }, "trade": { "id": "2c011d8b-1822-4d1c-9b16-414aaf2b2de4", "buy": "USD", "sell": "USDC", "referencedUnit": "USD", "referenceAmount": 100, "amount": 101, "status": "EXECUTED", "transactedAt": "2025-02-10T07:40:21.300Z", "quoteId": "d8bc9618-2830-1822-9ae2-414aaf2b2de3" }, "userCreditLimit": 10000000, "userCreditUsed": 8844000.51844473 } }