cabalspy-id 0.0.0-stage → 0.5.1
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/CHANGELOG.md +112 -0
- package/LICENSE +21 -0
- package/README.md +475 -3
- package/dist/api.cjs +72 -0
- package/dist/api.cjs.map +1 -0
- package/dist/api.d.cts +193 -0
- package/dist/api.d.ts +193 -0
- package/dist/api.js +72 -0
- package/dist/api.js.map +1 -0
- package/dist/chunk-3LKLY5WQ.js +1392 -0
- package/dist/chunk-3LKLY5WQ.js.map +1 -0
- package/dist/chunk-3P7QK2PG.js +385 -0
- package/dist/chunk-3P7QK2PG.js.map +1 -0
- package/dist/chunk-A2ZAFAWC.cjs +1 -0
- package/dist/chunk-A2ZAFAWC.cjs.map +1 -0
- package/dist/chunk-CJFIOVBA.js +1 -0
- package/dist/chunk-CJFIOVBA.js.map +1 -0
- package/dist/chunk-L4RHSWOA.cjs +1392 -0
- package/dist/chunk-L4RHSWOA.cjs.map +1 -0
- package/dist/chunk-P3MDLWLN.cjs +385 -0
- package/dist/chunk-P3MDLWLN.cjs.map +1 -0
- package/dist/chunk-X3OFGGSE.cjs +398 -0
- package/dist/chunk-X3OFGGSE.cjs.map +1 -0
- package/dist/chunk-Z3UPDOBY.js +398 -0
- package/dist/chunk-Z3UPDOBY.js.map +1 -0
- package/dist/index.cjs +97 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +21 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.js +97 -0
- package/dist/index.js.map +1 -0
- package/dist/react.cjs +308 -0
- package/dist/react.cjs.map +1 -0
- package/dist/react.d.cts +292 -0
- package/dist/react.d.ts +292 -0
- package/dist/react.js +280 -0
- package/dist/react.js.map +1 -0
- package/dist/thesis.cjs +68 -0
- package/dist/thesis.cjs.map +1 -0
- package/dist/thesis.d.cts +190 -0
- package/dist/thesis.d.ts +190 -0
- package/dist/thesis.js +68 -0
- package/dist/thesis.js.map +1 -0
- package/dist/types-UZeY9n1e.d.cts +689 -0
- package/dist/types-UZeY9n1e.d.ts +689 -0
- package/dist/users-BDLkwW1p.d.cts +767 -0
- package/dist/users-CDlDRuyv.d.ts +767 -0
- package/dist/widget.cjs +217 -0
- package/dist/widget.cjs.map +1 -0
- package/dist/widget.d.cts +195 -0
- package/dist/widget.d.ts +195 -0
- package/dist/widget.js +217 -0
- package/dist/widget.js.map +1 -0
- package/package.json +147 -6
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this package are documented here. The format follows
|
|
4
|
+
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and the project uses
|
|
5
|
+
[Semantic Versioning](https://semver.org/).
|
|
6
|
+
|
|
7
|
+
## [0.5.1] - 2026-10-15
|
|
8
|
+
|
|
9
|
+
### Changed
|
|
10
|
+
|
|
11
|
+
- People can sign in with X, Telegram or Google. Types match accounts without X: `x` is
|
|
12
|
+
`null` in userinfo claims and Data API profiles, `twitter` is `null` in profiles, trading
|
|
13
|
+
profile blocks and leaderboards, `telegram` is documented (`https://t.me/<name>` or `""`),
|
|
14
|
+
handles may be `tg.<name>` or `id.<hex>`.
|
|
15
|
+
|
|
16
|
+
### Added
|
|
17
|
+
|
|
18
|
+
- `hasX()` and `handleKind()` helpers and a README section "Users without X".
|
|
19
|
+
|
|
20
|
+
## [0.5.0] - 2026-10-14
|
|
21
|
+
|
|
22
|
+
### Added
|
|
23
|
+
|
|
24
|
+
- Entry points `cabalspy-id/api` (Data API, trade stream, login, webhooks), `cabalspy-id/thesis`
|
|
25
|
+
(thesis methods, `ThesisClient`, `ThesesStream`) and `cabalspy-id/widget` (browser:
|
|
26
|
+
`mountLoginButton`, `mountTheses`, `setThesisAccessToken`, `startLogin`, `onWidgetEvents`,
|
|
27
|
+
`loginButtonAttributes`, `thesisWidgetAttributes`), plus `cabalspy-id/widget/react`
|
|
28
|
+
(same as `cabalspy-id/react`). The root export is unchanged.
|
|
29
|
+
- Shared chunks in the ESM and CommonJS builds, so classes are identical across entry points.
|
|
30
|
+
- Packages table (socialfi-api, socialfi-thesis, socialfi-widget) in the README.
|
|
31
|
+
|
|
32
|
+
### Changed
|
|
33
|
+
|
|
34
|
+
- The React components use the same attribute mapping as `cabalspy-id/widget`.
|
|
35
|
+
|
|
36
|
+
## [0.4.1] - 2026-10-14
|
|
37
|
+
|
|
38
|
+
### Changed
|
|
39
|
+
|
|
40
|
+
- Package description, keywords and README: CabalSpy ID as a SocialFi API & SDK. No code changes.
|
|
41
|
+
|
|
42
|
+
## [0.4.0] - 2026-10-14
|
|
43
|
+
|
|
44
|
+
### Added
|
|
45
|
+
|
|
46
|
+
- `Thesis.reacted_by` (who reacted recently) and `Thesis.latest_replies` (reply preview on theses).
|
|
47
|
+
- Moderation notifications: Data API `thesisNotifications(csidId)` and
|
|
48
|
+
`appealThesisDecision(csidId, notificationId, message)`; public `ThesisClient.notifications()`,
|
|
49
|
+
`markNotificationsRead()` and `appeal(notificationId, message)`. Types `ThesisNotification`,
|
|
50
|
+
`ThesisNotifications`; `ThesisClient.me()` returns `notices` ({ unread, latest, url }).
|
|
51
|
+
- Webhook types `thesis.reply` (`ThesisReplyData`) and `thesis.reaction` (`ThesisReactionData`).
|
|
52
|
+
- Error code `reporting_paused` (403, `PermissionError`) documented.
|
|
53
|
+
|
|
54
|
+
## [0.3.0] - 2026-10-13
|
|
55
|
+
|
|
56
|
+
### Added
|
|
57
|
+
|
|
58
|
+
- `scope` (`global` | `instance`) on `listTheses`, `iterTheses`, `thesisSummary` and `latestTheses`.
|
|
59
|
+
- `ThesesStream` (`csid.thesesStream()`) for `wss://api-id.cabalspy.xyz/v1/theses/stream` (every plan):
|
|
60
|
+
`subscribe` / `unsubscribe` up to 200 tokens, `subscribeAll` / `unsubscribeAll`, subscriptions
|
|
61
|
+
restored after reconnects, heartbeat watchdog, events and async iteration.
|
|
62
|
+
- `ThesisClient`: `scope` and `clientId` options (reads, `live()`, and post attribution).
|
|
63
|
+
- React `<CabalSpyTheses>`: `clientId` and every design prop (`scope`, `sort`, `font`, `radius`,
|
|
64
|
+
`bg`, `card`, `text`, `muted`, `border`, `accent`, `accentText`, `bull`, `bear`, `showHeader`,
|
|
65
|
+
`showSentiment`, `compact`, `height`).
|
|
66
|
+
|
|
67
|
+
## [0.2.0] - 2026-10-13
|
|
68
|
+
|
|
69
|
+
### Added
|
|
70
|
+
|
|
71
|
+
- Token theses in the Data API: `listTheses` / `iterTheses`, `thesisSummary`, `thesis`,
|
|
72
|
+
`thesisReplies` / `iterThesisReplies`, `latestTheses`, `userTheses`, `thesisEligibility`,
|
|
73
|
+
and writes in a user's name: `postThesis`, `replyToThesis`, `reactToThesis`, `reportThesis`,
|
|
74
|
+
`deleteThesis`. Typed `Thesis`, `ThesisPosition`, `ThesisSummary`, `ThesisEligibility`.
|
|
75
|
+
- `CabalSpyID.postRaw` / `post`. Writes are only retried after the API's own rate limit
|
|
76
|
+
(`rate_limit_exceeded`), never after a server or network error.
|
|
77
|
+
- Stream: `events: ['trades', 'theses']` and `mint`; events `thesis`, `thesis.reply`,
|
|
78
|
+
`thesis.reaction`, `thesis.removed`; `stream.theses()` iterator.
|
|
79
|
+
- `ThesisClient` for the public thesis API (`https://id.cabalspy.xyz/thesis/v1`) with the user's
|
|
80
|
+
access token, and `ThesisClient.live()` for the public per-token websocket.
|
|
81
|
+
- React: `<CabalSpyTheses chain mint theme height radius accessToken />`.
|
|
82
|
+
- Webhook type `thesis.created` (`ThesisCreatedData`), OAuth scope `thesis`.
|
|
83
|
+
|
|
84
|
+
## [0.1.0] - 2026-10-13
|
|
85
|
+
|
|
86
|
+
First release.
|
|
87
|
+
|
|
88
|
+
### Added
|
|
89
|
+
|
|
90
|
+
- `CabalSpyID` Data API client for `https://api-id.cabalspy.xyz/v1`: `health`, `me`, `users`,
|
|
91
|
+
`profile`, `walletLookup`, `tracker`, `history`, `holdings`, `pnlCalendar`, `leaderboard`,
|
|
92
|
+
`latestTransactions`, with typed responses, `*Raw` envelope variants, `instance` support,
|
|
93
|
+
retries with backoff, rate limit info and async iterators (`iterUsers`, `iterHistory`,
|
|
94
|
+
`iterLeaderboard`).
|
|
95
|
+
- `CabalSpyIDStream` for the live trade stream (`/v1/stream`): auto-reconnect, heartbeat
|
|
96
|
+
watchdog, fatal configuration errors, async iteration.
|
|
97
|
+
- `CabalSpyIDAuth` OpenID Connect helpers: discovery, `createAuthorizationUrl` (PKCE S256,
|
|
98
|
+
state, nonce), `handleCallback`, `exchangeCode`, `refresh`, `revoke`, `userinfo`,
|
|
99
|
+
`verifyIdToken` and `verifyAccessToken` (ES256 via JWKS with WebCrypto), `isLimited`.
|
|
100
|
+
- `verifyWebhook` / `signWebhook` for Standard Webhooks signatures.
|
|
101
|
+
- `cabalspy-id/react`: `<CabalSpyLogin />` and `useCabalSpyID()`.
|
|
102
|
+
- Typed errors: `BadRequestError`, `AuthenticationError`, `PermissionError`,
|
|
103
|
+
`PlanUserLimitError`, `NotFoundError`, `RateLimitError`, `ServerError`, `ConnectionError`,
|
|
104
|
+
`InvalidResponseError`, `OAuthError`, `TokenVerificationError`, `WebhookVerificationError`.
|
|
105
|
+
|
|
106
|
+
[0.5.1]: https://github.com/CabalSpy/cabalspy-id-js/compare/v0.5.0...v0.5.1
|
|
107
|
+
[0.5.0]: https://github.com/CabalSpy/cabalspy-id-js/compare/v0.4.1...v0.5.0
|
|
108
|
+
[0.4.1]: https://github.com/CabalSpy/cabalspy-id-js/compare/v0.4.0...v0.4.1
|
|
109
|
+
[0.4.0]: https://github.com/CabalSpy/cabalspy-id-js/compare/v0.3.0...v0.4.0
|
|
110
|
+
[0.3.0]: https://github.com/CabalSpy/cabalspy-id-js/compare/v0.2.0...v0.3.0
|
|
111
|
+
[0.2.0]: https://github.com/CabalSpy/cabalspy-id-js/compare/v0.1.0...v0.2.0
|
|
112
|
+
[0.1.0]: https://github.com/CabalSpy/cabalspy-id-js/releases/tag/v0.1.0
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 CabalSpy
|
|
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
CHANGED
|
@@ -1,3 +1,475 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
# CabalSpy ID — SocialFi API & SDK
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/cabalspy-id) [](https://github.com/CabalSpy/cabalspy-id-js/actions/workflows/ci.yml) [](https://www.npmjs.com/package/cabalspy-id) [](LICENSE)
|
|
4
|
+
|
|
5
|
+
Official TypeScript SDK and React SocialFi widget for [CabalSpy ID](https://id.cabalspy.xyz). **CabalSpy ID is the SocialFi API for crypto apps**: one SocialFi integration gives your platform login with X, wallets verified by a tiny on-chain payment (no wallet connect, no signatures), reviewed KOL badges, live trades and PnL of your users and a drop-in SocialFi widget for token theses — on **Solana, BNB Chain, Base, Ethereum and Robinhood Chain**.
|
|
6
|
+
|
|
7
|
+
Your platform adds "Login with CabalSpy ID" and receives the user's X profile, verified wallets, KOL badge and full trading stats — PnL, win rate, trades, holdings — for copy trading, leaderboards and social features.
|
|
8
|
+
|
|
9
|
+
[Website](https://www.cabalspy.xyz/cabalspy-id/) · [Docs](https://docs.cabalspy.xyz/cabalspy-id) · [Sign in](https://id.cabalspy.xyz) · [API dashboard](https://apidashboard.cabalspy.xyz)
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install cabalspy-id
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
One package, everything you need:
|
|
16
|
+
|
|
17
|
+
| | |
|
|
18
|
+
|---|---|
|
|
19
|
+
| `CabalSpyIDAuth` | OpenID Connect for your server: PKCE, code exchange, refresh, revoke, userinfo, ID token verification (ES256 / JWKS) |
|
|
20
|
+
| `cabalspy-id/react` | `<CabalSpyLogin />` button, `<CabalSpyTheses />` widget and `useCabalSpyID()` hook |
|
|
21
|
+
| `ThesisClient` | public token thesis API for your own UI in the browser (user access token) with `live()` updates |
|
|
22
|
+
| `CabalSpyID` | Data API client for `https://api-id.cabalspy.xyz/v1`, typed responses, pagination, live trade stream |
|
|
23
|
+
| `verifyWebhook` | Standard Webhooks signature verification |
|
|
24
|
+
|
|
25
|
+
Zero runtime dependencies: crypto runs on WebCrypto. Works in Node 18+, browsers, Deno, Bun and edge runtimes. ESM and CommonJS.
|
|
26
|
+
|
|
27
|
+
Everything for developers — instance (client_id), client secrets, redirect URIs, button builder, webhooks, API keys — lives in the [API dashboard](https://apidashboard.cabalspy.xyz), tab **CabalSpy ID**.
|
|
28
|
+
|
|
29
|
+
## What can you build
|
|
30
|
+
|
|
31
|
+
- **Social trading feed** — every trade of your users live, with their X profile and PnL
|
|
32
|
+
- **Leaderboards** — rank your users by PnL, volume, win rate or trades
|
|
33
|
+
- **Copy trading** — follow verified wallets of real, identified traders
|
|
34
|
+
- **Token theses** — holders-only opinions on a token with the author's real position, as a SocialFi widget or your own UI
|
|
35
|
+
- **Trader profiles** — X profile, verified wallets, holdings, PnL calendar
|
|
36
|
+
- **KOL badges** — reviewed badges for influential traders, shown wherever they sign in
|
|
37
|
+
|
|
38
|
+
## Packages
|
|
39
|
+
|
|
40
|
+
One codebase, one version line. The focused packages re-export parts of `cabalspy-id`, so they always behave exactly the same.
|
|
41
|
+
|
|
42
|
+
| Package | npm | PyPI | What it contains |
|
|
43
|
+
|---|---|---|---|
|
|
44
|
+
| **cabalspy-id** | [`cabalspy-id`](https://www.npmjs.com/package/cabalspy-id) | [`cabalspy-id`](https://pypi.org/project/cabalspy-id/) | everything below |
|
|
45
|
+
| **socialfi-api** ([repo](https://github.com/CabalSpy/socialfi-api)) | [`socialfi-api`](https://www.npmjs.com/package/socialfi-api) | [`socialfi-api`](https://pypi.org/project/socialfi-api/) | the SocialFi API: Data API, Login with CabalSpy ID, trade stream, webhooks (= `cabalspy-id/api`, `cabalspy_id.api`) |
|
|
46
|
+
| **socialfi-thesis** ([repo](https://github.com/CabalSpy/socialfi-thesis)) | [`socialfi-thesis`](https://www.npmjs.com/package/socialfi-thesis) | [`socialfi-thesis`](https://pypi.org/project/socialfi-thesis/) | token theses: Data API thesis methods, public thesis client, theses stream (= `cabalspy-id/thesis`, `cabalspy_id.thesis`) |
|
|
47
|
+
| **socialfi-widget** ([repo](https://github.com/CabalSpy/socialfi-widget)) | [`socialfi-widget`](https://www.npmjs.com/package/socialfi-widget) | – | the browser SocialFi widgets: login button and theses widget, vanilla and React (= `cabalspy-id/widget`) |
|
|
48
|
+
|
|
49
|
+
### Entry points
|
|
50
|
+
|
|
51
|
+
| Import | Contents |
|
|
52
|
+
|---|---|
|
|
53
|
+
| `cabalspy-id` | everything |
|
|
54
|
+
| `cabalspy-id/api` | `CabalSpyID`, `CabalSpyIDStream`, `CabalSpyIDAuth`, `verifyWebhook`, errors and Data API types |
|
|
55
|
+
| `cabalspy-id/thesis` | `CabalSpyID` (thesis methods), `ThesisClient`, `ThesisLive`, `ThesesStream`, thesis types |
|
|
56
|
+
| `cabalspy-id/widget` | browser only: `mountLoginButton`, `mountTheses`, `setThesisAccessToken`, `startLogin`, `onWidgetEvents`, `loadCabalSpyIDWidget` |
|
|
57
|
+
| `cabalspy-id/react` (= `cabalspy-id/widget/react`) | `<CabalSpyLogin />`, `<CabalSpyTheses />`, `useCabalSpyID()` |
|
|
58
|
+
|
|
59
|
+
Classes are shared between entry points (`instanceof` works across them, ESM and CommonJS).
|
|
60
|
+
|
|
61
|
+
```ts
|
|
62
|
+
import { mountLoginButton, mountTheses } from 'cabalspy-id/widget';
|
|
63
|
+
|
|
64
|
+
mountLoginButton('#login', { clientId: 'csid_...', shape: 'pill', onLogin: ({ idToken }) => sendToBackend(idToken) });
|
|
65
|
+
const theses = mountTheses('#theses', { chain: 'solana', mint, clientId: 'csid_...', theme: 'dark', compact: true });
|
|
66
|
+
theses.update({ theme: 'light' });
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## Login button
|
|
70
|
+
|
|
71
|
+
Plain HTML, no build step:
|
|
72
|
+
|
|
73
|
+
```html
|
|
74
|
+
<div data-csid-login data-client-id="csid_..."></div>
|
|
75
|
+
<script src="https://id.cabalspy.xyz/widget.js" async></script>
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
React:
|
|
79
|
+
|
|
80
|
+
```tsx
|
|
81
|
+
import { CabalSpyLogin, useCabalSpyID } from 'cabalspy-id/react';
|
|
82
|
+
|
|
83
|
+
export function Header() {
|
|
84
|
+
const { user, limited } = useCabalSpyID({ clientId: 'csid_...' });
|
|
85
|
+
return (
|
|
86
|
+
<CabalSpyLogin
|
|
87
|
+
clientId="csid_..."
|
|
88
|
+
scope={['openid', 'profile', 'wallets']}
|
|
89
|
+
theme="dark"
|
|
90
|
+
shape="pill"
|
|
91
|
+
onLogin={({ idToken }) => fetch('/api/session', { method: 'POST', body: JSON.stringify({ idToken }) })}
|
|
92
|
+
onLogout={() => fetch('/api/session', { method: 'DELETE' })}
|
|
93
|
+
/>
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
`<CabalSpyLogin>` loads `widget.js` once and maps its props to the widget's `data-*` attributes:
|
|
99
|
+
|
|
100
|
+
| Prop | Attribute | |
|
|
101
|
+
|---|---|---|
|
|
102
|
+
| `clientId` | `data-client-id` | your instance's client_id (required) |
|
|
103
|
+
| `theme`, `color`, `textColor`, `shape`, `size`, `label`, `fullWidth`, `showLogo` | `data-theme` … `data-show-logo` | override the design from the dashboard's button builder |
|
|
104
|
+
| `href` | `data-href` | **server apps:** your login route (you run the OIDC flow with your secret) |
|
|
105
|
+
| `redirectUri`, `scope` | `data-redirect-uri`, `data-scope` | **browser apps:** the widget runs PKCE itself |
|
|
106
|
+
| `user`, `logoutHref` | `data-user`, `data-logout-href` | **server apps:** show the signed-in person's avatar menu |
|
|
107
|
+
| `onLogin`, `onLogout`, `onError` | events `csid:login`, `csid:logout`, `csid:error` | |
|
|
108
|
+
|
|
109
|
+
Browser apps (public clients) get `{ user, idToken, accessToken, expiresIn }` in `onLogin`. **Always send `idToken` to your backend and verify it there** before you trust it:
|
|
110
|
+
|
|
111
|
+
```ts
|
|
112
|
+
import { CabalSpyIDAuth } from 'cabalspy-id';
|
|
113
|
+
|
|
114
|
+
const auth = new CabalSpyIDAuth({ clientId: 'csid_...' });
|
|
115
|
+
const claims = await auth.verifyIdToken(idToken); // ES256 via JWKS: iss, aud, azp, exp
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
`useCabalSpyID({ clientId })` returns `{ user, idToken, accessToken, limited, ready, login(), signOut() }`.
|
|
119
|
+
|
|
120
|
+
## Server-side login (OpenID Connect)
|
|
121
|
+
|
|
122
|
+
Authorization code flow with PKCE S256 (required for every client), state and nonce.
|
|
123
|
+
|
|
124
|
+
```ts
|
|
125
|
+
import { CabalSpyIDAuth, isLimited } from 'cabalspy-id';
|
|
126
|
+
|
|
127
|
+
const auth = new CabalSpyIDAuth({
|
|
128
|
+
clientId: process.env.CSID_CLIENT_ID!, // csid_...
|
|
129
|
+
clientSecret: process.env.CSID_CLIENT_SECRET, // csid_sk_... (omit for public clients)
|
|
130
|
+
redirectUri: 'https://your.app/callback', // registered in the dashboard
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
// GET /login
|
|
134
|
+
const login = await auth.createAuthorizationUrl({ scope: ['openid', 'profile', 'wallets', 'offline_access'] });
|
|
135
|
+
// keep login.state, login.nonce and login.codeVerifier (session or signed http-only cookie)
|
|
136
|
+
redirect(login.url);
|
|
137
|
+
|
|
138
|
+
// GET /callback
|
|
139
|
+
const { tokens, claims } = await auth.handleCallback(request.url, stored);
|
|
140
|
+
// checks error, state and iss, exchanges the code, verifies the ID token and its nonce
|
|
141
|
+
|
|
142
|
+
if (isLimited(claims)) {
|
|
143
|
+
// over your plan's user limit: anonymous sub "anon_...", no profile or wallet data
|
|
144
|
+
} else {
|
|
145
|
+
const user = await auth.userinfo(tokens.access_token); // x profile, wallets, onchain
|
|
146
|
+
}
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
| Method | |
|
|
150
|
+
|---|---|
|
|
151
|
+
| `discover()` | the discovery document (cached) |
|
|
152
|
+
| `createAuthorizationUrl({ scope?, prompt?, redirectUri?, state?, nonce? })` | returns `{ url, state, nonce, codeVerifier, redirectUri }` |
|
|
153
|
+
| `handleCallback(url, { state, nonce, codeVerifier })` | full callback handling, returns `{ tokens, claims }` |
|
|
154
|
+
| `exchangeCode({ code, codeVerifier, redirectUri? })` | `POST /oauth/token`, authorization_code |
|
|
155
|
+
| `refresh(refreshToken)` | `POST /oauth/token`, refresh_token. Tokens rotate: store the new one; reusing an old one revokes the chain |
|
|
156
|
+
| `revoke(token)` | `POST /oauth/revoke` |
|
|
157
|
+
| `userinfo(accessToken)` | `GET /oauth/userinfo` |
|
|
158
|
+
| `verifyIdToken(idToken, { nonce?, maxAge? })` | ES256 signature via JWKS, iss, aud, azp, exp, nonce |
|
|
159
|
+
| `verifyAccessToken(accessToken)` | for access tokens your frontend sends to your API (`typ: at+jwt`) |
|
|
160
|
+
|
|
161
|
+
Scopes: `openid` `profile` `wallets` `onchain` `thesis` `offline_access` (`thesis`: post theses and replies, react and report in the user's name). Client authentication: `client_secret_basic` (default with a secret), `client_secret_post`, `none` (public clients). Access and ID tokens live 15 minutes; refresh tokens 30 days of inactivity, 90 days absolute.
|
|
162
|
+
|
|
163
|
+
**Users over the plan's limit can always sign in.** Their token carries an anonymous `sub` (`anon_...`), `limited: true` and `reason: "plan_user_limit"`, and no profile or wallet data, until the platform upgrades. `isLimited(claims)` checks both.
|
|
164
|
+
|
|
165
|
+
A runnable server is in [examples/login-server.mjs](examples/login-server.mjs).
|
|
166
|
+
|
|
167
|
+
## Users without X
|
|
168
|
+
|
|
169
|
+
People can sign in to CabalSpy ID with **X, Telegram or Google**. Accounts without X can do everything except earn the KOL badge, and connecting X later fills in their profile. For them:
|
|
170
|
+
|
|
171
|
+
| Field | With X | Without X |
|
|
172
|
+
|---|---|---|
|
|
173
|
+
| `preferred_username` (claims) / `username` | X handle, e.g. `alice` | `tg.<telegram name>` (Telegram) or `id.<hex>` (Google) — always contains a dot |
|
|
174
|
+
| `x` (userinfo, `/v1/profile`) | X profile / stats | `null` |
|
|
175
|
+
| `twitter` (profiles, trading profile blocks, leaderboards) | `https://x.com/<handle>` | `null` |
|
|
176
|
+
| `telegram` (profiles, trading profile blocks, leaderboards) | `https://t.me/<name>` or `""` | `https://t.me/<name>` or `""` |
|
|
177
|
+
| `name`, `picture` / `image_url` | from X | from Telegram or Google |
|
|
178
|
+
|
|
179
|
+
`profile_url` (`https://id.cabalspy.xyz/u/<handle>`) works for everyone. Thesis authors use the same handles.
|
|
180
|
+
|
|
181
|
+
```ts
|
|
182
|
+
import { hasX, handleKind } from 'cabalspy-id';
|
|
183
|
+
|
|
184
|
+
hasX(claims); // false for Telegram/Google sign-ins
|
|
185
|
+
handleKind('tg.alice'); // 'telegram'
|
|
186
|
+
const xLink = profile.twitter ?? null; // never build x.com links from tg./id. handles
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
## Data API
|
|
190
|
+
|
|
191
|
+
```ts
|
|
192
|
+
import { CabalSpyID } from 'cabalspy-id';
|
|
193
|
+
|
|
194
|
+
const csid = new CabalSpyID({ apiKey: process.env.CABALSPY_API_KEY });
|
|
195
|
+
|
|
196
|
+
const me = await csid.me(); // instance, plan, rate limit, users with data
|
|
197
|
+
|
|
198
|
+
// The person who just signed in: look them up by the `sub` of their ID token
|
|
199
|
+
const profile = await csid.profile({ csid_id: claims.sub });
|
|
200
|
+
const wallet = profile.wallets.find((w) => w.chains.includes('solana'))!;
|
|
201
|
+
|
|
202
|
+
// Full trading profile for a period, same numbers as the CabalSpy API
|
|
203
|
+
const t = await csid.tracker({ blockchain: 'solana', address: wallet.address, period: '7d' });
|
|
204
|
+
console.log(t.period_stats.realized_pnl_usd, t.period_win_rate_distribution.win_rate_percentage);
|
|
205
|
+
|
|
206
|
+
// Your users ranked by PnL
|
|
207
|
+
const board = await csid.leaderboard({ blockchain: 'solana', period: '7d', sort: 'pnl_usd', limit: 25 });
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
The API key is the **same key as the CabalSpy API**, with the per-key toggle "CabalSpy ID" enabled on the API keys page. A key sees **its instance only**: users that signed in to its apps, within the plan's user limit. `scope: 'global'` (every CabalSpy ID user) is Enterprise only.
|
|
211
|
+
|
|
212
|
+
| Method | Endpoint |
|
|
213
|
+
|---|---|
|
|
214
|
+
| `health()` | `GET /v1/health` (no key needed) |
|
|
215
|
+
| `me()` | `GET /v1/me` |
|
|
216
|
+
| `users({ limit?, kol?, cursor?, scope? })` | `GET /v1/users` |
|
|
217
|
+
| `profile({ username } \| { csid_id } \| { address })` | `GET /v1/profile` |
|
|
218
|
+
| `walletLookup(address)` | `GET /v1/wallets/lookup` |
|
|
219
|
+
| `tracker({ blockchain, address, period? })` | `GET /v1/wallets/tracker` |
|
|
220
|
+
| `history({ blockchain, address, limit?, cursor? })` | `GET /v1/wallets/history` |
|
|
221
|
+
| `holdings({ blockchain, address })` | `GET /v1/wallets/holdings` |
|
|
222
|
+
| `pnlCalendar({ blockchain, address })` | `GET /v1/wallets/pnl_calendar` |
|
|
223
|
+
| `leaderboard({ blockchain, period?, sort?, limit?, cursor?, scope? })` | `GET /v1/wallets/leaderboard` |
|
|
224
|
+
| `latestTransactions({ blockchain?, limit? })` | `GET /v1/transactions/latest` |
|
|
225
|
+
|
|
226
|
+
Chains: `solana`, `bnb`, `base`, `eth`, `rh`. Periods: `6h`, `1d`, `7d`, `30d`. Leaderboard sorts: `volume`, `pnl`, `pnl_usd`, `win_rate`, `trades`. Every response is fully typed.
|
|
227
|
+
|
|
228
|
+
If your account has several CabalSpy ID instances, pass `instance: 'csid_...'` (the client_id) to the constructor.
|
|
229
|
+
|
|
230
|
+
### Pagination
|
|
231
|
+
|
|
232
|
+
Async iterators follow `next_cursor` for you:
|
|
233
|
+
|
|
234
|
+
```ts
|
|
235
|
+
for await (const user of csid.iterUsers({ kol: true })) console.log(user.username);
|
|
236
|
+
for await (const trade of csid.iterHistory({ blockchain: 'solana', address })) console.log(trade.tx_signature);
|
|
237
|
+
for await (const entry of csid.iterLeaderboard({ blockchain: 'base', period: '30d' })) console.log(entry.rank);
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
For whole pages with metadata, use the `*Raw` methods (`usersRaw`, `historyRaw`, `leaderboardRaw`) with `csid.pages()`.
|
|
241
|
+
|
|
242
|
+
### Errors
|
|
243
|
+
|
|
244
|
+
Every failure is a typed subclass of `CabalSpyIDError` carrying `.code`, `.status`, `.requestId`, `.docs` (a link to the error's documentation), and for validation errors `.parameter` and `.allowed`.
|
|
245
|
+
|
|
246
|
+
```ts
|
|
247
|
+
import { NotFoundError, PlanUserLimitError, RateLimitError } from 'cabalspy-id';
|
|
248
|
+
|
|
249
|
+
try {
|
|
250
|
+
await csid.profile({ csid_id: claims.sub });
|
|
251
|
+
} catch (err) {
|
|
252
|
+
if (err instanceof PlanUserLimitError) return showUpgradeNotice(); // anon_ sub: no data until you upgrade
|
|
253
|
+
if (err instanceof NotFoundError) return null; // not one of your users
|
|
254
|
+
if (err instanceof RateLimitError) console.log(err.retryAfter);
|
|
255
|
+
throw err;
|
|
256
|
+
}
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
| Class | Status | Codes |
|
|
260
|
+
|---|---|---|
|
|
261
|
+
| `BadRequestError` | 400 | `missing_parameter`, `invalid_parameter`, `instance_required` |
|
|
262
|
+
| `AuthenticationError` | 401 | `missing_api_key` |
|
|
263
|
+
| `PermissionError` | 403 | `invalid_api_key`, `product_not_enabled`, `no_instance`, `scope_not_allowed` |
|
|
264
|
+
| `PlanUserLimitError` | 403 | `plan_user_limit` |
|
|
265
|
+
| `NotFoundError` | 404 | `profile_not_found`, `wallet_not_found`, `instance_not_found` |
|
|
266
|
+
| `RateLimitError` | 429 | `rate_limit_exceeded` |
|
|
267
|
+
| `ServerError` | 5xx | `internal_error`, `service_unavailable` |
|
|
268
|
+
| `ConnectionError` | – | network failure, timeout |
|
|
269
|
+
| `OAuthError` | 4xx | OAuth errors from the login endpoints (`invalid_grant`, `invalid_client`, …) |
|
|
270
|
+
| `TokenVerificationError` | – | ID / access token failed verification |
|
|
271
|
+
| `WebhookVerificationError` | – | webhook signature or timestamp invalid |
|
|
272
|
+
|
|
273
|
+
`429`, `5xx` and network errors are retried with exponential backoff (default 2 retries); `Retry-After` wins. The rate limit of the last call is in `csid.lastRateLimit` (`X-RateLimit-Limit/Remaining/Reset`).
|
|
274
|
+
|
|
275
|
+
## Token theses
|
|
276
|
+
|
|
277
|
+
A thesis is a short opinion on a token (up to 1000 characters), optionally tagged bull or bear. **Only holders post theses**: one of the author's verified wallets bought the token and still holds it. Every thesis shows the author's real position — what they bought when posting and their live PnL now (or "sold"); authors who keep their trading private show only that they hold. Anyone signed in can reply and react (`like` plus 🔥 🚀 💎 👀 😂 🤝 💀 🐂 🐻). The same theses appear in the widget, through the Data API and on every platform.
|
|
278
|
+
|
|
279
|
+
Writing needs the scope **`thesis`** in your login (`scope: ['openid', 'profile', 'thesis']`).
|
|
280
|
+
|
|
281
|
+
**Scope of reads.** Theses are shared across platforms. Every read (Data API `listTheses`, `thesisSummary`, `latestTheses`; `ThesisClient`; the widget; the live sockets) takes `scope`: `global` (default, every platform) or `instance` (only theses written on your instance). In the Data API your key decides the instance; the public API and widget need your `clientId`.
|
|
282
|
+
|
|
283
|
+
### Widget
|
|
284
|
+
|
|
285
|
+
```tsx
|
|
286
|
+
import { CabalSpyTheses, useCabalSpyID } from 'cabalspy-id/react';
|
|
287
|
+
|
|
288
|
+
const { accessToken } = useCabalSpyID({ clientId: 'csid_...' });
|
|
289
|
+
<CabalSpyTheses chain="solana" mint={mint} clientId="csid_..." theme="dark" accessToken={accessToken} />
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
With `clientId` the widget loads the design saved in the dashboard and credits posts to your app. Every design setting can be overridden by a prop (mapped to the widget's `data-*` attribute): `theme`, `scope`, `sort`, `font`, `radius`, `bg`, `card`, `text`, `muted`, `border`, `accent`, `accentText`, `bull`, `bear`, `showHeader`, `showSentiment`, `compact`, `height`.
|
|
293
|
+
|
|
294
|
+
Plain HTML: `<div data-csid-thesis data-chain="solana" data-mint="..." data-client-id="csid_..." data-theme="dark"></div>` with `widget.js`; `CSID.thesis.setAccessToken(token)` lets the signed-in person write without signing in again inside the widget (after a browser login through the widget this happens automatically).
|
|
295
|
+
|
|
296
|
+
### Your own UI in the browser: `ThesisClient`
|
|
297
|
+
|
|
298
|
+
The public thesis API (`https://id.cabalspy.xyz/thesis/v1`) needs no API key. Reading is open; writing uses the signed-in user's access token (scope `thesis`).
|
|
299
|
+
|
|
300
|
+
```ts
|
|
301
|
+
import { ThesisClient } from 'cabalspy-id';
|
|
302
|
+
|
|
303
|
+
const theses = new ThesisClient({ accessToken, clientId: 'csid_...' }); // token from csid:login / useCabalSpyID()
|
|
304
|
+
// add scope: 'instance' to show only theses written on your platform
|
|
305
|
+
|
|
306
|
+
const { items, token, summary } = await theses.list('solana', mint, { sort: 'top' });
|
|
307
|
+
const me = await theses.me('solana', mint); // { can_post, can_reply, holder, paused, user }
|
|
308
|
+
if (me.can_post) await theses.post('solana', mint, { body: 'Strong community, still early.', stance: 'bull' });
|
|
309
|
+
await theses.reply(items[0].id, 'Agree, chart looks good');
|
|
310
|
+
await theses.react(items[0].id, '🚀');
|
|
311
|
+
|
|
312
|
+
const live = theses.live('solana', mint); // public websocket for one token (also takes { scope, clientId })
|
|
313
|
+
live.on('thesis', (t) => prepend(t)).on('reply', addReply).on('reaction', updateCounts).on('removed', ({ id }) => drop(id));
|
|
314
|
+
await live.connect();
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
Methods: `list`, `iterate`, `summary`, `get`, `replies`, `byUser`, `me`, `post`, `reply`, `react`, `report`, `delete`, `notifications`, `markNotificationsRead`, `appeal`, `live`, `setAccessToken`.
|
|
318
|
+
|
|
319
|
+
### Data API (server to server)
|
|
320
|
+
|
|
321
|
+
Reading works with any key, for every token and user. Writing happens **in the name of one of your users**: pass their `csid_id` (the `sub` of their ID token); they must have signed in to your app with the scope `thesis` and be within your plan's user limit.
|
|
322
|
+
|
|
323
|
+
```ts
|
|
324
|
+
const list = await csid.listTheses({ blockchain: 'solana', mint, sort: 'new' });
|
|
325
|
+
const counts = await csid.thesisSummary({ blockchain: 'solana', mint }); // theses, bull, bear, authors, token
|
|
326
|
+
|
|
327
|
+
const { can_post, reason } = await csid.thesisEligibility({ blockchain: 'solana', mint, csid_id: claims.sub });
|
|
328
|
+
if (can_post) {
|
|
329
|
+
const t = await csid.postThesis({ blockchain: 'solana', mint, body: 'Accumulating here.', stance: 'bull', csid_id: claims.sub });
|
|
330
|
+
}
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
| Method | Endpoint |
|
|
334
|
+
|---|---|
|
|
335
|
+
| `listTheses({ blockchain, mint, sort?, stance?, limit?, cursor?, csid_id? })` / `iterTheses()` | `GET /v1/theses` |
|
|
336
|
+
| `thesisSummary({ blockchain, mint })` | `GET /v1/theses/summary` |
|
|
337
|
+
| `thesis(id, { csid_id? })` | `GET /v1/theses/item` |
|
|
338
|
+
| `thesisReplies({ id, limit?, cursor? })` / `iterThesisReplies()` | `GET /v1/theses/replies` |
|
|
339
|
+
| `latestTheses({ blockchain?, users?: 'all' \| 'instance', limit?, cursor? })` | `GET /v1/theses/latest` |
|
|
340
|
+
| `userTheses({ csid_id } \| { username })` | `GET /v1/theses/user` |
|
|
341
|
+
| `thesisEligibility({ blockchain, mint, csid_id })` | `GET /v1/theses/eligibility` |
|
|
342
|
+
| `postThesis({ blockchain, mint, body, stance?, csid_id })` | `POST /v1/theses` |
|
|
343
|
+
| `replyToThesis({ thesis_id, body, csid_id })` | `POST /v1/theses/replies` |
|
|
344
|
+
| `reactToThesis({ thesis_id, emoji, on?, csid_id })` | `POST /v1/theses/reactions` |
|
|
345
|
+
| `reportThesis({ thesis_id, reason, note?, csid_id })` | `POST /v1/theses/report` |
|
|
346
|
+
| `deleteThesis({ thesis_id, csid_id })` | `POST /v1/theses/delete` |
|
|
347
|
+
|
|
348
|
+
| `thesisNotifications(csidId)` | `GET /v1/theses/notifications` |
|
|
349
|
+
| `appealThesisDecision(csidId, notificationId, message)` | `POST /v1/theses/appeal` |
|
|
350
|
+
|
|
351
|
+
Every thesis carries `reacted_by` (the latest reactions with who reacted) and, for theses, `latest_replies` (a preview of the newest replies).
|
|
352
|
+
|
|
353
|
+
**Moderation.** Posts hidden after reports, pauses and moderator decisions reach the author as notifications (`{ id, kind, text, data, created_at, read, appealable, appeal }`); `appealable` ones can be appealed within 30 days with 10-1000 characters. Through the Data API in your user's name: `thesisNotifications(csidId)` / `appealThesisDecision(...)`; in the browser: `ThesisClient.notifications()`, `markNotificationsRead()`, `appeal(id, message)`. `ThesisClient.me()` also returns `notices: { unread, latest, url }` so your UI can show a badge.
|
|
354
|
+
|
|
355
|
+
Thesis error codes: `not_a_holder`, `consent_required`, `scope_missing`, `plan_user_limit` (`PlanUserLimitError`), `posting_paused`, `reporting_paused`, `sandbox_user` (403, `PermissionError`); `invalid_body`, `duplicate` (400); `not_found` (404); `rate_limited` (429). Writes are never retried after a server or network error, so a post can't be duplicated; only the API's own rate limit is retried.
|
|
356
|
+
|
|
357
|
+
### Theses stream (every plan)
|
|
358
|
+
|
|
359
|
+
Live theses for the tokens you choose, e.g. to put markers on a chart. Up to 200 tokens per connection (or all), available on every plan; subscriptions are sent again after every reconnect.
|
|
360
|
+
|
|
361
|
+
```ts
|
|
362
|
+
const ts = csid.thesesStream({ scope: 'global' }); // or 'instance'
|
|
363
|
+
ts.on('thesis', (t) => addMarker(t.blockchain, t.mint, t));
|
|
364
|
+
ts.on('thesis.removed', ({ id }) => removeMarker(id));
|
|
365
|
+
await ts.connect(); // resolves on `ready`
|
|
366
|
+
ts.subscribe([{ blockchain: 'solana', mint: MINT_A }, { blockchain: 'base', mint: TOKEN_B }]);
|
|
367
|
+
ts.unsubscribe([{ blockchain: 'base', mint: TOKEN_B }]);
|
|
368
|
+
// ts.subscribeAll() / ts.unsubscribeAll()
|
|
369
|
+
|
|
370
|
+
for await (const { event, data } of csid.thesesStream()) { … } // or iterate
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
Events: `ready`, `subscribed`, `thesis`, `thesis.reply`, `thesis.reaction`, `thesis.removed`, `heartbeat`, `reconnecting`, `close`, `error`. A refused connection (`invalid_api_key`, …) is fatal; a bad frame (`too_many_tokens`, an invalid address) is reported as `error` and the connection stays.
|
|
374
|
+
|
|
375
|
+
Also over the trade stream (Pro plan): `csid.stream({ events: ['theses'], blockchain: 'solana', mint })` emits `thesis`, `thesis.reply`, `thesis.reaction` and `thesis.removed` (or iterate `stream.theses()`). Your users' activity also arrives as webhooks: `thesis.created` (`event.data.thesis`), `thesis.reply` (`event.data.reply`) and `thesis.reaction` (`event.data`: `thesis_id`, `chain`, `mint`, `emoji`, `on`, `reactions`).
|
|
376
|
+
|
|
377
|
+
## Live stream
|
|
378
|
+
|
|
379
|
+
Every trade of your users the moment it is indexed, with the trader's profile (Pro plan and up).
|
|
380
|
+
|
|
381
|
+
```ts
|
|
382
|
+
const stream = csid.stream({ blockchain: 'solana' }); // omit blockchain for every chain
|
|
383
|
+
// events: ['trades'] (default), ['theses'] or both; mint: theses of one token
|
|
384
|
+
|
|
385
|
+
stream.on('trade', (t) => console.log(t.trader?.username, t.transaction_type, t.token_symbol, t.value_usd));
|
|
386
|
+
stream.on('error', (e) => console.error(e.code, e.message));
|
|
387
|
+
await stream.connect(); // resolves once the server confirmed the subscription
|
|
388
|
+
|
|
389
|
+
// or
|
|
390
|
+
for await (const trade of csid.stream()) console.log(trade);
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
The server sends a heartbeat every 30 seconds. The client reconnects with exponential backoff after a dropped connection or when heartbeats stop; configuration errors (`invalid_api_key`, `plan_required`, `scope_not_allowed`) are fatal and stop reconnecting. Events: `trade`, `thesis`, `thesis.reply`, `thesis.reaction`, `thesis.removed`, `subscribed`, `heartbeat`, `open`, `close`, `reconnecting`, `error`.
|
|
394
|
+
|
|
395
|
+
Browsers, Deno, Bun and Node 22+ have a global `WebSocket`. On Node 18–21 install `ws` and pass it:
|
|
396
|
+
|
|
397
|
+
```ts
|
|
398
|
+
import { WebSocket } from 'ws';
|
|
399
|
+
const stream = csid.stream({ WebSocketImpl: WebSocket });
|
|
400
|
+
```
|
|
401
|
+
|
|
402
|
+
## Webhooks
|
|
403
|
+
|
|
404
|
+
Deliveries follow the [Standard Webhooks](https://www.standardwebhooks.com) spec (`webhook-id`, `webhook-timestamp`, `webhook-signature`, secret `whsec_...`) and are retried for about 2 days. Events: `wallet.verified`, `wallet.removed`, `profile.updated`, `kol.granted`, `consent.revoked`, `thesis.created`, `thesis.reply`, `thesis.reaction` — only for users within the plan's limit.
|
|
405
|
+
|
|
406
|
+
```ts
|
|
407
|
+
import { verifyWebhook } from 'cabalspy-id';
|
|
408
|
+
|
|
409
|
+
// pass the RAW body, exactly as received
|
|
410
|
+
const event = await verifyWebhook({ payload: rawBody, headers: req.headers, secret: process.env.CSID_WEBHOOK_SECRET! });
|
|
411
|
+
|
|
412
|
+
switch (event.type) {
|
|
413
|
+
case 'wallet.verified': /* event.data.sub, … */ break;
|
|
414
|
+
case 'consent.revoked': /* delete the user's data */ break;
|
|
415
|
+
}
|
|
416
|
+
```
|
|
417
|
+
|
|
418
|
+
Timestamps older than 5 minutes are rejected (`toleranceSeconds`). During a secret roll several signatures are sent; any match is accepted. Dedupe on `event.id`, it is the same on every retry. `signWebhook()` builds test requests for your receiver.
|
|
419
|
+
|
|
420
|
+
## Configuration
|
|
421
|
+
|
|
422
|
+
```ts
|
|
423
|
+
new CabalSpyID({
|
|
424
|
+
apiKey: process.env.CABALSPY_API_KEY, // env fallback: CABALSPY_ID_API_KEY, then CABALSPY_API_KEY
|
|
425
|
+
instance: undefined, // client_id, when the account has several instances
|
|
426
|
+
baseUrl: 'https://api-id.cabalspy.xyz/v1',
|
|
427
|
+
streamUrl: 'wss://api-id.cabalspy.xyz/v1/stream',
|
|
428
|
+
timeout: 30_000,
|
|
429
|
+
maxRetries: 2,
|
|
430
|
+
headers: {},
|
|
431
|
+
fetch: undefined, // custom fetch (proxies, tests)
|
|
432
|
+
});
|
|
433
|
+
|
|
434
|
+
new CabalSpyIDAuth({
|
|
435
|
+
clientId: 'csid_...',
|
|
436
|
+
clientSecret: undefined, // csid_sk_..., server apps only
|
|
437
|
+
redirectUri: undefined,
|
|
438
|
+
issuer: 'https://id.cabalspy.xyz',
|
|
439
|
+
tokenEndpointAuthMethod: undefined, // client_secret_basic | client_secret_post | none
|
|
440
|
+
clockTolerance: 60,
|
|
441
|
+
timeout: 15_000,
|
|
442
|
+
fetch: undefined,
|
|
443
|
+
});
|
|
444
|
+
```
|
|
445
|
+
|
|
446
|
+
Never ship the API key or the client secret to a browser. The Data API key and `CabalSpyIDAuth` with a secret belong on your server.
|
|
447
|
+
|
|
448
|
+
## Pricing
|
|
449
|
+
|
|
450
|
+
Per month and registrable domain. Everyone can always sign in; above the limit the platform receives no data for the extra users until it upgrades.
|
|
451
|
+
|
|
452
|
+
| Plan | Price / month | Users with data | API rate | |
|
|
453
|
+
|---|---|---|---|---|
|
|
454
|
+
| Free | $0 | 50 | 1 req/s | |
|
|
455
|
+
| Starter | $49 | 200 | 5 req/s | |
|
|
456
|
+
| Pro | $149 | 500 | 10 req/s | + live stream |
|
|
457
|
+
| Business | $499 | 1,000 | 25 req/s | |
|
|
458
|
+
| Enterprise | custom | unlimited | custom + SLA | `scope=global` |
|
|
459
|
+
|
|
460
|
+
Yearly billing is 20% off. Card or crypto at [apidashboard.cabalspy.xyz/billing/csid](https://apidashboard.cabalspy.xyz/billing/csid).
|
|
461
|
+
|
|
462
|
+
## Docs
|
|
463
|
+
|
|
464
|
+
[docs.cabalspy.xyz/cabalspy-id](https://docs.cabalspy.xyz/cabalspy-id) · Discovery: [id.cabalspy.xyz/.well-known/openid-configuration](https://id.cabalspy.xyz/.well-known/openid-configuration)
|
|
465
|
+
|
|
466
|
+
## Related
|
|
467
|
+
|
|
468
|
+
- [CabalSpy ID](https://id.cabalspy.xyz) · [leaderboard](https://id.cabalspy.xyz/leaderboard) · [API dashboard](https://apidashboard.cabalspy.xyz)
|
|
469
|
+
- CabalSpy ID SDKs: [TypeScript](https://www.npmjs.com/package/cabalspy-id) · [Python](https://pypi.org/project/cabalspy-id/)
|
|
470
|
+
- CabalSpy API SDKs (KOL and smart money wallet tracking): [TypeScript](https://www.npmjs.com/package/cabalspy) · [Python](https://pypi.org/project/cabalspy/) · [Rust](https://crates.io/crates/cabalspy)
|
|
471
|
+
- [SDK overview](https://www.cabalspy.xyz/sdks/) · [MCP server](https://www.cabalspy.xyz/mcp/) · [CabalSpy Terminal](https://app.cabalspy.xyz/)
|
|
472
|
+
|
|
473
|
+
## License
|
|
474
|
+
|
|
475
|
+
MIT
|