propheseer 0.1.0
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.
- package/LICENSE +21 -0
- package/README.md +242 -0
- package/dist/index.cjs +832 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +857 -0
- package/dist/index.d.ts +857 -0
- package/dist/index.js +815 -0
- package/dist/index.js.map +1 -0
- package/package.json +70 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Propheseer
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
# Propheseer TypeScript SDK
|
|
2
|
+
|
|
3
|
+
Official TypeScript/JavaScript SDK for the [Propheseer](https://propheseer.com) prediction markets API. Access normalized data from Polymarket, Kalshi, and Gemini through a single, type-safe interface.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install propheseer
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
For WebSocket support (real-time market updates):
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install propheseer ws
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Quick Start
|
|
18
|
+
|
|
19
|
+
```typescript
|
|
20
|
+
import Propheseer from 'propheseer';
|
|
21
|
+
|
|
22
|
+
const client = new Propheseer({
|
|
23
|
+
apiKey: 'pk_test_...', // or set PROPHESEER_API_KEY env var
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
// List prediction markets
|
|
27
|
+
const page = await client.markets.list({ source: 'polymarket', limit: 10 });
|
|
28
|
+
for (const market of page.data) {
|
|
29
|
+
console.log(`${market.question}: ${(market.outcomes[0].probability * 100).toFixed(0)}%`);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Check your API key usage
|
|
33
|
+
const { data: keyInfo } = await client.keys.me();
|
|
34
|
+
console.log(`Plan: ${keyInfo.plan}, Daily usage: ${keyInfo.usage.daily}`);
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Configuration
|
|
38
|
+
|
|
39
|
+
```typescript
|
|
40
|
+
const client = new Propheseer({
|
|
41
|
+
apiKey: 'pk_test_...', // Required (or PROPHESEER_API_KEY env var)
|
|
42
|
+
baseURL: 'https://api.propheseer.com', // Default
|
|
43
|
+
timeout: 30_000, // Request timeout in ms (default: 30s)
|
|
44
|
+
maxRetries: 2, // Retries on 429/5xx errors (default: 2)
|
|
45
|
+
});
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Resources
|
|
49
|
+
|
|
50
|
+
### Markets
|
|
51
|
+
|
|
52
|
+
```typescript
|
|
53
|
+
// List markets with filters
|
|
54
|
+
const page = await client.markets.list({
|
|
55
|
+
source: 'polymarket', // 'polymarket' | 'kalshi' | 'gemini'
|
|
56
|
+
category: 'politics', // 'politics' | 'sports' | 'finance' | ...
|
|
57
|
+
status: 'open',
|
|
58
|
+
q: 'election', // search query
|
|
59
|
+
limit: 50,
|
|
60
|
+
offset: 0,
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
// Get a single market
|
|
64
|
+
const { data: market } = await client.markets.get('pm_12345');
|
|
65
|
+
|
|
66
|
+
// Auto-paginate through all markets
|
|
67
|
+
for await (const market of client.markets.listAutoPaginate({ source: 'kalshi' })) {
|
|
68
|
+
console.log(market.question);
|
|
69
|
+
}
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Categories
|
|
73
|
+
|
|
74
|
+
```typescript
|
|
75
|
+
const { data: categories } = await client.categories.list();
|
|
76
|
+
// [{ id: 'politics', name: 'Politics', subcategories: ['elections', ...] }, ...]
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### Arbitrage (Pro+)
|
|
80
|
+
|
|
81
|
+
```typescript
|
|
82
|
+
const { data: opportunities } = await client.arbitrage.find({
|
|
83
|
+
minSpread: 0.05,
|
|
84
|
+
category: 'politics',
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
for (const opp of opportunities) {
|
|
88
|
+
console.log(`${opp.question}: spread=${opp.spread}, return=${opp.potentialReturn}`);
|
|
89
|
+
}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Unusual Trades (Pro+)
|
|
93
|
+
|
|
94
|
+
```typescript
|
|
95
|
+
const page = await client.unusualTrades.list({
|
|
96
|
+
reason: 'high_amount',
|
|
97
|
+
since: '2025-01-01T00:00:00Z',
|
|
98
|
+
limit: 20,
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
for (const trade of page.data) {
|
|
102
|
+
console.log(`$${trade.trade.usdcValue} ${trade.trade.side} on "${trade.market.question}"`);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// Auto-paginate
|
|
106
|
+
for await (const trade of client.unusualTrades.listAutoPaginate()) {
|
|
107
|
+
console.log(trade.detection.reason, trade.detection.anomalyScore);
|
|
108
|
+
}
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### History (Business+)
|
|
112
|
+
|
|
113
|
+
```typescript
|
|
114
|
+
// Market price history
|
|
115
|
+
const { data: history } = await client.history.list({
|
|
116
|
+
marketId: 'pm_12345',
|
|
117
|
+
days: 7,
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
// Available snapshot dates
|
|
121
|
+
const { data: dates } = await client.history.dates();
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### Ticker (Public)
|
|
125
|
+
|
|
126
|
+
```typescript
|
|
127
|
+
// No auth required
|
|
128
|
+
const { data: items } = await client.ticker.list({ limit: 10 });
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
## Pagination
|
|
132
|
+
|
|
133
|
+
Paginated endpoints return a `Page<T>` object:
|
|
134
|
+
|
|
135
|
+
```typescript
|
|
136
|
+
const page = await client.markets.list({ limit: 50 });
|
|
137
|
+
console.log(page.data); // Market[]
|
|
138
|
+
console.log(page.meta.total); // total matching markets
|
|
139
|
+
console.log(page.hasMore()); // boolean
|
|
140
|
+
console.log(page.nextOffset()); // number | null
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
For automatic pagination:
|
|
144
|
+
|
|
145
|
+
```typescript
|
|
146
|
+
for await (const market of client.markets.listAutoPaginate({ limit: 50 }, { maxItems: 200 })) {
|
|
147
|
+
// yields individual items, fetching new pages as needed
|
|
148
|
+
}
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
## Error Handling
|
|
152
|
+
|
|
153
|
+
All API errors are thrown as typed exceptions:
|
|
154
|
+
|
|
155
|
+
```typescript
|
|
156
|
+
import { PermissionDeniedError, RateLimitError, AuthenticationError } from 'propheseer';
|
|
157
|
+
|
|
158
|
+
try {
|
|
159
|
+
await client.arbitrage.find();
|
|
160
|
+
} catch (err) {
|
|
161
|
+
if (err instanceof PermissionDeniedError) {
|
|
162
|
+
console.log(`Upgrade to ${err.requiredPlan} plan`);
|
|
163
|
+
} else if (err instanceof RateLimitError) {
|
|
164
|
+
console.log(`Rate limited, retry after ${err.retryAfter}s`);
|
|
165
|
+
} else if (err instanceof AuthenticationError) {
|
|
166
|
+
console.log('Invalid API key');
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
| Error Class | Status | When |
|
|
172
|
+
|------------|--------|------|
|
|
173
|
+
| `AuthenticationError` | 401 | Missing or invalid API key |
|
|
174
|
+
| `InsufficientCreditsError` | 402 | Not enough credits |
|
|
175
|
+
| `PermissionDeniedError` | 403 | Plan upgrade required |
|
|
176
|
+
| `NotFoundError` | 404 | Resource not found |
|
|
177
|
+
| `RateLimitError` | 429 | Rate limit exceeded |
|
|
178
|
+
| `InternalServerError` | 5xx | Server error |
|
|
179
|
+
| `APIConnectionError` | - | Network/timeout error |
|
|
180
|
+
|
|
181
|
+
## WebSocket (Real-Time Updates)
|
|
182
|
+
|
|
183
|
+
```typescript
|
|
184
|
+
import { PropheseerWebSocket } from 'propheseer';
|
|
185
|
+
|
|
186
|
+
const ws = new PropheseerWebSocket({
|
|
187
|
+
apiKey: 'pk_test_...',
|
|
188
|
+
reconnect: true, // Auto-reconnect (default: true)
|
|
189
|
+
maxReconnectAttempts: 5, // Default: 5
|
|
190
|
+
pingInterval: 25_000, // Keepalive interval (default: 25s)
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
ws.on('connected', (msg) => {
|
|
194
|
+
console.log(`Connected: ${msg.sessionId} (${msg.plan})`);
|
|
195
|
+
ws.subscribe(['pm_12345', 'ks_67890']);
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
ws.on('market_update', (msg) => {
|
|
199
|
+
console.log('Market update:', msg.market);
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
ws.on('market_snapshot', (msg) => {
|
|
203
|
+
console.log('Snapshot:', msg.market);
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
ws.on('error', (err) => console.error(err));
|
|
207
|
+
ws.on('disconnect', (code, reason) => console.log('Disconnected:', code, reason));
|
|
208
|
+
ws.on('reconnect', (attempt) => console.log('Reconnecting...', attempt));
|
|
209
|
+
|
|
210
|
+
await ws.connect();
|
|
211
|
+
|
|
212
|
+
// Later:
|
|
213
|
+
ws.unsubscribe(['pm_12345']);
|
|
214
|
+
ws.close();
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
## Rate Limit Information
|
|
218
|
+
|
|
219
|
+
Every API response includes rate limit info:
|
|
220
|
+
|
|
221
|
+
```typescript
|
|
222
|
+
const page = await client.markets.list();
|
|
223
|
+
console.log(page.rateLimit);
|
|
224
|
+
// {
|
|
225
|
+
// plan: 'pro',
|
|
226
|
+
// billingType: 'subscription',
|
|
227
|
+
// limitDay: 10000,
|
|
228
|
+
// remainingDay: 9950,
|
|
229
|
+
// limitMinute: 100,
|
|
230
|
+
// remainingMinute: 98,
|
|
231
|
+
// }
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
## Requirements
|
|
235
|
+
|
|
236
|
+
- Node.js >= 18 (uses native `fetch`)
|
|
237
|
+
- Also works in Bun, Deno, and edge runtimes
|
|
238
|
+
- `ws` package required only for WebSocket support
|
|
239
|
+
|
|
240
|
+
## License
|
|
241
|
+
|
|
242
|
+
MIT
|