[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-76072":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":10,"languages":10,"totalLinesOfCode":10,"stars":11,"forks":12,"watchers":13,"openIssues":14,"contributorsCount":15,"subscribersCount":15,"size":15,"stars1d":15,"stars7d":15,"stars30d":14,"stars90d":15,"forks30d":15,"starsTrendScore":15,"compositeScore":16,"rankGlobal":10,"rankLanguage":10,"license":17,"archived":18,"fork":18,"defaultBranch":19,"hasWiki":18,"hasPages":18,"topics":20,"createdAt":10,"pushedAt":10,"updatedAt":37,"readmeContent":38,"aiSummary":39,"trendingCount":15,"starSnapshotCount":15,"syncStatus":14,"lastSyncTime":40,"discoverSource":41},76072,"clob-client-v2","dev-polymarket\u002Fclob-client-v2","dev-polymarket","polymarket clob | polymarket clob | polymarket clob | polymarket clob | polymarket clob | polymarket clob | polymarket clob | polymarket clob | polymarket clob | polymarket clob | polymarket clob | polymarket clob | polymarket clob | polymarket clob | polymarket clob | polymarket clob - TypeScript client for Polymarket's CLOB (V2)","https:\u002F\u002Fdocs.polymarket.com",null,596,397,21,2,0,11.8,"MIT License",false,"main",[21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36],"api","blockchain","bot","btc","clob-api","clob-client","crypto","cryptocurrency","ethereum","exchange","forecast","javascript","polymarket","sdk","typescript","web3","2026-06-12 02:03:39","# Polymarket CLOB Client V2\n\nTypeScript client for the Polymarket CLOB (v2) \n\n## Installation (choose your package manager)\n\n```\nnpm i @polymarkets\u002Fclob-client-v2           # npm \u002F pnpm \u002F yarn\n```\n\n### Usage\n\n```ts\n\u002F\u002F npm install @polymarkets\u002Fclob-client-v2\n\u002F\u002F npm install viem\n\nimport { ApiKeyCreds, Chain, ClobClient, OrderType, Side } from \"@polymarkets\u002Fclob-client-v2\";\nimport { createWalletClient, http } from \"viem\";\nimport { privateKeyToAccount } from \"viem\u002Faccounts\";\n\nconst host = \"\u003Cpolymarket-clob-host>\";\nconst chainId = Chain.POLYGON; \u002F\u002F or Chain.AMOY for testnet\n\nconst account = privateKeyToAccount(\"0x...\"); \u002F\u002F your private key\nconst walletClient = createWalletClient({ account, transport: http() });\n\n\u002F\u002F Step 1: obtain API credentials using your wallet (L1 auth)\nconst clobClient = new ClobClient({ host, chain: chainId, signer: walletClient });\nconst creds = await clobClient.createOrDeriveApiKey();\n\n\u002F\u002F Step 2: initialize a fully-authenticated client (L1 + L2)\nconst client = new ClobClient({ host, chain: chainId, signer: walletClient, creds });\n\n\u002F\u002F Place a resting limit buy (GTC)\nconst resp = await client.createAndPostOrder(\n    {\n        tokenID: \"\", \u002F\u002F token ID of the market outcome — get from https:\u002F\u002Fdocs.polymarket.com\n        price: 0.4,\n        side: Side.BUY,\n        size: 100,\n    },\n    { tickSize: \"0.01\" },\n    OrderType.GTC,\n);\nconsole.log(resp);\n```\n\nSee [examples](examples\u002F) for more information.\n\n### Market Orders\n\n```ts\n\u002F\u002F Market buy — amount is in USDC\n\u002F\u002F OrderType.FOK: entire order must fill immediately or it is cancelled\n\u002F\u002F OrderType.FAK: fills as much as possible, remainder is cancelled\nconst resp = await client.createAndPostMarketOrder(\n    {\n        tokenID: \"\",\n        amount: 100, \u002F\u002F USDC\n        side: Side.BUY,\n        orderType: OrderType.FOK,\n    },\n    { tickSize: \"0.01\" },\n    OrderType.FOK,\n);\nconsole.log(resp);\n```\n\n### Authentication\n\nThe client has two authentication levels:\n\n**L1** — wallet signature (EIP-712). Required to create or derive API keys.\n\n```ts\nconst client = new ClobClient({ host, chain: chainId, signer: walletClient });\nconst creds = await client.createOrDeriveApiKey();\n```\n\n**L2** — HMAC with API credentials. Required for order placement, cancellation, and account data.\n\n```ts\nconst creds: ApiKeyCreds = {\n    key: process.env.CLOB_API_KEY,\n    secret: process.env.CLOB_SECRET,\n    passphrase: process.env.CLOB_PASS_PHRASE,\n};\nconst client = new ClobClient({ host, chain: chainId, signer: walletClient, creds });\n```\n\n### Error Handling\n\nBy default, API errors are returned as `{ error: \"...\", status: ... }` objects. To have the client throw instead, pass `throwOnError: true`:\n\n```ts\nimport { ApiError, ClobClient } from \"@polymarkets\u002Fclob-client-v2\";\n\nconst client = new ClobClient({ host, chain: chainId, signer: walletClient, creds, throwOnError: true });\n\ntry {\n    const book = await client.getOrderBook(tokenID);\n} catch (e) {\n    if (e instanceof ApiError) {\n        console.log(e.message); \u002F\u002F \"No orderbook exists for the requested token id\"\n        console.log(e.status);  \u002F\u002F 404\n        console.log(e.data);    \u002F\u002F full error response object\n    }\n}\n```\n","该项目是Polymarket CLOB（v2）的TypeScript客户端，用于与去中心化预测市场平台进行交互。它支持通过钱包签名和API密钥认证实现安全的订单创建、提交、取消及账户数据管理等功能，并提供限价单和市价单等多种交易方式。利用EIP-712标准进行L1级认证以生成或导出API密钥，而HMAC机制则保障了L2级操作的安全性。此库适用于需要在区块链上执行复杂交易策略的开发者，特别是在构建涉及加密货币交易、市场预测等应用场景下的自动化工具时。","2026-06-11 03:54:23","CREATED_QUERY"]