@k256/sdk 0.1.1 → 0.1.3
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/README.md +37 -13
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -87,19 +87,22 @@ type ConnectionState =
|
|
|
87
87
|
## Error Handling
|
|
88
88
|
|
|
89
89
|
```typescript
|
|
90
|
-
import { K256WebSocketError } from '@k256/sdk';
|
|
90
|
+
import { K256WebSocketClient, K256WebSocketError } from '@k256/sdk';
|
|
91
91
|
|
|
92
|
-
client
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
92
|
+
const client = new K256WebSocketClient({
|
|
93
|
+
apiKey: 'your-api-key',
|
|
94
|
+
onError: (error: K256WebSocketError) => {
|
|
95
|
+
console.error(`[${error.code}] ${error.message}`);
|
|
96
|
+
|
|
97
|
+
if (error.isAuthError) {
|
|
98
|
+
// Invalid API key - don't retry
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (error.isRecoverable) {
|
|
102
|
+
// Will auto-reconnect
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
});
|
|
103
106
|
```
|
|
104
107
|
|
|
105
108
|
## Low-Level Decoder
|
|
@@ -148,11 +151,32 @@ interface K256WebSocketClientConfig {
|
|
|
148
151
|
}
|
|
149
152
|
```
|
|
150
153
|
|
|
154
|
+
## Examples
|
|
155
|
+
|
|
156
|
+
Runnable examples are available in the GitHub repository:
|
|
157
|
+
|
|
158
|
+
```bash
|
|
159
|
+
git clone https://github.com/k256-xyz/k256-sdks.git
|
|
160
|
+
cd k256-sdks/typescript/examples
|
|
161
|
+
npm install
|
|
162
|
+
|
|
163
|
+
# Run with your API key
|
|
164
|
+
K256_API_KEY=your-key npx tsx websocket.ts
|
|
165
|
+
|
|
166
|
+
# Subscribe to specific channel
|
|
167
|
+
K256_API_KEY=your-key npx tsx websocket.ts --channel=priority_fees
|
|
168
|
+
|
|
169
|
+
# Filter by protocol
|
|
170
|
+
K256_API_KEY=your-key npx tsx websocket.ts --protocol="Raydium AMM"
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
See [examples/](https://github.com/k256-xyz/k256-sdks/tree/main/typescript/examples) for all available examples.
|
|
174
|
+
|
|
151
175
|
## Links
|
|
152
176
|
|
|
153
177
|
- [K256 Website](https://k256.xyz)
|
|
154
178
|
- [API Documentation](https://docs.k256.xyz)
|
|
155
|
-
- [GitHub](https://github.com/k256-xyz)
|
|
179
|
+
- [GitHub](https://github.com/k256-xyz/k256-sdks)
|
|
156
180
|
|
|
157
181
|
## License
|
|
158
182
|
|