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:
@@ -43,13 +43,13 @@ L1 methods require the client to initialize with a signer.
|
||||
)
|
||||
|
||||
# Ready to create user API credentials
|
||||
api_key = await client.create_api_key()
|
||||
api_key = client.create_api_key()
|
||||
```
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
<Warning>
|
||||
**Security:** Never commit private keys to version control. Always use environment variables or secure key management systems.
|
||||
Never commit private keys to version control. Always use environment variables or a secure key management system.
|
||||
</Warning>
|
||||
|
||||
***
|
||||
@@ -60,68 +60,75 @@ L1 methods require the client to initialize with a signer.
|
||||
|
||||
### createApiKey()
|
||||
|
||||
Creates a new API key (L2 credentials) for the wallet signer. This generates a new set of credentials that can be used for L2 authenticated requests.
|
||||
Each wallet can only have one active API key at a time. Creating a new key invalidates the previous one.
|
||||
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.
|
||||
|
||||
```typescript Signature theme={null}
|
||||
async createApiKey(nonce?: number): Promise<ApiKeyCreds>
|
||||
```
|
||||
|
||||
```typescript Params theme={null}
|
||||
`nonce` (optional): Custom nonce for deterministic key generation. If not provided, a default derivation is used.
|
||||
```
|
||||
<ResponseField name="nonce" type="number">
|
||||
Optional custom nonce for deterministic key generation. Optional.
|
||||
</ResponseField>
|
||||
|
||||
```typescript Response theme={null}
|
||||
interface ApiKeyCreds {
|
||||
apiKey: string;
|
||||
secret: string;
|
||||
passphrase: string;
|
||||
}
|
||||
```
|
||||
<ResponseField name="apiKey" type="string">
|
||||
The generated API key string.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="secret" type="string">
|
||||
The secret associated with the API key.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="passphrase" type="string">
|
||||
The passphrase associated with the API key.
|
||||
</ResponseField>
|
||||
|
||||
***
|
||||
|
||||
### deriveApiKey()
|
||||
|
||||
Derives an existing API key (L2 credentials) using a specific nonce. If you've already created API credentials with a particular nonce, this method will return the same credentials again.
|
||||
Derives an existing API key using a specific nonce. If you've already created credentials with a particular nonce, this returns the same credentials.
|
||||
|
||||
```typescript Signature theme={null}
|
||||
async deriveApiKey(nonce?: number): Promise<ApiKeyCreds>
|
||||
```
|
||||
|
||||
```typescript Params theme={null}
|
||||
`nonce` (optional): Custom nonce for deterministic key generation. If not provided, a default derivation is used.
|
||||
```
|
||||
<ResponseField name="nonce" type="number">
|
||||
The nonce used when originally creating the key. Optional.
|
||||
</ResponseField>
|
||||
|
||||
```typescript Response theme={null}
|
||||
interface ApiKeyCreds {
|
||||
apiKey: string;
|
||||
secret: string;
|
||||
passphrase: string;
|
||||
}
|
||||
```
|
||||
<ResponseField name="apiKey" type="string">
|
||||
The derived API key string.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="secret" type="string">
|
||||
The secret associated with the API key.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="passphrase" type="string">
|
||||
The passphrase associated with the API key.
|
||||
</ResponseField>
|
||||
|
||||
***
|
||||
|
||||
### createOrDeriveApiKey()
|
||||
|
||||
Convenience method that attempts to derive an API key with the default nonce, or creates a new one if it doesn't exist. This is the recommended method for initial setup if you're unsure if credentials already exist.
|
||||
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.**
|
||||
|
||||
```typescript Signature theme={null}
|
||||
async createOrDeriveApiKey(nonce?: number): Promise<ApiKeyCreds>
|
||||
```
|
||||
|
||||
```typescript Params theme={null}
|
||||
`nonce` (optional): Custom nonce for deterministic key generation. If not provided, a default derivation is used.
|
||||
```
|
||||
<ResponseField name="apiKey" type="string">
|
||||
The API key string, either derived or newly created.
|
||||
</ResponseField>
|
||||
|
||||
```typescript Response theme={null}
|
||||
interface ApiKeyCreds {
|
||||
apiKey: string;
|
||||
secret: string;
|
||||
passphrase: string;
|
||||
}
|
||||
```
|
||||
<ResponseField name="secret" type="string">
|
||||
The secret associated with the API key.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="passphrase" type="string">
|
||||
The passphrase associated with the API key.
|
||||
</ResponseField>
|
||||
|
||||
***
|
||||
|
||||
@@ -129,9 +136,7 @@ interface ApiKeyCreds {
|
||||
|
||||
### 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 order submission logic.
|
||||
Place order via L2 methods postOrder or postOrders.
|
||||
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()`](/trading/clients/l2#postorder) or [`postOrders()`](/trading/clients/l2#postorders).
|
||||
|
||||
```typescript Signature theme={null}
|
||||
async createOrder(
|
||||
@@ -140,49 +145,103 @@ async createOrder(
|
||||
): Promise<SignedOrder>
|
||||
```
|
||||
|
||||
```typescript Params theme={null}
|
||||
interface UserOrder {
|
||||
tokenID: string;
|
||||
price: number;
|
||||
size: number;
|
||||
side: Side;
|
||||
feeRateBps?: number;
|
||||
nonce?: number;
|
||||
expiration?: number;
|
||||
taker?: string;
|
||||
}
|
||||
<ResponseField name="tokenID" type="string">
|
||||
The token ID of the market outcome to trade.
|
||||
</ResponseField>
|
||||
|
||||
interface CreateOrderOptions {
|
||||
tickSize: TickSize;
|
||||
negRisk?: boolean;
|
||||
}
|
||||
```
|
||||
<ResponseField name="price" type="number">
|
||||
The limit price for the order.
|
||||
</ResponseField>
|
||||
|
||||
```typescript Response theme={null}
|
||||
interface SignedOrder {
|
||||
salt: string;
|
||||
maker: string;
|
||||
signer: string;
|
||||
taker: string;
|
||||
tokenId: string;
|
||||
makerAmount: string;
|
||||
takerAmount: string;
|
||||
side: number; // 0 = BUY, 1 = SELL
|
||||
expiration: string;
|
||||
nonce: string;
|
||||
feeRateBps: string;
|
||||
signatureType: number;
|
||||
signature: string;
|
||||
}
|
||||
```
|
||||
<ResponseField name="size" type="number">
|
||||
The size (number of shares) for 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. Optional.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="nonce" type="number">
|
||||
Optional nonce for the order. Optional.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="expiration" type="number">
|
||||
Optional expiration timestamp for the order. Optional.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="taker" type="string">
|
||||
Optional taker address for the order. Optional.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="tickSize" type="TickSize">
|
||||
The tick size used for order validation (CreateOrderOptions).
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="negRisk" type="boolean">
|
||||
Optional flag for negative risk markets (CreateOrderOptions). Optional.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="salt" type="string">
|
||||
A random salt value for the signed order.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="maker" type="string">
|
||||
The maker's address.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="signer" type="string">
|
||||
The signer's address.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="taker" type="string">
|
||||
The taker's address in the signed order.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="tokenId" type="string">
|
||||
The token ID in the signed order.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="makerAmount" type="string">
|
||||
The maker amount as a string.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="takerAmount" type="string">
|
||||
The taker amount as a string.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="side" type="number">
|
||||
The side of the order as a number (0 = BUY, 1 = SELL).
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="expiration" type="string">
|
||||
The expiration timestamp as a string.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="nonce" type="string">
|
||||
The nonce as a string.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="feeRateBps" type="string">
|
||||
The fee rate in basis points as a string.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="signatureType" type="number">
|
||||
The type identifier for the signature scheme used.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="signature" type="string">
|
||||
The cryptographic signature of the order.
|
||||
</ResponseField>
|
||||
|
||||
***
|
||||
|
||||
### createMarketOrder()
|
||||
|
||||
Create and sign a market order locally without posting it to the CLOB.
|
||||
Use this when you want to sign orders in advance or implement custom order submission logic.
|
||||
Place orders via L2 methods postOrder or postOrders.
|
||||
Create and sign a market order locally without posting it to the CLOB. Submit via [`postOrder()`](/trading/clients/l2#postorder) or [`postOrders()`](/trading/clients/l2#postorders).
|
||||
|
||||
```typescript Signature theme={null}
|
||||
async createMarketOrder(
|
||||
@@ -191,36 +250,89 @@ async createMarketOrder(
|
||||
): Promise<SignedOrder>
|
||||
```
|
||||
|
||||
```typescript Params theme={null}
|
||||
interface UserMarketOrder {
|
||||
tokenID: string;
|
||||
amount: number; // BUY: dollar amount, SELL: number of shares
|
||||
side: Side;
|
||||
price?: number; // Optional price limit
|
||||
feeRateBps?: number;
|
||||
nonce?: number;
|
||||
taker?: string;
|
||||
orderType?: OrderType.FOK | OrderType.FAK;
|
||||
}
|
||||
```
|
||||
<ResponseField name="tokenID" type="string">
|
||||
The token ID of the market outcome to trade.
|
||||
</ResponseField>
|
||||
|
||||
```typescript Response theme={null}
|
||||
interface SignedOrder {
|
||||
salt: string;
|
||||
maker: string;
|
||||
signer: string;
|
||||
taker: string;
|
||||
tokenId: string;
|
||||
makerAmount: string;
|
||||
takerAmount: string;
|
||||
side: number; // 0 = BUY, 1 = SELL
|
||||
expiration: string;
|
||||
nonce: string;
|
||||
feeRateBps: string;
|
||||
signatureType: number;
|
||||
signature: string;
|
||||
}
|
||||
```
|
||||
<ResponseField name="amount" type="number">
|
||||
The order amount. For BUY orders this is a dollar amount; for SELL orders this is the number of shares.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="side" type="Side">
|
||||
The side of the order (buy or sell).
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="price" type="number">
|
||||
Optional price limit for the market order. Optional.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="feeRateBps" type="number">
|
||||
Optional fee rate in basis points. Optional.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="nonce" type="number">
|
||||
Optional nonce for the order. Optional.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="taker" type="string">
|
||||
Optional taker address for the order. Optional.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="orderType" type="OrderType.FOK | OrderType.FAK">
|
||||
Optional order type, either FOK (Fill-Or-Kill) or FAK (Fill-And-Kill). Optional.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="salt" type="string">
|
||||
A random salt value for the signed order.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="maker" type="string">
|
||||
The maker's address.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="signer" type="string">
|
||||
The signer's address.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="taker" type="string">
|
||||
The taker's address in the signed order.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="tokenId" type="string">
|
||||
The token ID in the signed order.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="makerAmount" type="string">
|
||||
The maker amount as a string.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="takerAmount" type="string">
|
||||
The taker amount as a string.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="side" type="number">
|
||||
The side of the order as a number (0 = BUY, 1 = SELL).
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="expiration" type="string">
|
||||
The expiration timestamp as a string.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="nonce" type="string">
|
||||
The nonce as a string.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="feeRateBps" type="string">
|
||||
The fee rate in basis points as a string.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="signatureType" type="number">
|
||||
The type identifier for the signature scheme used.
|
||||
</ResponseField>
|
||||
|
||||
<ResponseField name="signature" type="string">
|
||||
The cryptographic signature of the order.
|
||||
</ResponseField>
|
||||
|
||||
***
|
||||
|
||||
@@ -232,7 +344,7 @@ interface SignedOrder {
|
||||
|
||||
**Solution:**
|
||||
|
||||
* Verify your private key is a valid hex string (starts with "0x")
|
||||
* 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
|
||||
</Accordion>
|
||||
@@ -249,9 +361,7 @@ interface SignedOrder {
|
||||
<Accordion title="Error: Invalid Funder Address">
|
||||
Your funder address is incorrect or doesn't match your wallet.
|
||||
|
||||
**Solution:** Check your Polymarket profile address at [polymarket.com/settings](https://polymarket.com/settings).
|
||||
|
||||
If it does not exist or user has never logged into Polymarket.com, deploy it first before creating L2 authentication.
|
||||
**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.
|
||||
</Accordion>
|
||||
|
||||
<Accordion title="Lost API credentials but have nonce">
|
||||
@@ -262,7 +372,7 @@ interface SignedOrder {
|
||||
</Accordion>
|
||||
|
||||
<Accordion title="Lost both credentials and nonce">
|
||||
Unfortunately, there's no way to recover lost API credentials without the nonce. You'll need to create new credentials:
|
||||
There's no way to recover lost credentials without the nonce. Create new ones:
|
||||
|
||||
```typescript theme={null}
|
||||
// Create fresh credentials with a new nonce
|
||||
@@ -277,19 +387,19 @@ interface SignedOrder {
|
||||
## 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="CLOB Quickstart Guide" icon="hammer" href="/developers/CLOB/quickstart">
|
||||
Initialize the CLOB quickly and place your first order.
|
||||
<Card title="Trading Quickstart" icon="bolt" href="/trading/quickstart">
|
||||
Initialize the client and place your first order.
|
||||
</Card>
|
||||
|
||||
<Card title="Public Methods" icon="globe" href="/developers/CLOB/clients/methods-l2">
|
||||
Access market data, orderbooks, and prices.
|
||||
<Card title="Public Methods" icon="globe" href="/trading/clients/public">
|
||||
Access market data, orderbooks, and prices without auth.
|
||||
</Card>
|
||||
|
||||
<Card title="L2 Methods" icon="lock" href="/developers/CLOB/clients/methods-l2">
|
||||
Manage and close orders. Creating orders requires signer.
|
||||
<Card title="L2 Methods" icon="lock" href="/trading/clients/l2">
|
||||
Place and manage orders with API credentials.
|
||||
</Card>
|
||||
</CardGroup>
|
||||
|
||||
Reference in New Issue
Block a user