@codex-data/sdk 2.0.1 → 2.0.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 CHANGED
@@ -1,261 +1,460 @@
1
1
  # Codex SDK
2
2
 
3
- This package exists to help you develop on top of the Codex API (https://docs.codex.io).
3
+ The TypeScript SDK for the [Codex API](https://www.codex.io) — real-time blockchain data, token prices, OHLCV charts, wallet balances, and holder analytics for 60M+ tokens across 80+ networks including Ethereum, Solana, Base, Arbitrum, BSC, and Polygon.
4
4
 
5
- It provides generated TypeScript types and convenient methods to access the GraphQL API with full type safety.
5
+ Codex is a GraphQL API used by teams like Coinbase, TradingView, Uniswap, Rainbow, FOMO, Farcaster, and hundreds of others.
6
6
 
7
- > [!NOTE]
8
- > We've changed our name from Defined to Codex.
9
- >
10
- > You will see references to our previous company name, Defined, while we make the switch to Codex.
7
+ - **[Documentation](https://docs.codex.io)**
8
+ - **[Get an API Key](https://dashboard.codex.io)**
9
+ - **[GraphQL Explorer](https://explorer.codex.io)**
11
10
 
12
- ## Features
11
+ ## Installation
13
12
 
14
- - 🚀 **Fully Typed**: Generated TypeScript types for all GraphQL operations
15
- - 📦 **Tree Shakeable**: ESM support with optimized bundle size
16
- - 🔄 **Real-time**: WebSocket subscriptions support
17
- - 🛠 **Developer Friendly**: Comprehensive examples and documentation
13
+ ```bash
14
+ npm install @codex-data/sdk
15
+ ```
18
16
 
19
- ## Installation
17
+ ```bash
18
+ yarn add @codex-data/sdk
19
+ ```
20
+
21
+ ```bash
22
+ pnpm add @codex-data/sdk
23
+ ```
24
+
25
+ ## Quick Start
26
+
27
+ ```typescript
28
+ import { Codex } from "@codex-data/sdk";
20
29
 
21
- | Package Manager | Command |
22
- | ----------------------------- | ----------------------------- |
23
- | [npm](https://www.npmjs.com/) | `npm install @codex-data/sdk` |
24
- | [yarn](https://yarnpkg.com/) | `yarn add @codex-data/sdk` |
25
- | [pnpm](https://pnpm.io/) | `pnpm add @codex-data/sdk` |
30
+ const sdk = new Codex(process.env.CODEX_API_KEY!);
26
31
 
27
- ## Usage
32
+ const networks = await sdk.queries.getNetworks({});
33
+ console.log(networks.getNetworks); // [{ id: 1, name: "ethereum" }, { id: 1399811149, name: "solana" }, ...]
34
+ ```
28
35
 
29
- Follow one of the examples in the [examples](/examples) directory, or simply run.
36
+ ## Get Token Prices
30
37
 
31
- Fetch a token.
38
+ Get the current USD price of any token. Supports up to 25 tokens per request. Prices are liquidity-weighted across all valid pools.
32
39
 
33
40
  ```typescript
34
41
  import { Codex } from "@codex-data/sdk";
35
42
 
36
- const sdk = new Codex(MY_API_KEY);
43
+ const sdk = new Codex(process.env.CODEX_API_KEY!);
44
+
45
+ const prices = await sdk.queries.getTokenPrices({
46
+ inputs: [
47
+ { address: "So11111111111111111111111111111111111111112", networkId: 1399811149 }, // SOL
48
+ { address: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", networkId: 1 }, // WETH
49
+ ],
50
+ });
51
+
52
+ prices.getTokenPrices?.forEach((price) => {
53
+ console.log(`${price?.address}: $${price?.priceUsd}`);
54
+ });
55
+ ```
37
56
 
38
- sdk.queries
39
- .token({
40
- input: {
41
- address: "0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c",
42
- networkId: 56,
57
+ To get a historical price, pass a `timestamp`:
58
+
59
+ ```typescript
60
+ const historicalPrice = await sdk.queries.getTokenPrices({
61
+ inputs: [
62
+ {
63
+ address: "So11111111111111111111111111111111111111112",
64
+ networkId: 1399811149,
65
+ timestamp: 1704067200, // Unix timestamp
43
66
  },
44
- })
45
- .then(console.log);
67
+ ],
68
+ });
46
69
  ```
47
70
 
48
- Use your own GraphQL selections
71
+ ## Get OHLCV Chart Data
72
+
73
+ Get candlestick data for any token or trading pair. Supports resolutions from 1-second to 7-day.
49
74
 
50
75
  ```typescript
51
76
  import { Codex } from "@codex-data/sdk";
52
77
 
53
- const sdk = new Codex(process.env.CODEX_API_KEY || "");
54
-
55
- // Using the raw GraphQL client
56
- sdk
57
- .send<{ getNetworks: Array<{ id: string; name: string }> }>(
58
- `
59
- query GetNetworks {
60
- getNetworks { id name }
61
- }
62
- `,
63
- {},
64
- )
65
- .then((res) => {
66
- console.log("Networks: ", res.getNetworks);
78
+ const sdk = new Codex(process.env.CODEX_API_KEY!);
79
+
80
+ const bars = await sdk.queries.getBars({
81
+ symbol: "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2:1", // WETH on Ethereum
82
+ from: 1704067200,
83
+ to: 1704153600,
84
+ resolution: "60", // 1-hour candles
85
+ removeEmptyBars: true,
86
+ });
87
+
88
+ bars.getBars?.o?.forEach((open, i) => {
89
+ console.log({
90
+ open,
91
+ high: bars.getBars?.h?.[i],
92
+ low: bars.getBars?.l?.[i],
93
+ close: bars.getBars?.c?.[i],
94
+ volume: bars.getBars?.volume?.[i],
95
+ timestamp: bars.getBars?.t?.[i],
67
96
  });
97
+ });
68
98
  ```
69
99
 
70
- Subscribe to real-time data
100
+ Available resolutions: `1S`, `5S`, `15S`, `30S`, `1`, `5`, `15`, `30`, `60`, `240`, `720`, `1D`, `7D`
101
+
102
+ ## Discover and Filter Tokens
103
+
104
+ Search and filter tokens by price, volume, market cap, liquidity, holder count, trading activity, and more.
71
105
 
72
106
  ```typescript
73
- import { Codex } from "@codex-data/sdk";
107
+ import { Codex, TokenRankingAttribute, RankingDirection } from "@codex-data/sdk";
74
108
 
75
- const sdk = new Codex(process.env.CODEX_API_KEY || "");
109
+ const sdk = new Codex(process.env.CODEX_API_KEY!);
76
110
 
77
- // Subscribe to price updates
78
- sdk.subscriptions.onPriceUpdated(
79
- {
80
- address: "0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c",
81
- networkId: 56,
82
- },
83
- (result) => {
84
- if (result.data) {
85
- console.log("Price updated:", result.data.onPriceUpdated);
86
- }
111
+ const result = await sdk.queries.filterTokens({
112
+ filters: {
113
+ network: [1], // Ethereum
114
+ liquidity: { gte: "100000" }, // $100k+ liquidity
115
+ marketCap: { gte: "1000000" }, // $1M+ market cap
116
+ txnCount24: { gte: "500" }, // 500+ transactions in 24h
87
117
  },
88
- );
118
+ rankings: [
119
+ {
120
+ attribute: TokenRankingAttribute.TrendingScore24,
121
+ direction: RankingDirection.Desc,
122
+ },
123
+ ],
124
+ limit: 20,
125
+ });
126
+
127
+ result.filterTokens?.results?.forEach((token) => {
128
+ console.log(`${token?.token?.name} (${token?.token?.symbol}): $${token?.priceUSD}`);
129
+ });
89
130
  ```
90
131
 
91
- ## Development
132
+ ## Get Wallet Balances
92
133
 
93
- ### Prerequisites
134
+ Get all token balances for a wallet address with USD values.
94
135
 
95
- - [Node.js](https://nodejs.org/) >= 17.5.0
96
- - [pnpm](https://pnpm.io/) (recommended) or npm/yarn
97
- - [`curl`](https://curl.se/) for fetching the GraphQL schema
136
+ ```typescript
137
+ import { Codex } from "@codex-data/sdk";
98
138
 
99
- ### Building from Source
139
+ const sdk = new Codex(process.env.CODEX_API_KEY!);
100
140
 
101
- ```bash
102
- # Install dependencies
103
- pnpm install
141
+ const balances = await sdk.queries.balances({
142
+ input: {
143
+ walletAddress: "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045", // vitalik.eth
144
+ networks: [1],
145
+ includeNative: true,
146
+ removeScams: true,
147
+ limit: 50,
148
+ },
149
+ });
104
150
 
105
- # Build the SDK
106
- pnpm run build
151
+ balances.balances?.items?.forEach((item) => {
152
+ console.log(`${item?.token?.symbol}: ${item?.shiftedBalance} ($${item?.balanceUsd})`);
153
+ });
107
154
  ```
108
155
 
109
- ### Running Examples
156
+ ## Get Token Holders
110
157
 
111
- All examples require a Codex API key. Get your API key at [docs.codex.io](https://docs.codex.io).
158
+ Get the list of wallets holding a specific token, sorted by balance.
112
159
 
113
- #### Simple Example
160
+ ```typescript
161
+ import { Codex } from "@codex-data/sdk";
114
162
 
115
- Basic usage with inline GraphQL queries:
163
+ const sdk = new Codex(process.env.CODEX_API_KEY!);
116
164
 
117
- ```bash
118
- cd examples/simple
119
- pnpm install
120
- CODEX_API_KEY=your_api_key pnpm run dev
165
+ const holders = await sdk.queries.holders({
166
+ input: {
167
+ tokenId: "So11111111111111111111111111111111111111112:1399811149", // SOL
168
+ limit: 50,
169
+ },
170
+ });
171
+
172
+ console.log(`Total holders: ${holders.holders?.count}`);
173
+ console.log(`Top 10 hold: ${holders.holders?.top10HoldersPercent}%`);
174
+
175
+ holders.holders?.items?.forEach((holder) => {
176
+ console.log(`${holder?.address}: ${holder?.shiftedBalance} ($${holder?.balanceUsd})`);
177
+ });
121
178
  ```
122
179
 
123
- #### Codegen Example
180
+ ## Get Token Trade History
124
181
 
125
- Shows how to use GraphQL Code Generator for fully typed queries:
182
+ Get buy, sell, mint, and burn events for any token or pair.
126
183
 
127
- ```bash
128
- cd examples/codegen
129
- pnpm install
130
- pnpm run codegen
131
- CODEX_API_KEY=your_api_key pnpm run dev
132
- ```
184
+ ```typescript
185
+ import { Codex } from "@codex-data/sdk";
133
186
 
134
- #### Next.js Example
187
+ const sdk = new Codex(process.env.CODEX_API_KEY!);
135
188
 
136
- Full-stack example with a Next.js application:
189
+ const events = await sdk.queries.getTokenEvents({
190
+ query: {
191
+ address: "So11111111111111111111111111111111111111112",
192
+ networkId: 1399811149,
193
+ eventDisplayType: ["Buy", "Sell"],
194
+ },
195
+ limit: 25,
196
+ });
137
197
 
138
- ```bash
139
- cd examples/next
140
- pnpm install
141
- NEXT_PUBLIC_CODEX_API_KEY=your_api_key pnpm run dev
198
+ events.getTokenEvents?.items?.forEach((event) => {
199
+ console.log(`${event?.eventDisplayType} by ${event?.maker} — $${event?.token0SwapValueUsd}`);
200
+ });
142
201
  ```
143
202
 
144
- ## Package Structure
203
+ ## Stream Real-Time Prices
145
204
 
146
- The SDK is built with modern tooling and provides both CommonJS and ESM builds:
205
+ > **Note:** WebSocket subscriptions require a [paid plan](https://dashboard.codex.io/dashboard/billing).
147
206
 
148
- ```
149
- @codex-data/sdk/
150
- ├── dist/
151
- │ ├── index.js # CommonJS entry point
152
- │ ├── index.mjs # ESM entry point
153
- │ ├── index.d.ts # TypeScript definitions
154
- │ └── sdk/ # SDK implementation
155
- ├── README.md
156
- └── package.json
157
- ```
207
+ Subscribe to live price updates via WebSocket. Fires on every on-chain swap.
158
208
 
159
- ## Contributing
209
+ ```typescript
210
+ import { Codex } from "@codex-data/sdk";
160
211
 
161
- We welcome contributions! Please feel free to submit a Pull Request.
212
+ const sdk = new Codex(process.env.CODEX_API_KEY!);
162
213
 
163
- ### Development Scripts
214
+ const unsubscribe = sdk.subscriptions.onPriceUpdated(
215
+ {
216
+ address: "So11111111111111111111111111111111111111112",
217
+ networkId: 1399811149,
218
+ },
219
+ {
220
+ next: (result) => {
221
+ console.log("Price:", result.data?.onPriceUpdated?.priceUsd);
222
+ },
223
+ error: (err) => console.error(err),
224
+ complete: () => console.log("Stream ended"),
225
+ },
226
+ );
164
227
 
165
- - `pnpm run build` - Build the SDK for production
166
- - `pnpm run test` - Run the test suite
167
- - `pnpm run lint` - Lint the codebase
168
- - `pnpm run clean` - Clean build artifacts
228
+ // Call unsubscribe() to clean up
229
+ ```
169
230
 
170
- ## Releasing
231
+ ## Stream Real-Time OHLCV Bars
171
232
 
172
- ### Publishing Beta Versions
233
+ > **Note:** WebSocket subscriptions require a [paid plan](https://dashboard.codex.io/dashboard/billing).
173
234
 
174
- For testing releases before making them public:
235
+ Get live candlestick updates across all resolutions simultaneously.
175
236
 
176
- 1. Update the version in `package.json` to a beta version:
237
+ ```typescript
238
+ import { Codex, QuoteToken } from "@codex-data/sdk";
177
239
 
178
- ```json
179
- "version": "2.0.0-beta.0"
180
- ```
240
+ const sdk = new Codex(process.env.CODEX_API_KEY!);
181
241
 
182
- 2. Publish to the beta tag:
242
+ const unsubscribe = sdk.subscriptions.onBarsUpdated(
243
+ {
244
+ pairId: "0x88e6a0c2ddd26feeb64f039a2c41296fcb3f5640:1", // USDC/WETH on Ethereum
245
+ quoteToken: QuoteToken.Token1,
246
+ },
247
+ {
248
+ next: (result) => {
249
+ const bar = result.data?.onBarsUpdated;
250
+ const oneMin = bar?.aggregates?.r1?.usd;
251
+ console.log(`1min candle — O: ${oneMin?.o} H: ${oneMin?.h} L: ${oneMin?.l} C: ${oneMin?.c}`);
252
+ },
253
+ error: (err) => console.error(err),
254
+ complete: () => console.log("Stream ended"),
255
+ },
256
+ );
257
+ ```
183
258
 
184
- ```bash
185
- pnpm run publish:beta
186
- ```
259
+ ## Stream Live Trades
187
260
 
188
- 3. Test the beta version:
189
- ```bash
190
- npm install @codex-data/sdk@beta
191
- ```
261
+ > **Note:** WebSocket subscriptions require a [paid plan](https://dashboard.codex.io/dashboard/billing).
192
262
 
193
- Users installing without the `@beta` tag will continue to receive the latest stable version.
263
+ Watch buy/sell events as they happen on any trading pair.
194
264
 
195
- ### Publishing Production Releases
265
+ ```typescript
266
+ import { Codex, QuoteToken } from "@codex-data/sdk";
196
267
 
197
- 1. Update the version in `package.json` to a production version:
268
+ const sdk = new Codex(process.env.CODEX_API_KEY!);
198
269
 
199
- ```json
200
- "version": "2.0.0"
201
- ```
270
+ const unsubscribe = sdk.subscriptions.onEventsCreated(
271
+ {
272
+ id: "0x88e6a0c2ddd26feeb64f039a2c41296fcb3f5640:1",
273
+ quoteToken: QuoteToken.Token0,
274
+ },
275
+ {
276
+ next: (result) => {
277
+ result.data?.onEventsCreated?.events?.forEach((event) => {
278
+ console.log(`${event?.eventDisplayType} by ${event?.maker} — $${event?.token0SwapValueUsd}`);
279
+ });
280
+ },
281
+ error: (err) => console.error(err),
282
+ complete: () => console.log("Stream ended"),
283
+ },
284
+ );
285
+ ```
202
286
 
203
- 2. Publish to the latest tag:
204
- ```bash
205
- pnpm run publish:latest
206
- ```
287
+ ## Raw GraphQL Queries
207
288
 
208
- > **Note:** The `prepublishOnly` script automatically runs the full build before publishing, ensuring the package is always built before release.
289
+ Use `sdk.send()` to execute any GraphQL query directly.
209
290
 
210
- # Upgrading to 2.0.0+
291
+ ```typescript
292
+ import { Codex } from "@codex-data/sdk";
211
293
 
212
- There are a few breaking changes in 2.0.0 that you need to be aware of.
294
+ const sdk = new Codex(process.env.CODEX_API_KEY!);
213
295
 
214
- ### Imports
296
+ const result = await sdk.send<{
297
+ getNetworks: Array<{ id: number; name: string }>;
298
+ }>(
299
+ `query GetNetworks {
300
+ getNetworks { id name }
301
+ }`,
302
+ {},
303
+ );
215
304
 
216
- **Before**
305
+ console.log("Networks:", result.getNetworks);
217
306
  ```
307
+
308
+ ## Common Network IDs
309
+
310
+ | Network | ID |
311
+ | --- | --- |
312
+ | Ethereum | `1` |
313
+ | BSC | `56` |
314
+ | Polygon | `137` |
315
+ | Arbitrum | `42161` |
316
+ | Base | `8453` |
317
+ | Avalanche | `43114` |
318
+ | Solana | `1399811149` |
319
+
320
+ Use `sdk.queries.getNetworks({})` for the full list of 80+ supported networks.
321
+
322
+ ## ID Format Convention
323
+
324
+ IDs in the Codex API follow the pattern `address:networkId`:
325
+
326
+ - **Token ID:** `0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2:1` (WETH on Ethereum)
327
+ - **Pair ID:** `0x88e6a0c2ddd26feeb64f039a2c41296fcb3f5640:1` (USDC/WETH on Ethereum)
328
+ - **Wallet ID:** `0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045:1`
329
+
330
+ ## All Available Methods
331
+
332
+ ### Queries (`sdk.queries.*`)
333
+
334
+ | Method | Description |
335
+ | --- | --- |
336
+ | [`filterTokens`](https://docs.codex.io/api-reference/queries/filtertokens) | Search and filter tokens by price, volume, market cap, liquidity |
337
+ | [`getTokenPrices`](https://docs.codex.io/api-reference/queries/gettokenprices) | Get current or historical USD prices for up to 25 tokens |
338
+ | [`getBars`](https://docs.codex.io/api-reference/queries/getbars) | Get OHLCV candlestick data for a trading pair |
339
+ | [`holders`](https://docs.codex.io/api-reference/queries/holders) | Get token holder list sorted by balance ([paid](https://dashboard.codex.io/dashboard/billing)) |
340
+ | [`filterPairs`](https://docs.codex.io/api-reference/queries/filterpairs) | Search and filter trading pairs |
341
+ | [`balances`](https://docs.codex.io/api-reference/queries/balances) | Get wallet token balances with USD values ([paid](https://dashboard.codex.io/dashboard/billing)) |
342
+ | [`getTokenEvents`](https://docs.codex.io/api-reference/queries/gettokenevents) | Get buy/sell/mint/burn trade events |
343
+ | [`pairMetadata`](https://docs.codex.io/api-reference/queries/pairmetadata) | Get trading pair stats and metadata |
344
+ | [`token`](https://docs.codex.io/api-reference/queries/token) | Get metadata for a single token |
345
+ | [`listPairsWithMetadataForToken`](https://docs.codex.io/api-reference/queries/listpairswithmetadatafortoken) | List pairs with full metadata |
346
+ | [`getTokenEventsForMaker`](https://docs.codex.io/api-reference/queries/gettokeneventsformaker) | Get trade events for a specific wallet |
347
+ | [`getDetailedPairStats`](https://docs.codex.io/api-reference/queries/getdetailedpairstats) | Get detailed bucketed stats for a pair |
348
+ | [`listPairsForToken`](https://docs.codex.io/api-reference/queries/listpairsfortoken) | List all trading pairs for a token |
349
+ | [`tokenTopTraders`](https://docs.codex.io/api-reference/queries/tokentoptraders) | Get top traders for a token |
350
+ | [`tokens`](https://docs.codex.io/api-reference/queries/tokens) | Get metadata for multiple tokens |
351
+ | [`top10HoldersPercent`](https://docs.codex.io/api-reference/queries/top10holderspercent) | Get percentage held by top 10 wallets |
352
+ | [`getDetailedPairsStats`](https://docs.codex.io/api-reference/queries/getdetailedpairsstats) | Get detailed stats for multiple pairs |
353
+ | [`filterTokenWallets`](https://docs.codex.io/api-reference/queries/filtertokenwallets) | Get per-wallet trading stats (profit/loss, buy/sell counts) ([paid](https://dashboard.codex.io/dashboard/billing)) |
354
+ | [`liquidityMetadata`](https://docs.codex.io/api-reference/queries/liquiditymetadata) | Get liquidity pool metadata ([paid](https://dashboard.codex.io/dashboard/billing)) |
355
+ | [`tokenSparklines`](https://docs.codex.io/api-reference/queries/tokensparklines) | Get sparkline price data for tokens |
356
+ | [`filterWallets`](https://docs.codex.io/api-reference/queries/filterwallets) | Filter wallets by trading statistics ([paid](https://dashboard.codex.io/dashboard/billing)) |
357
+ | [`detailedWalletStats`](https://docs.codex.io/api-reference/queries/detailedwalletstats) | Get comprehensive wallet analytics ([paid](https://dashboard.codex.io/dashboard/billing)) |
358
+ | [`getExchanges`](https://docs.codex.io/api-reference/queries/getexchanges) | Get DEX information |
359
+ | [`getNetworks`](https://docs.codex.io/api-reference/queries/getnetworks) | List all 80+ supported networks |
360
+ | [`getTokenBars`](https://docs.codex.io/api-reference/queries/gettokenbars) | Get OHLCV data for a token across all pairs |
361
+ | [`chartUrls`](https://docs.codex.io/api-reference/queries/charturls) | Get pre-rendered chart image URLs ([paid](https://dashboard.codex.io/dashboard/billing)) |
362
+ | [`walletChart`](https://docs.codex.io/api-reference/queries/walletchart) | Get wallet portfolio chart data ([paid](https://dashboard.codex.io/dashboard/billing)) |
363
+ | [`filterExchanges`](https://docs.codex.io/api-reference/queries/filterexchanges) | Filter decentralized exchanges |
364
+ | [`liquidityLocks`](https://docs.codex.io/api-reference/queries/liquiditylocks) | Get liquidity lock information ([paid](https://dashboard.codex.io/dashboard/billing)) |
365
+ | [`getNetworkConfigs`](https://docs.codex.io/api-reference/queries/getnetworkconfigs) | Get network configuration details |
366
+ | [`getNetworkStats`](https://docs.codex.io/api-reference/queries/getnetworkstats) | Get network-level statistics |
367
+ | [`getNetworkStatus`](https://docs.codex.io/api-reference/queries/getnetworkstatus) | Get network sync status |
368
+ | [`tokenLifecycleEvents`](https://docs.codex.io/api-reference/queries/tokenlifecycleevents) | Get token creation and migration events |
369
+ | [`blocks`](https://docs.codex.io/api-reference/queries/blocks) | Get block data by number or timestamp |
370
+
371
+ ### Subscriptions (`sdk.subscriptions.*`) — [paid plan](https://dashboard.codex.io/dashboard/billing) required
372
+
373
+ | Method | Description |
374
+ | --- | --- |
375
+ | [`onPairMetadataUpdated`](https://docs.codex.io/api-reference/subscriptions/onpairmetadataupdated) | Live pair stat updates |
376
+ | [`onLaunchpadTokenEventBatch`](https://docs.codex.io/api-reference/subscriptions/onlaunchpadtokeneventbatch) | Batched launchpad events |
377
+ | [`onBarsUpdated`](https://docs.codex.io/api-reference/subscriptions/onbarsupdated) | Real-time OHLCV bars for a trading pair |
378
+ | [`onPriceUpdated`](https://docs.codex.io/api-reference/subscriptions/onpriceupdated) | Real-time price for a single token |
379
+ | [`onHoldersUpdated`](https://docs.codex.io/api-reference/subscriptions/onholdersupdated) | Live holder count and balance changes |
380
+ | [`onDetailedStatsUpdated`](https://docs.codex.io/api-reference/subscriptions/ondetailedstatsupdated) | Live detailed stats updates |
381
+ | [`onDetailedTokenStatsUpdated`](https://docs.codex.io/api-reference/subscriptions/ondetailedtokenstatsupdated) | Live detailed token stats aggregated across pools |
382
+ | [`onEventsCreated`](https://docs.codex.io/api-reference/subscriptions/oneventscreated) | Live buy/sell events for a pair |
383
+ | [`onPricesUpdated`](https://docs.codex.io/api-reference/subscriptions/onpricesupdated) | Real-time prices for multiple tokens |
384
+ | [`onUnconfirmedEventsCreated`](https://docs.codex.io/api-reference/subscriptions/onunconfirmedeventscreated) | Unconfirmed (mempool) trade events |
385
+ | [`onTokenEventsCreated`](https://docs.codex.io/api-reference/subscriptions/ontokeneventscreated) | Live events across all pools for a token |
386
+ | [`onLaunchpadTokenEvent`](https://docs.codex.io/api-reference/subscriptions/onlaunchpadtokenevent) | Individual launchpad events (Pump.fun, etc.) |
387
+ | [`onTokenBarsUpdated`](https://docs.codex.io/api-reference/subscriptions/ontokenbarsupdated) | Real-time OHLCV bars for a token |
388
+ | [`onLatestPairUpdated`](https://docs.codex.io/api-reference/subscriptions/onlatestpairupdated) | New trading pair creation events |
389
+ | [`onUnconfirmedBarsUpdated`](https://docs.codex.io/api-reference/subscriptions/onunconfirmedbarsupdated) | Unconfirmed bar updates |
390
+ | [`onEventsCreatedByMaker`](https://docs.codex.io/api-reference/subscriptions/oneventscreatedbymaker) | Live events for a specific wallet |
391
+ | [`onBalanceUpdated`](https://docs.codex.io/api-reference/subscriptions/onbalanceupdated) | Live wallet balance updates |
392
+ | [`onTokenLifecycleEventsCreated`](https://docs.codex.io/api-reference/subscriptions/ontokenlifecycleeventscreated) | Token lifecycle events |
393
+ | [`onLatestTokens`](https://docs.codex.io/api-reference/subscriptions/onlatesttokens) | New token creation events |
394
+ | [`onNftEventsCreated`](https://docs.codex.io/api-reference/subscriptions/onnfteventscreated) | NFT trade events |
395
+
396
+ ### Mutations (`sdk.mutations.*`)
397
+
398
+ | Method | Description |
399
+ | --- | --- |
400
+ | [`createWebhooks`](https://docs.codex.io/api-reference/mutations/createwebhooks) | Create webhook alerts ([paid](https://dashboard.codex.io/dashboard/billing)) |
401
+ | [`deleteWebhooks`](https://docs.codex.io/api-reference/mutations/deletewebhooks) | Delete webhook alerts ([paid](https://dashboard.codex.io/dashboard/billing)) |
402
+ | [`backfillWalletAggregates`](https://docs.codex.io/api-reference/mutations/backfillwalletaggregates) | Trigger wallet data backfill ([paid](https://dashboard.codex.io/dashboard/billing)) |
403
+ | [`createApiTokens`](https://docs.codex.io/api-reference/mutations/createapitokens) | Create short-lived API tokens for client-side use ([paid](https://dashboard.codex.io/dashboard/billing)) |
404
+ | [`deleteApiToken`](https://docs.codex.io/api-reference/mutations/deleteapitoken) | Delete an API token ([paid](https://dashboard.codex.io/dashboard/billing)) |
405
+ | [`refreshBalances`](https://docs.codex.io/api-reference/mutations/refreshbalances) | Refresh wallet balances |
406
+
407
+ ## Configuration
408
+
409
+ ```typescript
218
410
  import { Codex } from "@codex-data/sdk";
219
- import { TokenRankingAttribute, RankingDirection } from "@codex-data/sdk/dist/sdk/generated/graphql";
220
- ```
221
411
 
222
- **After**
223
- ```
224
- import { Codex, TokenRankingAttribute, RankingDirection } from "@codex-data/sdk";
225
- ```
412
+ const sdk = new Codex("YOUR_API_KEY", {
413
+ apiUrl: "https://graph.codex.io/graphql", // default
414
+ apiRealtimeUrl: "wss://graph.codex.io/graphql", // default
415
+ ws: true, // enable WebSocket (default: true)
416
+ });
226
417
 
227
- **Before**
228
- ```tsx
229
- import { Codex, GraphQL } from "@codex-data/sdk";
418
+ // Update config at runtime
419
+ sdk.updateConfig({ ws: false });
230
420
 
231
- const [quoteToken, setQuoteToken] = useState<GraphQL.QuoteToken>(GraphQL.QuoteToken.Token0);
421
+ // Clean up WebSocket connection
422
+ sdk.dispose();
232
423
  ```
233
424
 
234
- **After**
235
- ```tsx
236
- import { Codex, QuoteToken } from "@codex-data/sdk";
425
+ ## Examples
237
426
 
238
- const [quoteToken, setQuoteToken] = useState<QuoteToken>(QuoteToken.Token0);
239
- ```
427
+ See the [examples](./examples) directory for full working projects:
240
428
 
241
- ### `onLaunchpadTokenEventBatch`
429
+ - **[Simple](./examples/simple)** — Basic queries, filtering, and subscriptions
430
+ - **[Codegen](./examples/codegen)** — Using GraphQL Code Generator for fully typed custom queries
431
+ - **[Next.js](./examples/next)** — Full-stack web application
242
432
 
243
- **Before**
244
- ```tsx
245
- const unsubscribeFn = codex.subscriptions.onLaunchpadTokenEventBatch(
246
- {
247
- networkId: networkId
248
- }
249
- )
250
- ```
433
+ ## Contributing
251
434
 
252
- **After**
253
- ```tsx
254
- const unsubscribeFn = codex.subscriptions.onLaunchpadTokenEventBatch(
255
- {
256
- input: {
257
- networkId: networkId
258
- }
259
- }
260
- )
435
+ We welcome contributions! Please feel free to submit a Pull Request.
436
+
437
+ ```bash
438
+ pnpm install # Install dependencies
439
+ pnpm run build # Build the SDK
440
+ pnpm run test # Run tests
441
+ pnpm run lint # Lint the codebase
261
442
  ```
443
+
444
+ ## Upgrading to v2
445
+
446
+ See [UPGRADING.md](./UPGRADING.md) for migration instructions from v1 to v2.
447
+
448
+ ## Links
449
+
450
+ - [Codex API Documentation](https://docs.codex.io)
451
+ - [Popular Endpoints](https://docs.codex.io/api-reference/popular-endpoints)
452
+ - [GraphQL Explorer](https://explorer.codex.io)
453
+ - [Get an API Key](https://dashboard.codex.io)
454
+ - [Codex MCP Server](https://github.com/Codex-Data/codex-mcp)
455
+ - [Discord](https://discord.com/invite/mFpUhT3vAq)
456
+ - [Twitter](https://x.com/trycodex)
457
+
458
+ ## License
459
+
460
+ MIT
@@ -1,4 +1,4 @@
1
- import { ApiTokenQueryVariables, ApiTokensQueryVariables, BalancesQueryVariables, BlocksQueryVariables, ChartUrlsQueryVariables, DetailedWalletStatsQueryVariables, FilterExchangesQueryVariables, FilterPairsQueryVariables, FilterTokensQueryVariables, FilterTokenWalletsQueryVariables, FilterWalletsQueryVariables, GetBarsQueryVariables, GetCommunityNotesQueryVariables, GetDetailedPairsStatsQueryVariables, GetDetailedPairStatsQueryVariables, GetEventLabelsQueryVariables, GetExchangesQueryVariables, GetNetworkConfigsQueryVariables, GetNetworksQueryVariables, GetNetworkStatsQueryVariables, GetNetworkStatusQueryVariables, GetSymbolQueryVariables, GetTokenBarsQueryVariables, GetTokenEventsForMakerQueryVariables, GetTokenEventsQueryVariables, GetTokenPricesQueryVariables, GetWebhooksQueryVariables, HoldersQueryVariables, LiquidityLocksQueryVariables, LiquidityMetadataByTokenQueryVariables, LiquidityMetadataQueryVariables, ListPairsForTokenQueryVariables, ListPairsWithMetadataForTokenQueryVariables, PairMetadataQueryVariables, TokenLifecycleEventsQueryVariables, TokenQueryVariables, TokenSparklinesQueryVariables, TokensQueryVariables, TokenTopTradersQueryVariables, Top10HoldersPercentQueryVariables, WalletAggregateBackfillStateQueryVariables, WalletChartQueryVariables } from "./generated/graphql";
1
+ import { ApiTokenQueryVariables, ApiTokensQueryVariables, BalancesQueryVariables, BlocksQueryVariables, ChartUrlsQueryVariables, DetailedWalletStatsQueryVariables, FilterExchangesQueryVariables, FilterPairsQueryVariables, FilterTokensQueryVariables, FilterTokenWalletsQueryVariables, FilterWalletsQueryVariables, GetBarsQueryVariables, GetCommunityNotesQueryVariables, GetDetailedPairsStatsQueryVariables, GetDetailedPairStatsQueryVariables, GetDetailedTokenStatsQueryVariables, GetEventLabelsQueryVariables, GetExchangesQueryVariables, GetNetworkConfigsQueryVariables, GetNetworksQueryVariables, GetNetworkStatsQueryVariables, GetNetworkStatusQueryVariables, GetSymbolQueryVariables, GetTokenBarsQueryVariables, GetTokenEventsForMakerQueryVariables, GetTokenEventsQueryVariables, GetTokenPricesQueryVariables, GetWebhooksQueryVariables, HoldersQueryVariables, LiquidityLocksQueryVariables, LiquidityMetadataByTokenQueryVariables, LiquidityMetadataQueryVariables, ListPairsForTokenQueryVariables, ListPairsWithMetadataForTokenQueryVariables, PairMetadataQueryVariables, TokenLifecycleEventsQueryVariables, TokenQueryVariables, TokenSparklinesQueryVariables, TokensQueryVariables, TokenTopTradersQueryVariables, Top10HoldersPercentQueryVariables, WalletAggregateBackfillStateQueryVariables, WalletChartQueryVariables } from "./generated/graphql";
2
2
  import { Codex } from "./index";
3
3
  export declare class Query {
4
4
  private sdk;
@@ -18,6 +18,7 @@ export declare class Query {
18
18
  getCommunityNotes: (vars: GetCommunityNotesQueryVariables) => Promise<import("./generated/graphql").GetCommunityNotesQuery>;
19
19
  getDetailedPairStats: (vars: GetDetailedPairStatsQueryVariables) => Promise<import("./generated/graphql").GetDetailedPairStatsQuery>;
20
20
  getDetailedPairsStats: (vars: GetDetailedPairsStatsQueryVariables) => Promise<import("./generated/graphql").GetDetailedPairsStatsQuery>;
21
+ getDetailedTokenStats: (vars: GetDetailedTokenStatsQueryVariables) => Promise<import("./generated/graphql").GetDetailedTokenStatsQuery>;
21
22
  getEventLabels: (vars: GetEventLabelsQueryVariables) => Promise<import("./generated/graphql").GetEventLabelsQuery>;
22
23
  getExchanges: (vars: GetExchangesQueryVariables) => Promise<import("./generated/graphql").GetExchangesQuery>;
23
24
  getNetworkConfigs: (vars: GetNetworkConfigsQueryVariables) => Promise<import("./generated/graphql").GetNetworkConfigsQuery>;