@opinion-labs/opinion-api 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +98 -0
  2. package/package.json +1 -1
package/README.md ADDED
@@ -0,0 +1,98 @@
1
+ # @opinion-labs/opinion-api
2
+
3
+ Auto-generated TypeScript client for the [Opinion Labs](https://opinion.trade) Prediction Market OpenAPI.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @opinion-labs/opinion-api
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ```typescript
14
+ import { createClient, createConfig } from '@opinion-labs/opinion-api/client';
15
+ import { getMarket, getTokenOrderbook, getTokenLatestPrice } from '@opinion-labs/opinion-api';
16
+
17
+ // Create a configured client
18
+ const client = createClient(
19
+ createConfig({
20
+ baseUrl: 'https://openapi.opinion.trade/openapi',
21
+ headers: {
22
+ apikey: 'your_api_key',
23
+ },
24
+ })
25
+ );
26
+
27
+ // Fetch markets
28
+ const { data } = await getMarket({
29
+ client,
30
+ headers: { apikey: 'your_api_key' },
31
+ query: { chainId: '56', marketType: 2, page: 1, limit: 10, sortBy: 1 },
32
+ });
33
+
34
+ console.log(data?.result?.list);
35
+ ```
36
+
37
+ ## Available Endpoints
38
+
39
+ ### Market Data
40
+
41
+ | Function | Description |
42
+ |----------|-------------|
43
+ | `getMarket()` | List markets with pagination and filters |
44
+ | `getMarketByMarketId()` | Get binary market details by ID |
45
+ | `getMarketCategoricalByMarketId()` | Get categorical market details by ID |
46
+ | `getQuoteToken()` | List supported quote tokens |
47
+ | `getTokenOrderbook()` | Get orderbook for a token |
48
+ | `getTokenLatestPrice()` | Get latest price for a token |
49
+ | `getTokenPriceHistory()` | Get price history with interval/time range |
50
+ | `getTokenFeeRates()` | Get fee rates for a token |
51
+
52
+ ### User & Positions
53
+
54
+ | Function | Description |
55
+ |----------|-------------|
56
+ | `getUserAuth()` | Get authenticated user info |
57
+ | `getUserBalance()` | Get user's token balances |
58
+ | `getPositions()` | Get user's positions |
59
+ | `getPositionsUserByWalletAddress()` | Get another user's positions |
60
+ | `getTrade()` | Get user's trade history |
61
+ | `getTradeUserByWalletAddress()` | Get another user's trade history |
62
+ | `getOrder()` | Get user's orders |
63
+ | `getOrderByOrderId()` | Get order details by ID |
64
+
65
+ ### Orders
66
+
67
+ | Function | Description |
68
+ |----------|-------------|
69
+ | `postOrder()` | Place an order |
70
+ | `postOrderCancel()` | Cancel an order |
71
+
72
+ ## Response Format
73
+
74
+ All endpoints return responses in the following structure:
75
+
76
+ ```typescript
77
+ {
78
+ data?: {
79
+ errno: number; // 0 = success
80
+ errmsg: string; // Error message (empty on success)
81
+ result: T; // Response payload
82
+ };
83
+ error?: unknown;
84
+ }
85
+ ```
86
+
87
+ ## Higher-Level SDK
88
+
89
+ For a more ergonomic developer experience with built-in order signing, wallet management, and WebSocket support, use [`@opinion-labs/opinion-clob-sdk`](https://www.npmjs.com/package/@opinion-labs/opinion-clob-sdk) which wraps this client.
90
+
91
+ ## Requirements
92
+
93
+ - Node.js >= 18
94
+ - TypeScript >= 5.3 (for type-safe usage)
95
+
96
+ ## License
97
+
98
+ MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opinion-labs/opinion-api",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "Auto-generated OpenAPI client for Opinion Prediction Market API",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",