Orders
Get Order Preview
REST API
- Introduction
- Requests
- Rate Limits
- Authentication
- Pagination
- CLI Setup
- Activities
- Address Book
- Allocations
- Assets
- Balances
- Commission
- Financing
- Futures
- Invoices
- Onchain Address Book
- Onchain Address Groups
- Orders
- Payment Methods
- Portfolios
- Positions
- Products
- Staking
- Transactions
- Users
- Wallets
FIX API
Orders
Get Order Preview
Retrieve an order preview.
POST
/
v1
/
portfolios
/
{portfolio_id}
/
order_preview
Copy
Ask AI
curl --request POST \
--url https://api.prime.coinbase.com/v1/portfolios/{portfolio_id}/order_preview \
--header 'Content-Type: application/json' \
--data '{
"product_id": "<string>",
"side": "UNKNOWN_ORDER_SIDE",
"type": "UNKNOWN_ORDER_TYPE",
"base_quantity": "<string>",
"quote_value": "<string>",
"limit_price": "<string>",
"start_time": "2023-11-07T05:31:56Z",
"expiry_time": "2023-11-07T05:31:56Z",
"time_in_force": "UNKNOWN_TIME_IN_FORCE",
"is_raise_exact": true,
"historical_pov": "<string>",
"stop_price": "<string>",
"settl_currency": "<string>"
}'
Copy
Ask AI
{
"portfolio_id": "3e1fe27e-26fe-46d8-b118-c752a2ae6b47",
"product_id": "BTC-USD",
"side": "UNKNOWN_ORDER_SIDE",
"type": "UNKNOWN_ORDER_TYPE",
"base_quantity": "50",
"quote_value": "100",
"limit_price": "50.12",
"start_time": "2021-05-31T09:59:59.000Z",
"expiry_time": "2021-05-31T10:59:59.000Z",
"time_in_force": "UNKNOWN_TIME_IN_FORCE",
"commission": "4.99",
"slippage": "0.05",
"best_bid": "10",
"best_ask": "10",
"average_filled_price": "50.19",
"order_total": "123",
"historical_pov": "0.5"
}
Use the Prime SDK or CLI to test this endpoint by following the quickstart guide and running with the following examples
Copy
Ask AI
OrdersService ordersService = PrimeServiceFactory.createOrdersService(client);
GetOrderPreviewRequest request = new GetOrderPreviewRequest.Builder()
.portfolioId("PORTFOLIO_ID_HERE")
.productId("ADA-USD")
.side(OrderSide.BUY)
.type(OrderType.MARKET)
.baseQuantity("10.0")
.build();
GetOrderPreviewResponse orderResponse = ordersService.getOrderPreview(request);
For more information, please visit the Prime Java SDK.
Copy
Ask AI
OrdersService ordersService = PrimeServiceFactory.createOrdersService(client);
GetOrderPreviewRequest request = new GetOrderPreviewRequest.Builder()
.portfolioId("PORTFOLIO_ID_HERE")
.productId("ADA-USD")
.side(OrderSide.BUY)
.type(OrderType.MARKET)
.baseQuantity("10.0")
.build();
GetOrderPreviewResponse orderResponse = ordersService.getOrderPreview(request);
For more information, please visit the Prime Java SDK.
Copy
Ask AI
var ordersService = new OrdersService(client);
var request = new GetOrderPreviewRequest("PORTFOLIO_ID_HERE")
{
BaseQuantity = "5",
LimitPrice = "0.32",
Side = OrderSide.BUY,
ProductId = "ADA-USD",
Type = OrderType.LIMIT,
ExpiryTime = new DateTimeOffset(DateTime.UtcNow.AddMinutes(5)).ToString("o"),
};
var getOrderPreviewResponse = orderService.GetOrderPreview(request);
For more information, please visit the Prime .NET SDK.
Copy
Ask AI
ordersService := orders.NewOrdersService(client)
request := &orders.GetOrderPreviewRequest{
Order: &model.Order{
PortfolioId: "PORTFOLIO_ID_HERE",
BaseQuantity: "5",
LimitPrice: "0.32",
Side: "BUY",
ProductId: "ADA-USD",
Type: "LIMIT",
ExpiryTime: time.Now().UTC().Add(5 * time.Minute).Format(time.RFC3339),
},
}
response, err := ordersService.GetOrderPreviewRequest(context.Background(), request)
For more information, please visit the Prime Go SDK.
Copy
Ask AI
prime_client = PrimeClient(credentials)
request = GetOrderPreviewRequest(
portfolio_id="PORTFOLIO_ID_HERE",
base_quantity="5",
limit_price="0.32",
side="BUY",
product_id="ADA-USD",
type="LIMIT",
expiry_time=(datetime.datetime.now() + datetime.timedelta(minutes=5)).isoformat() + "Z",
)
response = prime_client.get_order_preview(request)
For more information, please visit the Prime Python SDK.
Copy
Ask AI
primectl create-order-preview --help
For more information, please visit the Prime CLI.
Copy
Ask AI
const ordersService = new OrdersService(client);
const today = new Date();
ordersService.createOrderPreview({
portfolioId: "PORTFOLIO_ID_HERE",
baseQuantity: "5",
limitPrice: "0.32",
side: OrderSide.BUY,
productId: "ADA-USD",
type: OrderType.LIMIT,
expiryTime: date.setDate(date.getDate() + 1),
}).then(async (response) => {
console.log('Order Preview: ', response);
})
For more information, please visit the Prime TS SDK.
Path Parameters
The ID of the portfolio that owns the order
Body
application/json
Response
200
application/json
A successful response.
The response is of type object
.
Was this page helpful?
Copy
Ask AI
curl --request POST \
--url https://api.prime.coinbase.com/v1/portfolios/{portfolio_id}/order_preview \
--header 'Content-Type: application/json' \
--data '{
"product_id": "<string>",
"side": "UNKNOWN_ORDER_SIDE",
"type": "UNKNOWN_ORDER_TYPE",
"base_quantity": "<string>",
"quote_value": "<string>",
"limit_price": "<string>",
"start_time": "2023-11-07T05:31:56Z",
"expiry_time": "2023-11-07T05:31:56Z",
"time_in_force": "UNKNOWN_TIME_IN_FORCE",
"is_raise_exact": true,
"historical_pov": "<string>",
"stop_price": "<string>",
"settl_currency": "<string>"
}'
Copy
Ask AI
{
"portfolio_id": "3e1fe27e-26fe-46d8-b118-c752a2ae6b47",
"product_id": "BTC-USD",
"side": "UNKNOWN_ORDER_SIDE",
"type": "UNKNOWN_ORDER_TYPE",
"base_quantity": "50",
"quote_value": "100",
"limit_price": "50.12",
"start_time": "2021-05-31T09:59:59.000Z",
"expiry_time": "2021-05-31T10:59:59.000Z",
"time_in_force": "UNKNOWN_TIME_IN_FORCE",
"commission": "4.99",
"slippage": "0.05",
"best_bid": "10",
"best_ask": "10",
"average_filled_price": "50.19",
"order_total": "123",
"historical_pov": "0.5"
}
Assistant
Responses are generated using AI and may contain mistakes.