Skip to Content

Orders

Place and cancel orders on the matching engine. Authenticate with your API key from the web app API section.

Endpoints

MethodPathDescription
POST/api/orders/nonceRequest order nonce
POST/api/orders/Create order
POST/api/orders/cancelCancel order
POST/api/orders/cancel-allCancel all open orders

Request order nonce

POST /api/orders/nonce

Issues a one-time nonce before submitting an order (anti-replay).

Request

import axios from 'axios'; const response = await axios.post('https://api.loafmarkets.com/api/orders/nonce', undefined, { headers: { Authorization: `Bearer ${process.env.LOAF_API_KEY}` }, }); console.log(response.data);

Parameters

ParameterTypeRequiredDescription
None-NoNo parameters for this endpoint.

Response

Type: OrderNonceResponse

interface OrderNonceResponse { nonce: string; deadline: number; // Unix seconds }

Example response:

{ "nonce": "a1b2c3d4e5f6789012345678901234ab", "deadline": 1893456000 }

Errors

StatusCodeDescription
400validation_errorRequest failed schema validation.
401unauthorizedMissing or invalid authentication.
404not_foundResource not found (where applicable).
500internal_errorUnexpected server error.

Requires API key authentication.


Create order

POST /api/orders/

Submits an order for the authenticated user.

Request body

Type: OrderRequestBody (@loafmarkets/shared-types)

interface OrderRequestBody { propertyId: number; price: number; quantity: number; side: 'BUY' | 'SELL'; type: 'MARKET' | 'LIMIT'; timeInForce: 'GTC' | 'IOC' | 'FOK' | 'GTD'; deadline: number; nonce: string; }

Request

import axios from 'axios'; import type { OrderRequestBody } from '@loafmarkets/shared-types'; const body: OrderRequestBody = { propertyId: 42, price: 125.5, quantity: 10, side: 'BUY', type: 'LIMIT', timeInForce: 'GTC', deadline: 0, nonce: 'a1b2c3d4e5f6789012345678901234ab', }; const response = await axios.post('https://api.loafmarkets.com/api/orders/', body, { headers: { Authorization: `Bearer ${process.env.LOAF_API_KEY}` }, }); console.log(response.data);

For a market order, set "type": "MARKET" and "price": 0. See the Python bot template  for a higher-level SDK.

Minimum order notional is 10 USDL (price × quantity), waived only for a SELL that closes your entire position.

Parameters

ParameterTypeRequiredDescription
propertyIdnumberYes(body) Property ID (positive integer).
pricenumberYes(body) Limit price in USDL. Use 0 for market orders (MARKET_ORDER_PRICE).
quantitynumberYes(body) Order size in tokens (max 1 decimal place).
side'BUY' | 'SELL'Yes(body) Order side.
type'MARKET' | 'LIMIT'Yes(body) Order type.
timeInForce'GTC' | 'IOC' | 'FOK' | 'GTD'Yes(body) Time in force.
deadlinenumberYes(body) Unix timestamp (seconds). Use 0 unless timeInForce is GTD.
noncestringYes(body) 32-character hex nonce from POST /api/orders/nonce.

Response

Type: OrderApiResponse

interface OrderApiResponse { success: boolean; orderId: number; errorMessage?: string; }

Example response:

{ "success": true, "orderId": 9001 }

Errors

StatusCodeDescription
400validation_errorRequest failed schema validation.
401unauthorizedMissing or invalid authentication.
404not_foundResource not found (where applicable).
500internal_errorUnexpected server error.

Requires API key authentication.


Cancel order

POST /api/orders/cancel

Cancels an existing order via the matching engine.

Request body

Type: CancelOrderRequestBody (@loafmarkets/shared-types)

interface CancelOrderRequestBody { orderId: number; }

Request

import axios from 'axios'; import type { CancelOrderRequestBody } from '@loafmarkets/shared-types'; const body: CancelOrderRequestBody = { orderId: 9001, }; const response = await axios.post('https://api.loafmarkets.com/api/orders/cancel', body, { headers: { Authorization: `Bearer ${process.env.LOAF_API_KEY}` }, }); console.log(response.data);

Parameters

ParameterTypeRequiredDescription
orderIdnumberYes(body) ID of the order to cancel.

Response

Type: CancelOrderResponse

interface CancelOrderResponse { success: boolean; orderId: number; errorMessage?: string; }

Example response:

{ "success": true, "orderId": 9001 }

Errors

StatusCodeDescription
400validation_errorRequest failed schema validation.
401unauthorizedMissing or invalid authentication.
404not_foundResource not found (where applicable).
500internal_errorUnexpected server error.

Requires API key authentication.


Cancel all orders

POST /api/orders/cancel-all

Cancels every open order for the authenticated user by relaying a cancel request to the matching engine for each one.

Request

import axios from 'axios'; const response = await axios.post('https://api.loafmarkets.com/api/orders/cancel-all', undefined, { headers: { Authorization: `Bearer ${process.env.LOAF_API_KEY}` }, }); console.log(response.data);

Parameters

ParameterTypeRequiredDescription
None-NoNo parameters for this endpoint.

Response

Type: CancelAllOrdersResponse (@loafmarkets/shared-types)

interface CancelAllOrdersResponse { requestedCount: number; cancelledOrderIds: number[]; failedOrders: Array<{ orderId: number; errorMessage: string }>; }

Example response:

{ "requestedCount": 2, "cancelledOrderIds": [9001, 9002], "failedOrders": [] }

Errors

StatusCodeDescription
401unauthorizedMissing or invalid authentication.
503service_unavailableMatching engine unavailable for all cancels.
500internal_errorUnexpected server error.

Requires API key authentication. Partial success is possible: check failedOrders when cancelledOrderIds does not cover every open order.

Last updated on