> ## Documentation Index > Fetch the complete documentation index at: https://docs.polymarket.com/llms.txt > Use this file to discover all available pages before exploring further. # L2 Methods > 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 a signer, signature type, API credentials, and funder address. ```typescript theme={null} import { ClobClient } from "@polymarket/clob-client-v2"; import { createWalletClient, http } from "viem"; import { privateKeyToAccount } from "viem/accounts"; const account = privateKeyToAccount(process.env.PRIVATE_KEY as `0x${string}`); const signer = createWalletClient({ account, transport: http() }); const apiCreds = { key: process.env.API_KEY, secret: process.env.SECRET, passphrase: process.env.PASSPHRASE, }; const depositWalletAddress = process.env.DEPOSIT_WALLET_ADDRESS!; const client = new ClobClient({ host: "https://clob.polymarket.com", chain: 137, signer, creds: apiCreds, signatureType: 3, // POLY_1271 funderAddress: depositWalletAddress, }); // Ready to send authenticated requests const order = await client.postOrder(signedOrder); ``` ```python theme={null} from py_clob_client_v2 import ClobClient from py_clob_client_v2 import ApiCreds import os api_creds = ApiCreds( api_key=os.getenv("API_KEY"), api_secret=os.getenv("SECRET"), api_passphrase=os.getenv("PASSPHRASE") ) client = ClobClient( host="https://clob.polymarket.com", chain_id=137, key=os.getenv("PRIVATE_KEY"), creds=api_creds, signature_type=3, # POLY_1271 funder=os.getenv("DEPOSIT_WALLET_ADDRESS") ) # Ready to send authenticated requests order = client.post_order(signed_order) ``` *** ## Order Creation and Management *** ### createAndPostOrder 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( userOrder: UserOrder, options?: Partial, orderType?: OrderType.GTC | OrderType.GTD, // Defaults to GTC ): Promise ``` **Params** The token ID of the outcome to trade. The limit price for the order. The size of the order. The side of the order (buy or sell). Optional expiration timestamp for the order. Tick size for the order. One of `"0.1"`, `"0.01"`, `"0.001"`, `"0.0001"`. Optional. Whether the market uses negative risk. **Response** Whether the order was successfully placed. Error message if the order was not successful. The ID of the placed order. Array of transaction hashes associated with the order. The current status of the order. The amount being taken in the order. The amount being made in the order. *** ### createAndPostMarketOrder 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( userMarketOrder: UserMarketOrder, options?: Partial, orderType?: OrderType.FOK | OrderType.FAK, // Defaults to FOK ): Promise ``` **Params** The token ID of the outcome to trade. The amount for the market order. The side of the order (buy or sell). Optional price hint for the market order. Optional order type override. Defaults to FOK. **Response** Whether the order was successfully placed. Error message if the order was not successful. The ID of the placed order. Array of transaction hashes associated with the order. The current status of the order. The amount being taken in the order. The amount being made in the order. *** ### postOrder 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 ): Promise ``` *** ### postOrders Posts up to 15 pre-signed orders in a single batch. ```typescript Signature theme={null} async postOrders( args: PostOrdersArgs[], ): Promise ``` **Params** The pre-signed order to post. The order type (e.g. GTC, FOK, FAK). Optional. Whether to post the order as post-only. Defaults to false. *** ### cancelOrder Cancels a single open order. ```typescript Signature theme={null} async cancelOrder(orderID: string): Promise ``` **Response** Array of order IDs that were successfully canceled. Map of order IDs to reasons why they could not be canceled. *** ### cancelOrders Cancels multiple orders in a single batch. ```typescript Signature theme={null} async cancelOrders(orderIDs: string[]): Promise ``` *** ### cancelAll Cancels all open orders. ```typescript Signature theme={null} async cancelAll(): Promise ``` *** ### cancelMarketOrders Cancels all open orders for a specific market. ```typescript Signature theme={null} async cancelMarketOrders( payload: OrderMarketCancelParams ): Promise ``` **Params** Optional. The market condition ID to cancel orders for. Optional. The token ID to cancel orders for. *** ## Order and Trade Queries *** ### getOrder Get details for a specific order by ID. ```typescript Signature theme={null} async getOrder(orderID: string): Promise ``` **Response** The unique order ID. The current status of the order. The API key of the order owner. The on-chain address of the order maker. The market condition ID the order belongs to. The token ID the order is for. The side of the order (BUY or SELL). The original size of the order when it was placed. The amount of the order that has been matched so far. The limit price of the order. Array of trade IDs associated with this order. The outcome label for the order's token. Unix timestamp of when the order was created. The expiration time of the order. The order type (e.g. GTC, FOK, FAK, GTD). *** ### getOpenOrders Get all your open orders. ```typescript Signature theme={null} async getOpenOrders( params?: OpenOrderParams, only_first_page?: boolean, ): Promise ``` **Params** Optional. Filter by order ID. Optional. Filter by market condition ID. Optional. Filter by token ID. *** ### getTrades Get your trade history (filled orders). ```typescript Signature theme={null} async getTrades( params?: TradeParams, only_first_page?: boolean, ): Promise ``` **Params** Optional. Filter by trade ID. Optional. Filter by maker address. Optional. Filter by market condition ID. Optional. Filter by token ID. Optional. Return trades before this timestamp. Optional. Return trades after this timestamp. **Response** The unique trade ID. The order ID of the taker side. The market condition ID for the trade. The token ID for the trade. The side of the trade (BUY or SELL). The size of the trade. The fee rate in basis points. The price at which the trade was matched. The current status of the trade. The time at which the trade was matched. The time of the last update to this trade. The outcome label for the traded token. The bucket index for the trade. The API key of the trade owner. The on-chain address of the maker. Array of maker order objects that participated in this trade. Each `MakerOrder` contains the following fields: The maker order ID. The API key of the maker order owner. The on-chain address of the maker order maker. The amount matched for this maker order. The price of the maker order. The fee rate in basis points for the maker order. The token ID for the maker order. The outcome label for the maker order's token. The side of the maker order (BUY or SELL). The on-chain transaction hash for the trade. Whether the authenticated user is the taker or a maker in this trade. *** ### getTradesPaginated Get trade history with pagination for large result sets. ```typescript Signature theme={null} async getTradesPaginated( params?: TradeParams, ): Promise ``` **Response** Array of trade objects for the current page. The maximum number of trades returned per page. The total number of trades matching the query. *** ## Balance and Allowances *** ### getBalanceAllowance Get your balance and allowance for specific tokens. ```typescript Signature theme={null} async getBalanceAllowance( params?: BalanceAllowanceParams ): Promise ``` **Params** The type of asset to query. One of `"COLLATERAL"` or `"CONDITIONAL"`. Optional. The token ID to query (required when `asset_type` is `CONDITIONAL`). **Response** The current balance for the specified asset. The current allowance for the specified asset. *** ### updateBalanceAllowance Updates the cached balance and allowance for specific tokens. ```typescript Signature theme={null} async updateBalanceAllowance( params?: BalanceAllowanceParams ): Promise ``` *** ## API Key Management *** ### getApiKeys Get all API keys associated with your account. ```typescript Signature theme={null} async getApiKeys(): Promise ``` **Response** Array of API key credential objects associated with the account. *** ### deleteApiKey Deletes (revokes) the currently authenticated API key. ```typescript Signature theme={null} async deleteApiKey(): Promise ``` *** ## Notifications *** ### getNotifications Retrieves all event notifications for the authenticated user. Records are automatically removed after 48 hours. ```typescript Signature theme={null} async getNotifications(): Promise ``` **Response** Unique notification ID. The user's API key, or an empty string for global notifications. Type-specific payload data for the notification. Optional Unix timestamp of when the notification was created. Notification type (see below). | 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 | *** ### dropNotifications Mark notifications as read/dismissed. ```typescript Signature theme={null} async dropNotifications(params?: DropNotificationParams): Promise ``` **Params** Array of notification IDs to dismiss. *** ## See Also Deep dive into L1 and L2 authentication. Sign orders and derive API credentials with your private key. Read market data and orderbooks without auth. Real-time market data streaming.