Listing Product Pairs

Tradable product pairs are returned by List Products. This endpoint’s response includes all enabled products for a given portfolio, along with crucial details such as minimum/maximum order increments and order book precision. This can be used to validate order parameters, ensure compliance with product constraints, and power trading interfaces or workflows.

ProductsService productsService = PrimeServiceFactory.createProductsService(client);

ListPortfolioProductsRequest request = new ListPortfolioProductsRequest.Builder()
    .portfolioId("PORTFOLIO_ID_HERE")
    .build();

ListPortfolioProductsResponse response = productsService.listPortfolioProducts(request);

To learn more about this SDK, please visit the Prime Java SDK.

Creating a Trade

Trading via the Prime REST API is conducted through the Create Order endpoint. When an order is created, the product (for example, BTC-USD) and the portfolio ID must be specified. The portfolio ID determines which trading balance will be used for debits and credits, and can be obtained from List Portfolios or from the URL of the Prime web UI.

Any order algorithm supported in the Prime UI is also available through the Create Order API. Prime supports specifying orders in both base units (e.g., “10 ETH”) and quote units (e.g., “100,000 USD of ETH”).

OrdersService ordersService = PrimeServiceFactory.createOrdersService(client);

CreateOrderRequest request = new CreateOrderRequest.Builder()
    .portfolioId("PORTFOLIO_ID_HERE")
    .productId("ADA-USD")
    .side(OrderSide.BUY)
    .type(OrderType.MARKET)
    .baseQuantity("10.0")
    .clientOrderId(UUID.randomUUID().toString())
    .build());
CreateOrderResponse orderResponse = ordersService.createOrder(request);

To learn more about this SDK, please visit the Prime Java SDK.

An Order Preview can also be submitted, which is useful in scenarios where a preview screen is needed, or to obtain a general idea of trading conditions. This is not a hold.

Tracking an order

When an order is successfully created, the API returns an order ID. This ID can be used to check the current status or attempt to cancel the order.

There are multiple ways to track order status:

  • Orders WebSocket: Subscribe to real-time updates for order status and fills via the Orders Websocket
  • Get Order by ID: Poll the Get Order by ID endpoint to retrieve detailed information about the order, including price and quantity details.

Examples of using Get Order by ID are shown below.

OrdersService ordersService = PrimeServiceFactory.createOrdersService(client);

GetOrderByOrderIdRequest request = new GetOrderByOrderIdRequest.Builder()
    .portfolioId("PORTFOLIO_ID_HERE")
    .orderId("ORDER_ID_HERE")
    .build();

GetOrderByOrderIdResponse response = ordersService.getOrderByOrderId(request);

To learn more about this SDK, please visit the Prime Java SDK.

Order Fills

An order can be split into multiple fills. Each fill contains specific details, such as venue that executed the fill. These fills are all tied to the same order ID.

  • List Order Fills: List Order Fills retrieves fills specific to a given order ID.
  • List Portfolio Fills: List Portfolio Fills retrieves all latest fills across a portfolio, which can also be subsequently filtered

Examples of using list Order Fills are shown below.

OrdersService ordersService = PrimeServiceFactory.createOrdersService(client);

ListOrderFillsRequest request = new ListOrderFillsRequest.Builder()
    .portfolioId("PORTFOLIO_ID_HERE")
    .orderId("ORDER_ID_HERE")
.build();

ListOrderFillsResponse response = ordersService.listOrderFills(request);

To learn more about this SDK, please visit the Prime Java SDK.

Cancelling an order

If an order is still open, a cancellation may be attempted via Cancel Order. Note that a cancellation request does not guarantee a successful cancellation because the order status could change at any time (e.g., it may fill before the cancel request is processed).

OrdersService ordersService = PrimeServiceFactory.cancelOrdersService(client);

CancelOrderRequest request = new CancelOrderRequest.Builder()
    .portfolioId("PORTFOLIO_ID_HERE")
    .orderId("ORDER_ID_HERE")
.build());

CancelOrderResponse orderResponse = ordersService.cancelOrder(request);

To learn more about this SDK, please visit the Prime Java SDK.

Please note: All requests discussed above require proper authentication. For more information, visit REST API Authentication.