Update Polymarket documentation (2026-02-19)
- Added new documentation URLs from llms.txt index - Updated TARGET.md with 244 total documentation pages - Scraped new pages for trading, concepts, and API reference sections - Updated changelog and new index pages
This commit is contained in:
@@ -4,13 +4,11 @@
|
||||
|
||||
# L2 Methods
|
||||
|
||||
> These methods require user API credentials (L2 headers). Use these for placing trades and managing user's positions.
|
||||
|
||||
***
|
||||
> These methods require user API credentials (L2 headers). Use these for placing trades and managing your positions.
|
||||
|
||||
## Client Initialization
|
||||
|
||||
L2 methods require the client to initialize with the signer, signatureType, user API credentials, and funder.
|
||||
L2 methods require the client to initialize with a signer, signature type, API credentials, and funder address.
|
||||
|
||||
<Tabs>
|
||||
<Tab title="TypeScript">
|
||||
@@ -18,7 +16,7 @@ L2 methods require the client to initialize with the signer, signatureType, user
|
||||
import { ClobClient } from "@polymarket/clob-client";
|
||||
import { Wallet } from "ethers";
|
||||
|
||||
const signer = new Wallet(process.env.PRIVATE_KEY)
|
||||
const signer = new Wallet(process.env.PRIVATE_KEY);
|
||||
|
||||
const apiCreds = {
|
||||
apiKey: process.env.API_KEY,
|
||||
@@ -31,11 +29,11 @@ L2 methods require the client to initialize with the signer, signatureType, user
|
||||
137,
|
||||
signer,
|
||||
apiCreds,
|
||||
2, // Deployed Safe proxy wallet
|
||||
process.env.FUNDER_ADDRESS // Address of deployed Safe proxy wallet
|
||||
2, // GNOSIS_SAFE
|
||||
process.env.FUNDER_ADDRESS
|
||||
);
|
||||
|
||||
// Ready to send authenticated requests to the CLOB API!
|
||||
// Ready to send authenticated requests
|
||||
const order = await client.postOrder(signedOrder);
|
||||
```
|
||||
</Tab>
|
||||
@@ -57,12 +55,12 @@ L2 methods require the client to initialize with the signer, signatureType, user
|
||||
chain_id=137,
|
||||
key=os.getenv("PRIVATE_KEY"),
|
||||
creds=api_creds,
|
||||
signature_type=2, # Deployed Safe proxy wallet
|
||||
funder=os.getenv("FUNDER_ADDRESS") # Address of deployed Safe proxy wallet
|
||||
signature_type=2, # GNOSIS_SAFE
|
||||
funder=os.getenv("FUNDER_ADDRESS")
|
||||
)
|
||||
|
||||
# Ready to send authenticated requests to the CLOB API!
|
||||
order = await client.post_order(signed_order)
|
||||
# Ready to send authenticated requests
|
||||
order = client.post_order(signed_order)
|
||||
```
|
||||
</Tab>
|
||||
</Tabs>
|
||||
@@ -75,8 +73,7 @@ L2 methods require the client to initialize with the signer, signatureType, user
|
||||
|
||||
### createAndPostOrder()
|
||||
|
||||
A convenience method that creates, prompts signature, and posts an order in a single call.
|
||||
Use when you want to buy/sell at a specific price and can wait.
|
||||
Convenience method that creates, signs, and posts a limit order in a single call. Use when you want to buy or sell at a specific price.
|
||||
|
||||
```typescript Signature theme={null}
|
||||
async createAndPostOrder(
|
||||
@@ -86,44 +83,83 @@ async createAndPostOrder(
|
||||
): Promise<OrderResponse>
|
||||
```
|
||||
|
||||
```typescript Params theme={null}
|
||||
interface UserOrder {
|
||||
tokenID: string;
|
||||
price: number;
|
||||
size: number;
|
||||
side: Side;
|
||||
feeRateBps?: number;
|
||||
nonce?: number;
|
||||
expiration?: number;
|
||||
taker?: string;
|
||||
}
|
||||
**Params**
|
||||
|
||||
type CreateOrderOptions = {
|
||||
tickSize: TickSize;
|
||||
negRisk?: boolean;
|
||||
}
|
||||
<ResponseField name="tokenID" type="string">
|
||||
The token ID of the outcome to trade.
|
||||
</ResponseField>
|
||||
|
||||
type TickSize = "0.1" | "0.01" | "0.001" | "0.0001";
|
||||
```
|
||||
<ResponseField name="price" type="number">
|
||||
The limit price for the order.
|
||||
</ResponseField>
|
||||
|
||||
```typescript Response theme={null}
|
||||
interface OrderResponse {
|
||||
success: boolean;
|
||||
errorMsg: string;
|
||||
orderID: string;
|
||||
transactionsHashes: string[];
|
||||
status: string;
|
||||
takingAmount: string;
|
||||
makingAmount: string;
|
||||
}
|
||||
```
|
||||
<ResponseField name="size" type="number">
|
||||
The size of the order.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="side" type="Side">
|
||||
The side of the order (buy or sell).
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="feeRateBps" type="number">
|
||||
Optional fee rate in basis points.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="nonce" type="number">
|
||||
Optional nonce for the order.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="expiration" type="number">
|
||||
Optional expiration timestamp for the order.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="taker" type="string">
|
||||
Optional taker address.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="tickSize" type="TickSize">
|
||||
Tick size for the order. One of `"0.1"`, `"0.01"`, `"0.001"`, `"0.0001"`.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="negRisk" type="boolean">
|
||||
Optional. Whether the market uses negative risk.
|
||||
</ResponseField>
|
||||
|
||||
**Response**
|
||||
|
||||
<ResponseField name="success" type="boolean">
|
||||
Whether the order was successfully placed.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="errorMsg" type="string">
|
||||
Error message if the order was not successful.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="orderID" type="string">
|
||||
The ID of the placed order.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="transactionsHashes" type="string[]">
|
||||
Array of transaction hashes associated with the order.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="status" type="string">
|
||||
The current status of the order.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="takingAmount" type="string">
|
||||
The amount being taken in the order.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="makingAmount" type="string">
|
||||
The amount being made in the order.
|
||||
</ResponseField>
|
||||
|
||||
***
|
||||
|
||||
### createAndPostMarketOrder()
|
||||
|
||||
A convenience method that creates, prompts signature, and posts an order in a single call.
|
||||
Use when you want to buy/sell right now at whatever the market price is.
|
||||
Convenience method that creates, signs, and posts a market order in a single call. Use when you want to buy or sell at the current market price.
|
||||
|
||||
```typescript Signature theme={null}
|
||||
async createAndPostMarketOrder(
|
||||
@@ -133,103 +169,109 @@ async createAndPostMarketOrder(
|
||||
): Promise<OrderResponse>
|
||||
```
|
||||
|
||||
```typescript Params theme={null}
|
||||
interface UserMarketOrder {
|
||||
tokenID: string;
|
||||
amount: number;
|
||||
side: Side;
|
||||
price?: number;
|
||||
feeRateBps?: number;
|
||||
nonce?: number;
|
||||
taker?: string;
|
||||
orderType?: OrderType.FOK | OrderType.FAK;
|
||||
}
|
||||
**Params**
|
||||
|
||||
type CreateOrderOptions = {
|
||||
tickSize: TickSize;
|
||||
negRisk?: boolean;
|
||||
}
|
||||
<ResponseField name="tokenID" type="string">
|
||||
The token ID of the outcome to trade.
|
||||
</ResponseField>
|
||||
|
||||
type TickSize = "0.1" | "0.01" | "0.001" | "0.0001";
|
||||
```
|
||||
<ResponseField name="amount" type="number">
|
||||
The amount for the market order.
|
||||
</ResponseField>
|
||||
|
||||
```typescript Response theme={null}
|
||||
interface OrderResponse {
|
||||
success: boolean;
|
||||
errorMsg: string;
|
||||
orderID: string;
|
||||
transactionsHashes: string[];
|
||||
status: string;
|
||||
takingAmount: string;
|
||||
makingAmount: string;
|
||||
}
|
||||
```
|
||||
<ResponseField name="side" type="Side">
|
||||
The side of the order (buy or sell).
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="price" type="number">
|
||||
Optional price hint for the market order.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="feeRateBps" type="number">
|
||||
Optional fee rate in basis points.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="nonce" type="number">
|
||||
Optional nonce for the order.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="taker" type="string">
|
||||
Optional taker address.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="orderType" type="OrderType.FOK | OrderType.FAK">
|
||||
Optional order type override. Defaults to FOK.
|
||||
</ResponseField>
|
||||
|
||||
**Response**
|
||||
|
||||
<ResponseField name="success" type="boolean">
|
||||
Whether the order was successfully placed.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="errorMsg" type="string">
|
||||
Error message if the order was not successful.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="orderID" type="string">
|
||||
The ID of the placed order.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="transactionsHashes" type="string[]">
|
||||
Array of transaction hashes associated with the order.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="status" type="string">
|
||||
The current status of the order.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="takingAmount" type="string">
|
||||
The amount being taken in the order.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="makingAmount" type="string">
|
||||
The amount being made in the order.
|
||||
</ResponseField>
|
||||
|
||||
***
|
||||
|
||||
### postOrder()
|
||||
|
||||
Posts a pre-signed and created order to the CLOB.
|
||||
Posts a pre-signed order to the CLOB. Use with [`createOrder()`](/trading/clients/l1#createorder) or [`createMarketOrder()`](/trading/clients/l1#createmarketorder) from L1 methods.
|
||||
|
||||
```typescript Signature theme={null}
|
||||
async postOrder(
|
||||
order: SignedOrder,
|
||||
orderType?: OrderType, // Defaults to GTC
|
||||
postOnly?: boolean, // Defaults to false
|
||||
postOnly?: boolean, // Defaults to false
|
||||
): Promise<OrderResponse>
|
||||
```
|
||||
|
||||
```typescript Params theme={null}
|
||||
order: SignedOrder // Pre-signed order from createOrder() or createMarketOrder()
|
||||
orderType?: OrderType // Optional, defaults to GTC
|
||||
postOnly?: boolean // Optional, defaults to false
|
||||
```
|
||||
|
||||
```typescript Response theme={null}
|
||||
interface OrderResponse {
|
||||
success: boolean;
|
||||
errorMsg: string;
|
||||
orderID: string;
|
||||
transactionsHashes: string[];
|
||||
status: string;
|
||||
takingAmount: string;
|
||||
makingAmount: string;
|
||||
}
|
||||
```
|
||||
|
||||
***
|
||||
|
||||
### postOrders()
|
||||
|
||||
Posts up to 15 pre-signed and created orders in a single batch.
|
||||
Posts up to 15 pre-signed orders in a single batch.
|
||||
|
||||
```typescript theme={null}
|
||||
```typescript Signature theme={null}
|
||||
async postOrders(
|
||||
args: PostOrdersArgs[],
|
||||
): Promise<OrderResponse[]>
|
||||
```
|
||||
|
||||
```typescript Params theme={null}
|
||||
interface PostOrdersArgs {
|
||||
order: SignedOrder;
|
||||
orderType: OrderType;
|
||||
postOnly?: boolean; // Defaults to false
|
||||
}
|
||||
```
|
||||
**Params**
|
||||
|
||||
```typescript Response theme={null}
|
||||
OrderResponse[] // Array of OrderResponse objects
|
||||
<ResponseField name="order" type="SignedOrder">
|
||||
The pre-signed order to post.
|
||||
</ResponseField>
|
||||
|
||||
interface OrderResponse {
|
||||
success: boolean;
|
||||
errorMsg: string;
|
||||
orderID: string;
|
||||
transactionsHashes: string[];
|
||||
status: string;
|
||||
takingAmount: string;
|
||||
makingAmount: string;
|
||||
}
|
||||
```
|
||||
<ResponseField name="orderType" type="OrderType">
|
||||
The order type (e.g. GTC, FOK, FAK).
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="postOnly" type="boolean">
|
||||
Optional. Whether to post the order as post-only. Defaults to false.
|
||||
</ResponseField>
|
||||
|
||||
***
|
||||
|
||||
@@ -241,12 +283,15 @@ Cancels a single open order.
|
||||
async cancelOrder(orderID: string): Promise<CancelOrdersResponse>
|
||||
```
|
||||
|
||||
```typescript Response theme={null}
|
||||
interface CancelOrdersResponse {
|
||||
canceled: string[];
|
||||
not_canceled: Record<string, any>;
|
||||
}
|
||||
```
|
||||
**Response**
|
||||
|
||||
<ResponseField name="canceled" type="string[]">
|
||||
Array of order IDs that were successfully canceled.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="not_canceled" type="Record<string, any>">
|
||||
Map of order IDs to reasons why they could not be canceled.
|
||||
</ResponseField>
|
||||
|
||||
***
|
||||
|
||||
@@ -258,17 +303,6 @@ Cancels multiple orders in a single batch.
|
||||
async cancelOrders(orderIDs: string[]): Promise<CancelOrdersResponse>
|
||||
```
|
||||
|
||||
```typescript Params theme={null}
|
||||
orderIDs: string[];
|
||||
```
|
||||
|
||||
```typescript Response theme={null}
|
||||
interface CancelOrdersResponse {
|
||||
canceled: string[];
|
||||
not_canceled: Record<string, any>;
|
||||
}
|
||||
```
|
||||
|
||||
***
|
||||
|
||||
### cancelAll()
|
||||
@@ -276,14 +310,7 @@ interface CancelOrdersResponse {
|
||||
Cancels all open orders.
|
||||
|
||||
```typescript Signature theme={null}
|
||||
async cancelAll(): Promise<CancelResponse>
|
||||
```
|
||||
|
||||
```typescript Response theme={null}
|
||||
interface CancelOrdersResponse {
|
||||
canceled: string[];
|
||||
not_canceled: Record<string, any>;
|
||||
}
|
||||
async cancelAll(): Promise<CancelOrdersResponse>
|
||||
```
|
||||
|
||||
***
|
||||
@@ -298,19 +325,15 @@ async cancelMarketOrders(
|
||||
): Promise<CancelOrdersResponse>
|
||||
```
|
||||
|
||||
```typescript Parameters theme={null}
|
||||
interface OrderMarketCancelParams {
|
||||
market?: string;
|
||||
asset_id?: string;
|
||||
}
|
||||
```
|
||||
**Params**
|
||||
|
||||
```typescript Response theme={null}
|
||||
interface CancelOrdersResponse {
|
||||
canceled: string[];
|
||||
not_canceled: Record<string, any>;
|
||||
}
|
||||
```
|
||||
<ResponseField name="market" type="string">
|
||||
Optional. The market condition ID to cancel orders for.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="asset_id" type="string">
|
||||
Optional. The token ID to cancel orders for.
|
||||
</ResponseField>
|
||||
|
||||
***
|
||||
|
||||
@@ -320,31 +343,73 @@ interface CancelOrdersResponse {
|
||||
|
||||
### getOrder()
|
||||
|
||||
Get details for a specific order.
|
||||
Get details for a specific order by ID.
|
||||
|
||||
```typescript Signature theme={null}
|
||||
async getOrder(orderID: string): Promise<OpenOrder>
|
||||
```
|
||||
|
||||
```typescript Response theme={null}
|
||||
interface OpenOrder {
|
||||
id: string;
|
||||
status: string;
|
||||
owner: string;
|
||||
maker_address: string;
|
||||
market: string;
|
||||
asset_id: string;
|
||||
side: string;
|
||||
original_size: string;
|
||||
size_matched: string;
|
||||
price: string;
|
||||
associate_trades: string[];
|
||||
outcome: string;
|
||||
created_at: number;
|
||||
expiration: string;
|
||||
order_type: string;
|
||||
}
|
||||
```
|
||||
**Response**
|
||||
|
||||
<ResponseField name="id" type="string">
|
||||
The unique order ID.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="status" type="string">
|
||||
The current status of the order.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="owner" type="string">
|
||||
The API key of the order owner.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="maker_address" type="string">
|
||||
The on-chain address of the order maker.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="market" type="string">
|
||||
The market condition ID the order belongs to.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="asset_id" type="string">
|
||||
The token ID the order is for.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="side" type="string">
|
||||
The side of the order (BUY or SELL).
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="original_size" type="string">
|
||||
The original size of the order when it was placed.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="size_matched" type="string">
|
||||
The amount of the order that has been matched so far.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="price" type="string">
|
||||
The limit price of the order.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="associate_trades" type="string[]">
|
||||
Array of trade IDs associated with this order.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="outcome" type="string">
|
||||
The outcome label for the order's token.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="created_at" type="number">
|
||||
Unix timestamp of when the order was created.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="expiration" type="string">
|
||||
The expiration time of the order.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="order_type" type="string">
|
||||
The order type (e.g. GTC, FOK, FAK, GTD).
|
||||
</ResponseField>
|
||||
|
||||
***
|
||||
|
||||
@@ -356,40 +421,22 @@ Get all your open orders.
|
||||
async getOpenOrders(
|
||||
params?: OpenOrderParams,
|
||||
only_first_page?: boolean,
|
||||
): Promise<OpenOrdersResponse>
|
||||
): Promise<OpenOrder[]>
|
||||
```
|
||||
|
||||
```typescript Params theme={null}
|
||||
interface OpenOrderParams {
|
||||
id?: string; // Order ID
|
||||
market?: string; // Market condition ID
|
||||
asset_id?: string; // Token ID
|
||||
}
|
||||
**Params**
|
||||
|
||||
only_first_page?: boolean // Defaults to false
|
||||
```
|
||||
<ResponseField name="id" type="string">
|
||||
Optional. Filter by order ID.
|
||||
</ResponseField>
|
||||
|
||||
```typescript Response theme={null}
|
||||
type OpenOrdersResponse = OpenOrder[];
|
||||
<ResponseField name="market" type="string">
|
||||
Optional. Filter by market condition ID.
|
||||
</ResponseField>
|
||||
|
||||
interface OpenOrder {
|
||||
id: string;
|
||||
status: string;
|
||||
owner: string;
|
||||
maker_address: string;
|
||||
market: string;
|
||||
asset_id: string;
|
||||
side: string;
|
||||
original_size: string;
|
||||
size_matched: string;
|
||||
price: string;
|
||||
associate_trades: string[];
|
||||
outcome: string;
|
||||
created_at: number;
|
||||
expiration: string;
|
||||
order_type: string;
|
||||
}
|
||||
```
|
||||
<ResponseField name="asset_id" type="string">
|
||||
Optional. Filter by token ID.
|
||||
</ResponseField>
|
||||
|
||||
***
|
||||
|
||||
@@ -404,53 +451,141 @@ async getTrades(
|
||||
): Promise<Trade[]>
|
||||
```
|
||||
|
||||
```typescript Params theme={null}
|
||||
interface TradeParams {
|
||||
id?: string;
|
||||
maker_address?: string;
|
||||
market?: string;
|
||||
asset_id?: string;
|
||||
before?: string;
|
||||
after?: string;
|
||||
}
|
||||
**Params**
|
||||
|
||||
only_first_page?: boolean // Defaults to false
|
||||
```
|
||||
<ResponseField name="id" type="string">
|
||||
Optional. Filter by trade ID.
|
||||
</ResponseField>
|
||||
|
||||
```typescript Response theme={null}
|
||||
interface Trade {
|
||||
id: string;
|
||||
taker_order_id: string;
|
||||
market: string;
|
||||
asset_id: string;
|
||||
side: Side;
|
||||
size: string;
|
||||
fee_rate_bps: string;
|
||||
price: string;
|
||||
status: string;
|
||||
match_time: string;
|
||||
last_update: string;
|
||||
outcome: string;
|
||||
bucket_index: number;
|
||||
owner: string;
|
||||
maker_address: string;
|
||||
maker_orders: MakerOrder[];
|
||||
transaction_hash: string;
|
||||
trader_side: "TAKER" | "MAKER";
|
||||
}
|
||||
<ResponseField name="maker_address" type="string">
|
||||
Optional. Filter by maker address.
|
||||
</ResponseField>
|
||||
|
||||
interface MakerOrder {
|
||||
order_id: string;
|
||||
owner: string;
|
||||
maker_address: string;
|
||||
matched_amount: string;
|
||||
price: string;
|
||||
fee_rate_bps: string;
|
||||
asset_id: string;
|
||||
outcome: string;
|
||||
side: Side;
|
||||
}
|
||||
```
|
||||
<ResponseField name="market" type="string">
|
||||
Optional. Filter by market condition ID.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="asset_id" type="string">
|
||||
Optional. Filter by token ID.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="before" type="string">
|
||||
Optional. Return trades before this timestamp.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="after" type="string">
|
||||
Optional. Return trades after this timestamp.
|
||||
</ResponseField>
|
||||
|
||||
**Response**
|
||||
|
||||
<ResponseField name="id" type="string">
|
||||
The unique trade ID.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="taker_order_id" type="string">
|
||||
The order ID of the taker side.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="market" type="string">
|
||||
The market condition ID for the trade.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="asset_id" type="string">
|
||||
The token ID for the trade.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="side" type="Side">
|
||||
The side of the trade (BUY or SELL).
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="size" type="string">
|
||||
The size of the trade.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="fee_rate_bps" type="string">
|
||||
The fee rate in basis points.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="price" type="string">
|
||||
The price at which the trade was matched.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="status" type="string">
|
||||
The current status of the trade.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="match_time" type="string">
|
||||
The time at which the trade was matched.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="last_update" type="string">
|
||||
The time of the last update to this trade.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="outcome" type="string">
|
||||
The outcome label for the traded token.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="bucket_index" type="number">
|
||||
The bucket index for the trade.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="owner" type="string">
|
||||
The API key of the trade owner.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="maker_address" type="string">
|
||||
The on-chain address of the maker.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="maker_orders" type="MakerOrder[]">
|
||||
Array of maker order objects that participated in this trade. Each `MakerOrder` contains the following fields:
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="maker_orders[].order_id" type="string">
|
||||
The maker order ID.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="maker_orders[].owner" type="string">
|
||||
The API key of the maker order owner.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="maker_orders[].maker_address" type="string">
|
||||
The on-chain address of the maker order maker.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="maker_orders[].matched_amount" type="string">
|
||||
The amount matched for this maker order.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="maker_orders[].price" type="string">
|
||||
The price of the maker order.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="maker_orders[].fee_rate_bps" type="string">
|
||||
The fee rate in basis points for the maker order.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="maker_orders[].asset_id" type="string">
|
||||
The token ID for the maker order.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="maker_orders[].outcome" type="string">
|
||||
The outcome label for the maker order's token.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="maker_orders[].side" type="Side">
|
||||
The side of the maker order (BUY or SELL).
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="transaction_hash" type="string">
|
||||
The on-chain transaction hash for the trade.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="trader_side" type=""TAKER" | "MAKER"">
|
||||
Whether the authenticated user is the taker or a maker in this trade.
|
||||
</ResponseField>
|
||||
|
||||
***
|
||||
|
||||
@@ -464,24 +599,19 @@ async getTradesPaginated(
|
||||
): Promise<TradesPaginatedResponse>
|
||||
```
|
||||
|
||||
```typescript Params theme={null}
|
||||
interface TradeParams {
|
||||
id?: string;
|
||||
maker_address?: string;
|
||||
market?: string;
|
||||
asset_id?: string;
|
||||
before?: string;
|
||||
after?: string;
|
||||
}
|
||||
```
|
||||
**Response**
|
||||
|
||||
```typescript Response theme={null}
|
||||
interface TradesPaginatedResponse {
|
||||
trades: Trade[];
|
||||
limit: number;
|
||||
count: number;
|
||||
}
|
||||
```
|
||||
<ResponseField name="trades" type="Trade[]">
|
||||
Array of trade objects for the current page.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="limit" type="number">
|
||||
The maximum number of trades returned per page.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="count" type="number">
|
||||
The total number of trades matching the query.
|
||||
</ResponseField>
|
||||
|
||||
***
|
||||
|
||||
@@ -499,24 +629,25 @@ async getBalanceAllowance(
|
||||
): Promise<BalanceAllowanceResponse>
|
||||
```
|
||||
|
||||
```typescript Params theme={null}
|
||||
interface BalanceAllowanceParams {
|
||||
asset_type: AssetType;
|
||||
token_id?: string;
|
||||
}
|
||||
**Params**
|
||||
|
||||
enum AssetType {
|
||||
COLLATERAL = "COLLATERAL",
|
||||
CONDITIONAL = "CONDITIONAL",
|
||||
}
|
||||
```
|
||||
<ResponseField name="asset_type" type="AssetType">
|
||||
The type of asset to query. One of `"COLLATERAL"` or `"CONDITIONAL"`.
|
||||
</ResponseField>
|
||||
|
||||
```typescript Response theme={null}
|
||||
interface BalanceAllowanceResponse {
|
||||
balance: string;
|
||||
allowance: string;
|
||||
}
|
||||
```
|
||||
<ResponseField name="token_id" type="string">
|
||||
Optional. The token ID to query (required when `asset_type` is `CONDITIONAL`).
|
||||
</ResponseField>
|
||||
|
||||
**Response**
|
||||
|
||||
<ResponseField name="balance" type="string">
|
||||
The current balance for the specified asset.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="allowance" type="string">
|
||||
The current allowance for the specified asset.
|
||||
</ResponseField>
|
||||
|
||||
***
|
||||
|
||||
@@ -530,21 +661,11 @@ async updateBalanceAllowance(
|
||||
): Promise<void>
|
||||
```
|
||||
|
||||
```typescript Params theme={null}
|
||||
interface BalanceAllowanceParams {
|
||||
asset_type: AssetType;
|
||||
token_id?: string;
|
||||
}
|
||||
|
||||
enum AssetType {
|
||||
COLLATERAL = "COLLATERAL",
|
||||
CONDITIONAL = "CONDITIONAL",
|
||||
}
|
||||
```
|
||||
|
||||
***
|
||||
|
||||
## API Key Management (L2)
|
||||
## API Key Management
|
||||
|
||||
***
|
||||
|
||||
### getApiKeys()
|
||||
|
||||
@@ -554,17 +675,11 @@ Get all API keys associated with your account.
|
||||
async getApiKeys(): Promise<ApiKeysResponse>
|
||||
```
|
||||
|
||||
```typescript Response theme={null}
|
||||
interface ApiKeysResponse {
|
||||
apiKeys: ApiKeyCreds[];
|
||||
}
|
||||
**Response**
|
||||
|
||||
interface ApiKeyCreds {
|
||||
key: string;
|
||||
secret: string;
|
||||
passphrase: string;
|
||||
}
|
||||
```
|
||||
<ResponseField name="apiKeys" type="ApiKeyCreds[]">
|
||||
Array of API key credential objects associated with the account.
|
||||
</ResponseField>
|
||||
|
||||
***
|
||||
|
||||
@@ -572,9 +687,7 @@ interface ApiKeyCreds {
|
||||
|
||||
Deletes (revokes) the currently authenticated API key.
|
||||
|
||||
**TypeScript Signature:**
|
||||
|
||||
```typescript theme={null}
|
||||
```typescript Signature theme={null}
|
||||
async deleteApiKey(): Promise<any>
|
||||
```
|
||||
|
||||
@@ -586,30 +699,39 @@ async deleteApiKey(): Promise<any>
|
||||
|
||||
### getNotifications()
|
||||
|
||||
Retrieves all event notifications for the L2 authenticated user.
|
||||
Records are removed automatically after 48 hours or if manually removed via dropNotifications().
|
||||
Retrieves all event notifications for the authenticated user. Records are automatically removed after 48 hours.
|
||||
|
||||
```typescript Signature theme={null}
|
||||
public async getNotifications(): Promise<Notification[]>
|
||||
async getNotifications(): Promise<Notification[]>
|
||||
```
|
||||
|
||||
```typescript Response theme={null}
|
||||
interface Notification {
|
||||
id: number; // Unique notification ID
|
||||
owner: string; // User's L2 credential apiKey or empty string for global notifications
|
||||
payload: any; // Type-specific payload data
|
||||
timestamp?: number; // Unix timestamp
|
||||
type: number; // Notification type (see type mapping below)
|
||||
}
|
||||
```
|
||||
**Response**
|
||||
|
||||
**Notification Type Mapping**
|
||||
<ResponseField name="id" type="number">
|
||||
Unique notification ID.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="owner" type="string">
|
||||
The user's API key, or an empty string for global notifications.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="payload" type="any">
|
||||
Type-specific payload data for the notification.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="timestamp" type="number">
|
||||
Optional Unix timestamp of when the notification was created.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="type" type="number">
|
||||
Notification type (see below).
|
||||
</ResponseField>
|
||||
|
||||
| Name | Value | Description |
|
||||
| ------------------ | ----- | ---------------------------------------- |
|
||||
| Order Cancellation | 1 | User's order was canceled |
|
||||
| Order Fill | 2 | User's order was filled (maker or taker) |
|
||||
| Market Resolved | 4 | Market was resolved |
|
||||
| Order Cancellation | `1` | User's order was canceled |
|
||||
| Order Fill | `2` | User's order was filled (maker or taker) |
|
||||
| Market Resolved | `4` | Market was resolved |
|
||||
|
||||
***
|
||||
|
||||
@@ -618,33 +740,33 @@ interface Notification {
|
||||
Mark notifications as read/dismissed.
|
||||
|
||||
```typescript Signature theme={null}
|
||||
public async dropNotifications(params?: DropNotificationParams): Promise<void>
|
||||
async dropNotifications(params?: DropNotificationParams): Promise<void>
|
||||
```
|
||||
|
||||
```typescript Params theme={null}
|
||||
interface DropNotificationParams {
|
||||
ids: string[]; // Array of notification IDs to mark as read
|
||||
}
|
||||
```
|
||||
**Params**
|
||||
|
||||
<ResponseField name="ids" type="string[]">
|
||||
Array of notification IDs to dismiss.
|
||||
</ResponseField>
|
||||
|
||||
***
|
||||
|
||||
## See Also
|
||||
|
||||
<CardGroup cols={2}>
|
||||
<Card title="Understand CLOB Authentication" icon="shield" href="/developers/CLOB/authentication">
|
||||
Deep dive into L1 and L2 authentication
|
||||
<Card title="Authentication" icon="shield" href="/api-reference/authentication">
|
||||
Deep dive into L1 and L2 authentication.
|
||||
</Card>
|
||||
|
||||
<Card title="Public Methods" icon="globe" href="/developers/CLOB/clients/methods-l2">
|
||||
Access market data, orderbooks, and prices.
|
||||
<Card title="L1 Methods" icon="key" href="/trading/clients/l1">
|
||||
Sign orders and derive API credentials with your private key.
|
||||
</Card>
|
||||
|
||||
<Card title="L1 Methods" icon="lock" href="/developers/CLOB/clients/methods-l2">
|
||||
Private key authentication to create or derive API keys (L2 headers)
|
||||
<Card title="Public Methods" icon="globe" href="/trading/clients/public">
|
||||
Read market data and orderbooks without auth.
|
||||
</Card>
|
||||
|
||||
<Card title="Web Socket API" icon="hammer" href="/developers/CLOB/websocket/wss-overview">
|
||||
Real-time market data streaming
|
||||
<Card title="WebSocket" icon="bolt" href="/market-data/websocket/overview">
|
||||
Real-time market data streaming.
|
||||
</Card>
|
||||
</CardGroup>
|
||||
|
||||
Reference in New Issue
Block a user