Files
PolymarketDocumentation/docs/developers/CLOB/clients/methods-l1.md
T
AI Agent b2a29fe51f 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
2026-02-19 14:31:02 +01:00

11 KiB

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.

L1 Methods

These methods require a wallet signer (private key) but do not require user API credentials. Use these for initial setup.

Client Initialization

L1 methods require the client to initialize with a signer.

```typescript theme={null} import { ClobClient } from "@polymarket/clob-client"; import { Wallet } from "ethers";
const signer = new Wallet(process.env.PRIVATE_KEY);

const client = new ClobClient(
  "https://clob.polymarket.com",
  137,
  signer // Signer required for L1 methods
);

// Ready to create user API credentials
const apiKey = await client.createApiKey();
```
```python theme={null} from py_clob_client.client import ClobClient import os
private_key = os.getenv("PRIVATE_KEY")

client = ClobClient(
    host="https://clob.polymarket.com",
    chain_id=137,
    key=private_key  # Signer required for L1 methods
)

# Ready to create user API credentials
api_key = client.create_api_key()
```
Never commit private keys to version control. Always use environment variables or a secure key management system.

API Key Management


createApiKey()

Creates a new API key (L2 credentials) for the wallet signer. Each wallet can only have one active API key at a time — creating a new key invalidates the previous one.

async createApiKey(nonce?: number): Promise<ApiKeyCreds>
Optional custom nonce for deterministic key generation. Optional. The generated API key string. The secret associated with the API key. The passphrase associated with the API key.

deriveApiKey()

Derives an existing API key using a specific nonce. If you've already created credentials with a particular nonce, this returns the same credentials.

async deriveApiKey(nonce?: number): Promise<ApiKeyCreds>
The nonce used when originally creating the key. Optional. The derived API key string. The secret associated with the API key. The passphrase associated with the API key.

createOrDeriveApiKey()

Convenience method that attempts to derive an API key with the default nonce, or creates a new one if it doesn't exist. Recommended for initial setup.

async createOrDeriveApiKey(nonce?: number): Promise<ApiKeyCreds>
The API key string, either derived or newly created. The secret associated with the API key. The passphrase associated with the API key.

Order Signing

createOrder()

Create and sign a limit order locally without posting it to the CLOB. Use this when you want to sign orders in advance or implement custom submission logic. Submit via postOrder() or postOrders().

async createOrder(
  userOrder: UserOrder,
  options?: Partial<CreateOrderOptions>
): Promise<SignedOrder>
The token ID of the market outcome to trade. The limit price for the order. The size (number of shares) for the order. The side of the order (buy or sell). Optional fee rate in basis points. Optional. Optional nonce for the order. Optional. Optional expiration timestamp for the order. Optional. Optional taker address for the order. Optional. The tick size used for order validation (CreateOrderOptions). Optional flag for negative risk markets (CreateOrderOptions). Optional. A random salt value for the signed order. The maker's address. The signer's address. The taker's address in the signed order. The token ID in the signed order. The maker amount as a string. The taker amount as a string. The side of the order as a number (0 = BUY, 1 = SELL). The expiration timestamp as a string. The nonce as a string. The fee rate in basis points as a string. The type identifier for the signature scheme used. The cryptographic signature of the order.

createMarketOrder()

Create and sign a market order locally without posting it to the CLOB. Submit via postOrder() or postOrders().

async createMarketOrder(
  userMarketOrder: UserMarketOrder,
  options?: Partial<CreateOrderOptions>
): Promise<SignedOrder>
The token ID of the market outcome to trade. The order amount. For BUY orders this is a dollar amount; for SELL orders this is the number of shares. The side of the order (buy or sell). Optional price limit for the market order. Optional. Optional fee rate in basis points. Optional. Optional nonce for the order. Optional. Optional taker address for the order. Optional. Optional order type, either FOK (Fill-Or-Kill) or FAK (Fill-And-Kill). Optional. A random salt value for the signed order. The maker's address. The signer's address. The taker's address in the signed order. The token ID in the signed order. The maker amount as a string. The taker amount as a string. The side of the order as a number (0 = BUY, 1 = SELL). The expiration timestamp as a string. The nonce as a string. The fee rate in basis points as a string. The type identifier for the signature scheme used. The cryptographic signature of the order.

Troubleshooting

Your wallet's private key is incorrect or improperly formatted.
**Solution:**

* Verify your private key is a valid hex string (starts with `0x`)
* Ensure you're using the correct key for the intended address
* Check that the key has proper permissions
The nonce you provided has already been used to create an API key.
**Solution:**

* Use `deriveApiKey()` with the same nonce to retrieve existing credentials
* Or use a different nonce with `createApiKey()`
Your funder address is incorrect or doesn't match your wallet.
**Solution:** Check your proxy wallet address at [polymarket.com/settings](https://polymarket.com/settings). If it doesn't exist, the user has never logged in to Polymarket.com — deploy the proxy wallet first before creating L2 credentials.
```typescript theme={null} // Use deriveApiKey with the original nonce const recovered = await client.deriveApiKey(originalNonce); ``` There's no way to recover lost credentials without the nonce. Create new ones:
```typescript  theme={null}
// Create fresh credentials with a new nonce
const newCreds = await client.createApiKey();
// Save the nonce this time!
```

See Also

Deep dive into L1 and L2 authentication. Initialize the client and place your first order. Access market data, orderbooks, and prices without auth. Place and manage orders with API credentials.