@codex-data/sdk 2.3.12 → 2.3.14
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 +200 -94
- package/dist/index.d.ts +16 -0
- package/dist/sdk/Query.d.ts +2 -1
- package/dist/sdk/Query.js +1 -0
- package/dist/sdk/Query.mjs +2 -1
- package/dist/sdk/Subscribe.js +6 -6
- package/dist/sdk/Subscribe.mjs +6 -6
- package/dist/sdk/generated/gql.d.ts +53 -48
- package/dist/sdk/generated/gql.js +25 -24
- package/dist/sdk/generated/gql.mjs +25 -24
- package/dist/sdk/generated/graphql.d.ts +174 -255
- package/dist/sdk/generated/graphql.js +50 -29
- package/dist/sdk/generated/graphql.mjs +45 -24
- package/package.json +5 -3
- package/schema.graphql +15903 -0
package/README.md
CHANGED
|
@@ -33,6 +33,8 @@ const networks = await sdk.queries.getNetworks({});
|
|
|
33
33
|
console.log(networks.getNetworks); // [{ id: 1, name: "ethereum" }, { id: 1399811149, name: "solana" }, ...]
|
|
34
34
|
```
|
|
35
35
|
|
|
36
|
+
> **Tip:** The built-in `sdk.queries.*` methods request **every** available field. They're great for exploring the API, but for production we recommend [writing a custom query](#custom-queries-request-only-the-fields-you-need) that selects only the fields you need.
|
|
37
|
+
|
|
36
38
|
## Get Token Prices
|
|
37
39
|
|
|
38
40
|
Get the current USD price of any token. Supports up to 25 tokens per request. Prices are liquidity-weighted across all valid pools.
|
|
@@ -44,8 +46,11 @@ const sdk = new Codex(process.env.CODEX_API_KEY!);
|
|
|
44
46
|
|
|
45
47
|
const prices = await sdk.queries.getTokenPrices({
|
|
46
48
|
inputs: [
|
|
47
|
-
{
|
|
48
|
-
|
|
49
|
+
{
|
|
50
|
+
address: "So11111111111111111111111111111111111111112",
|
|
51
|
+
networkId: 1399811149,
|
|
52
|
+
}, // SOL
|
|
53
|
+
{ address: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", networkId: 1 }, // WETH
|
|
49
54
|
],
|
|
50
55
|
});
|
|
51
56
|
|
|
@@ -104,16 +109,20 @@ Available resolutions: `1S`, `5S`, `15S`, `30S`, `1`, `5`, `15`, `30`, `60`, `24
|
|
|
104
109
|
Search and filter tokens by price, volume, market cap, liquidity, holder count, trading activity, and more.
|
|
105
110
|
|
|
106
111
|
```typescript
|
|
107
|
-
import {
|
|
112
|
+
import {
|
|
113
|
+
Codex,
|
|
114
|
+
TokenRankingAttribute,
|
|
115
|
+
RankingDirection,
|
|
116
|
+
} from "@codex-data/sdk";
|
|
108
117
|
|
|
109
118
|
const sdk = new Codex(process.env.CODEX_API_KEY!);
|
|
110
119
|
|
|
111
120
|
const result = await sdk.queries.filterTokens({
|
|
112
121
|
filters: {
|
|
113
|
-
network: [1],
|
|
114
|
-
liquidity: { gte: "100000" },
|
|
115
|
-
marketCap: { gte: "1000000" },
|
|
116
|
-
txnCount24: { gte: "500" },
|
|
122
|
+
network: [1], // Ethereum
|
|
123
|
+
liquidity: { gte: "100000" }, // $100k+ liquidity
|
|
124
|
+
marketCap: { gte: "1000000" }, // $1M+ market cap
|
|
125
|
+
txnCount24: { gte: "500" }, // 500+ transactions in 24h
|
|
117
126
|
},
|
|
118
127
|
rankings: [
|
|
119
128
|
{
|
|
@@ -125,7 +134,9 @@ const result = await sdk.queries.filterTokens({
|
|
|
125
134
|
});
|
|
126
135
|
|
|
127
136
|
result.filterTokens?.results?.forEach((token) => {
|
|
128
|
-
console.log(
|
|
137
|
+
console.log(
|
|
138
|
+
`${token?.token?.name} (${token?.token?.symbol}): $${token?.priceUSD}`,
|
|
139
|
+
);
|
|
129
140
|
});
|
|
130
141
|
```
|
|
131
142
|
|
|
@@ -149,7 +160,9 @@ const balances = await sdk.queries.balances({
|
|
|
149
160
|
});
|
|
150
161
|
|
|
151
162
|
balances.balances?.items?.forEach((item) => {
|
|
152
|
-
console.log(
|
|
163
|
+
console.log(
|
|
164
|
+
`${item?.token?.symbol}: ${item?.shiftedBalance} ($${item?.balanceUsd})`,
|
|
165
|
+
);
|
|
153
166
|
});
|
|
154
167
|
```
|
|
155
168
|
|
|
@@ -173,7 +186,9 @@ console.log(`Total holders: ${holders.holders?.count}`);
|
|
|
173
186
|
console.log(`Top 10 hold: ${holders.holders?.top10HoldersPercent}%`);
|
|
174
187
|
|
|
175
188
|
holders.holders?.items?.forEach((holder) => {
|
|
176
|
-
console.log(
|
|
189
|
+
console.log(
|
|
190
|
+
`${holder?.address}: ${holder?.shiftedBalance} ($${holder?.balanceUsd})`,
|
|
191
|
+
);
|
|
177
192
|
});
|
|
178
193
|
```
|
|
179
194
|
|
|
@@ -196,7 +211,9 @@ const events = await sdk.queries.getTokenEvents({
|
|
|
196
211
|
});
|
|
197
212
|
|
|
198
213
|
events.getTokenEvents?.items?.forEach((event) => {
|
|
199
|
-
console.log(
|
|
214
|
+
console.log(
|
|
215
|
+
`${event?.eventDisplayType} by ${event?.maker} — $${event?.token0SwapValueUsd}`,
|
|
216
|
+
);
|
|
200
217
|
});
|
|
201
218
|
```
|
|
202
219
|
|
|
@@ -248,7 +265,9 @@ const unsubscribe = sdk.subscriptions.onBarsUpdated(
|
|
|
248
265
|
next: (result) => {
|
|
249
266
|
const bar = result.data?.onBarsUpdated;
|
|
250
267
|
const oneMin = bar?.aggregates?.r1?.usd;
|
|
251
|
-
console.log(
|
|
268
|
+
console.log(
|
|
269
|
+
`1min candle — O: ${oneMin?.o} H: ${oneMin?.h} L: ${oneMin?.l} C: ${oneMin?.c}`,
|
|
270
|
+
);
|
|
252
271
|
},
|
|
253
272
|
error: (err) => console.error(err),
|
|
254
273
|
complete: () => console.log("Stream ended"),
|
|
@@ -275,7 +294,9 @@ const unsubscribe = sdk.subscriptions.onEventsCreated(
|
|
|
275
294
|
{
|
|
276
295
|
next: (result) => {
|
|
277
296
|
result.data?.onEventsCreated?.events?.forEach((event) => {
|
|
278
|
-
console.log(
|
|
297
|
+
console.log(
|
|
298
|
+
`${event?.eventDisplayType} by ${event?.maker} — $${event?.token0SwapValueUsd}`,
|
|
299
|
+
);
|
|
279
300
|
});
|
|
280
301
|
},
|
|
281
302
|
error: (err) => console.error(err),
|
|
@@ -284,9 +305,15 @@ const unsubscribe = sdk.subscriptions.onEventsCreated(
|
|
|
284
305
|
);
|
|
285
306
|
```
|
|
286
307
|
|
|
287
|
-
##
|
|
308
|
+
## Custom Queries: Request Only the Fields You Need
|
|
309
|
+
|
|
310
|
+
The built-in `sdk.queries.*` methods select every available field, so the recipes above are the most expensive way to call each endpoint. Writing your own query means you get smaller, faster responses.
|
|
288
311
|
|
|
289
|
-
|
|
312
|
+
There are two ways to do it:
|
|
313
|
+
|
|
314
|
+
### Option 1: `sdk.send()` — quick, zero setup
|
|
315
|
+
|
|
316
|
+
Write the query yourself and describe the result type inline:
|
|
290
317
|
|
|
291
318
|
```typescript
|
|
292
319
|
import { Codex } from "@codex-data/sdk";
|
|
@@ -305,17 +332,96 @@ const result = await sdk.send<{
|
|
|
305
332
|
console.log("Networks:", result.getNetworks);
|
|
306
333
|
```
|
|
307
334
|
|
|
335
|
+
Instead of writing types by hand, you can reuse the SDK's exported query types with `DeepPartial`, which makes every field optional:
|
|
336
|
+
|
|
337
|
+
```typescript
|
|
338
|
+
import { Codex, DeepPartial, FilterTokensQuery } from "@codex-data/sdk";
|
|
339
|
+
|
|
340
|
+
const sdk = new Codex(process.env.CODEX_API_KEY!);
|
|
341
|
+
|
|
342
|
+
const result = await sdk.send<DeepPartial<FilterTokensQuery>>(
|
|
343
|
+
`query FilterTokens($limit: Int) {
|
|
344
|
+
filterTokens(limit: $limit) {
|
|
345
|
+
results {
|
|
346
|
+
priceUSD
|
|
347
|
+
volume24
|
|
348
|
+
token { name symbol }
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
}`,
|
|
352
|
+
{ limit: 10 },
|
|
353
|
+
);
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
### Option 2: GraphQL Code Generator — exact types and autocomplete
|
|
357
|
+
|
|
358
|
+
For production codebases we recommend generating types from your own queries. The SDK ships its schema at `@codex-data/sdk/schema.graphql`, so codegen runs offline against the exact schema version you have installed.
|
|
359
|
+
|
|
360
|
+
Install the codegen tooling:
|
|
361
|
+
|
|
362
|
+
```bash
|
|
363
|
+
npm install -D @graphql-codegen/cli @graphql-codegen/client-preset
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
Add a `codegen.ts` to your project root:
|
|
367
|
+
|
|
368
|
+
```typescript
|
|
369
|
+
import type { CodegenConfig } from "@graphql-codegen/cli";
|
|
370
|
+
|
|
371
|
+
const config: CodegenConfig = {
|
|
372
|
+
schema: "./node_modules/@codex-data/sdk/schema.graphql",
|
|
373
|
+
documents: "src/**/*.ts",
|
|
374
|
+
generates: {
|
|
375
|
+
"src/gql/": {
|
|
376
|
+
preset: "client",
|
|
377
|
+
presetConfig: { fragmentMasking: false },
|
|
378
|
+
},
|
|
379
|
+
},
|
|
380
|
+
};
|
|
381
|
+
|
|
382
|
+
export default config;
|
|
383
|
+
```
|
|
384
|
+
|
|
385
|
+
Run `graphql-codegen`, then write queries with the generated `graphql()` helper and pass them to `sdk.query()`. The result type is inferred from exactly the fields you selected:
|
|
386
|
+
|
|
387
|
+
```typescript
|
|
388
|
+
import { Codex } from "@codex-data/sdk";
|
|
389
|
+
import { graphql } from "./gql";
|
|
390
|
+
|
|
391
|
+
const sdk = new Codex(process.env.CODEX_API_KEY!);
|
|
392
|
+
|
|
393
|
+
const trendingTokens = graphql(`
|
|
394
|
+
query TrendingTokens($limit: Int) {
|
|
395
|
+
filterTokens(limit: $limit) {
|
|
396
|
+
results {
|
|
397
|
+
priceUSD
|
|
398
|
+
volume24
|
|
399
|
+
token {
|
|
400
|
+
name
|
|
401
|
+
symbol
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
`);
|
|
407
|
+
|
|
408
|
+
const result = await sdk.query(trendingTokens, { limit: 10 });
|
|
409
|
+
// result.filterTokens.results[0].priceUSD — fully typed, only what you asked for
|
|
410
|
+
```
|
|
411
|
+
|
|
412
|
+
See the [codegen example](./examples/codegen) for a complete working project.
|
|
413
|
+
|
|
308
414
|
## Common Network IDs
|
|
309
415
|
|
|
310
|
-
| Network
|
|
311
|
-
|
|
|
312
|
-
| Ethereum
|
|
313
|
-
| BSC
|
|
314
|
-
| Polygon
|
|
315
|
-
| Arbitrum
|
|
316
|
-
| Base
|
|
317
|
-
| Avalanche | `43114`
|
|
318
|
-
| Solana
|
|
416
|
+
| Network | ID |
|
|
417
|
+
| --------- | ------------ |
|
|
418
|
+
| Ethereum | `1` |
|
|
419
|
+
| BSC | `56` |
|
|
420
|
+
| Polygon | `137` |
|
|
421
|
+
| Arbitrum | `42161` |
|
|
422
|
+
| Base | `8453` |
|
|
423
|
+
| Avalanche | `43114` |
|
|
424
|
+
| Solana | `1399811149` |
|
|
319
425
|
|
|
320
426
|
Use `sdk.queries.getNetworks({})` for the full list of 80+ supported networks.
|
|
321
427
|
|
|
@@ -331,78 +437,78 @@ IDs in the Codex API follow the pattern `address:networkId`:
|
|
|
331
437
|
|
|
332
438
|
### Queries (`sdk.queries.*`)
|
|
333
439
|
|
|
334
|
-
| Method
|
|
335
|
-
|
|
|
336
|
-
| [`filterTokens`](https://docs.codex.io/api-reference/queries/filtertokens)
|
|
337
|
-
| [`getTokenPrices`](https://docs.codex.io/api-reference/queries/gettokenprices)
|
|
338
|
-
| [`getBars`](https://docs.codex.io/api-reference/queries/getbars)
|
|
339
|
-
| [`holders`](https://docs.codex.io/api-reference/queries/holders)
|
|
340
|
-
| [`filterPairs`](https://docs.codex.io/api-reference/queries/filterpairs)
|
|
341
|
-
| [`balances`](https://docs.codex.io/api-reference/queries/balances)
|
|
342
|
-
| [`getTokenEvents`](https://docs.codex.io/api-reference/queries/gettokenevents)
|
|
343
|
-
| [`pairMetadata`](https://docs.codex.io/api-reference/queries/pairmetadata)
|
|
344
|
-
| [`token`](https://docs.codex.io/api-reference/queries/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)
|
|
347
|
-
| [`getDetailedPairStats`](https://docs.codex.io/api-reference/queries/getdetailedpairstats)
|
|
348
|
-
| [`listPairsForToken`](https://docs.codex.io/api-reference/queries/listpairsfortoken)
|
|
349
|
-
| [`tokenTopTraders`](https://docs.codex.io/api-reference/queries/tokentoptraders)
|
|
350
|
-
| [`tokens`](https://docs.codex.io/api-reference/queries/tokens)
|
|
351
|
-
| [`top10HoldersPercent`](https://docs.codex.io/api-reference/queries/top10holderspercent)
|
|
352
|
-
| [`getDetailedPairsStats`](https://docs.codex.io/api-reference/queries/getdetailedpairsstats)
|
|
353
|
-
| [`filterTokenWallets`](https://docs.codex.io/api-reference/queries/filtertokenwallets)
|
|
354
|
-
| [`liquidityMetadata`](https://docs.codex.io/api-reference/queries/liquiditymetadata)
|
|
355
|
-
| [`tokenSparklines`](https://docs.codex.io/api-reference/queries/tokensparklines)
|
|
356
|
-
| [`filterWallets`](https://docs.codex.io/api-reference/queries/filterwallets)
|
|
357
|
-
| [`detailedWalletStats`](https://docs.codex.io/api-reference/queries/detailedwalletstats)
|
|
358
|
-
| [`getExchanges`](https://docs.codex.io/api-reference/queries/getexchanges)
|
|
359
|
-
| [`getNetworks`](https://docs.codex.io/api-reference/queries/getnetworks)
|
|
360
|
-
| [`getTokenBars`](https://docs.codex.io/api-reference/queries/gettokenbars)
|
|
361
|
-
| [`chartUrls`](https://docs.codex.io/api-reference/queries/charturls)
|
|
362
|
-
| [`walletChart`](https://docs.codex.io/api-reference/queries/walletchart)
|
|
363
|
-
| [`filterExchanges`](https://docs.codex.io/api-reference/queries/filterexchanges)
|
|
364
|
-
| [`liquidityLocks`](https://docs.codex.io/api-reference/queries/liquiditylocks)
|
|
365
|
-
| [`getNetworkConfigs`](https://docs.codex.io/api-reference/queries/getnetworkconfigs)
|
|
366
|
-
| [`getNetworkStats`](https://docs.codex.io/api-reference/queries/getnetworkstats)
|
|
367
|
-
| [`getNetworkStatus`](https://docs.codex.io/api-reference/queries/getnetworkstatus)
|
|
368
|
-
| [`tokenLifecycleEvents`](https://docs.codex.io/api-reference/queries/tokenlifecycleevents)
|
|
369
|
-
| [`blocks`](https://docs.codex.io/api-reference/queries/blocks)
|
|
440
|
+
| Method | Description |
|
|
441
|
+
| ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------ |
|
|
442
|
+
| [`filterTokens`](https://docs.codex.io/api-reference/queries/filtertokens) | Search and filter tokens by price, volume, market cap, liquidity |
|
|
443
|
+
| [`getTokenPrices`](https://docs.codex.io/api-reference/queries/gettokenprices) | Get current or historical USD prices for up to 25 tokens |
|
|
444
|
+
| [`getBars`](https://docs.codex.io/api-reference/queries/getbars) | Get OHLCV candlestick data for a trading pair |
|
|
445
|
+
| [`holders`](https://docs.codex.io/api-reference/queries/holders) | Get token holder list sorted by balance ([paid](https://dashboard.codex.io/dashboard/billing)) |
|
|
446
|
+
| [`filterPairs`](https://docs.codex.io/api-reference/queries/filterpairs) | Search and filter trading pairs |
|
|
447
|
+
| [`balances`](https://docs.codex.io/api-reference/queries/balances) | Get wallet token balances with USD values ([paid](https://dashboard.codex.io/dashboard/billing)) |
|
|
448
|
+
| [`getTokenEvents`](https://docs.codex.io/api-reference/queries/gettokenevents) | Get buy/sell/mint/burn trade events |
|
|
449
|
+
| [`pairMetadata`](https://docs.codex.io/api-reference/queries/pairmetadata) | Get trading pair stats and metadata |
|
|
450
|
+
| [`token`](https://docs.codex.io/api-reference/queries/token) | Get metadata for a single token |
|
|
451
|
+
| [`listPairsWithMetadataForToken`](https://docs.codex.io/api-reference/queries/listpairswithmetadatafortoken) | List pairs with full metadata |
|
|
452
|
+
| [`getTokenEventsForMaker`](https://docs.codex.io/api-reference/queries/gettokeneventsformaker) | Get trade events for a specific wallet |
|
|
453
|
+
| [`getDetailedPairStats`](https://docs.codex.io/api-reference/queries/getdetailedpairstats) | Get detailed bucketed stats for a pair |
|
|
454
|
+
| [`listPairsForToken`](https://docs.codex.io/api-reference/queries/listpairsfortoken) | List all trading pairs for a token |
|
|
455
|
+
| [`tokenTopTraders`](https://docs.codex.io/api-reference/queries/tokentoptraders) | Get top traders for a token |
|
|
456
|
+
| [`tokens`](https://docs.codex.io/api-reference/queries/tokens) | Get metadata for multiple tokens |
|
|
457
|
+
| [`top10HoldersPercent`](https://docs.codex.io/api-reference/queries/top10holderspercent) | Get percentage held by top 10 wallets |
|
|
458
|
+
| [`getDetailedPairsStats`](https://docs.codex.io/api-reference/queries/getdetailedpairsstats) | Get detailed stats for multiple pairs |
|
|
459
|
+
| [`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)) |
|
|
460
|
+
| [`liquidityMetadata`](https://docs.codex.io/api-reference/queries/liquiditymetadata) | Get liquidity pool metadata ([paid](https://dashboard.codex.io/dashboard/billing)) |
|
|
461
|
+
| [`tokenSparklines`](https://docs.codex.io/api-reference/queries/tokensparklines) | Get sparkline price data for tokens |
|
|
462
|
+
| [`filterWallets`](https://docs.codex.io/api-reference/queries/filterwallets) | Filter wallets by trading statistics ([paid](https://dashboard.codex.io/dashboard/billing)) |
|
|
463
|
+
| [`detailedWalletStats`](https://docs.codex.io/api-reference/queries/detailedwalletstats) | Get comprehensive wallet analytics ([paid](https://dashboard.codex.io/dashboard/billing)) |
|
|
464
|
+
| [`getExchanges`](https://docs.codex.io/api-reference/queries/getexchanges) | Get DEX information |
|
|
465
|
+
| [`getNetworks`](https://docs.codex.io/api-reference/queries/getnetworks) | List all 80+ supported networks |
|
|
466
|
+
| [`getTokenBars`](https://docs.codex.io/api-reference/queries/gettokenbars) | Get OHLCV data for a token across all pairs |
|
|
467
|
+
| [`chartUrls`](https://docs.codex.io/api-reference/queries/charturls) | Get pre-rendered chart image URLs ([paid](https://dashboard.codex.io/dashboard/billing)) |
|
|
468
|
+
| [`walletChart`](https://docs.codex.io/api-reference/queries/walletchart) | Get wallet portfolio chart data ([paid](https://dashboard.codex.io/dashboard/billing)) |
|
|
469
|
+
| [`filterExchanges`](https://docs.codex.io/api-reference/queries/filterexchanges) | Filter decentralized exchanges |
|
|
470
|
+
| [`liquidityLocks`](https://docs.codex.io/api-reference/queries/liquiditylocks) | Get liquidity lock information ([paid](https://dashboard.codex.io/dashboard/billing)) |
|
|
471
|
+
| [`getNetworkConfigs`](https://docs.codex.io/api-reference/queries/getnetworkconfigs) | Get network configuration details |
|
|
472
|
+
| [`getNetworkStats`](https://docs.codex.io/api-reference/queries/getnetworkstats) | Get network-level statistics |
|
|
473
|
+
| [`getNetworkStatus`](https://docs.codex.io/api-reference/queries/getnetworkstatus) | Get network sync status |
|
|
474
|
+
| [`tokenLifecycleEvents`](https://docs.codex.io/api-reference/queries/tokenlifecycleevents) | Get token creation and migration events |
|
|
475
|
+
| [`blocks`](https://docs.codex.io/api-reference/queries/blocks) | Get block data by number or timestamp |
|
|
370
476
|
|
|
371
477
|
### Subscriptions (`sdk.subscriptions.*`) — [paid plan](https://dashboard.codex.io/dashboard/billing) required
|
|
372
478
|
|
|
373
|
-
| Method
|
|
374
|
-
|
|
|
375
|
-
| [`onPairMetadataUpdated`](https://docs.codex.io/api-reference/subscriptions/onpairmetadataupdated)
|
|
376
|
-
| [`onLaunchpadTokenEventBatch`](https://docs.codex.io/api-reference/subscriptions/onlaunchpadtokeneventbatch)
|
|
377
|
-
| [`onBarsUpdated`](https://docs.codex.io/api-reference/subscriptions/onbarsupdated)
|
|
378
|
-
| [`onPriceUpdated`](https://docs.codex.io/api-reference/subscriptions/onpriceupdated)
|
|
379
|
-
| [`onHoldersUpdated`](https://docs.codex.io/api-reference/subscriptions/onholdersupdated)
|
|
380
|
-
| [`onDetailedStatsUpdated`](https://docs.codex.io/api-reference/subscriptions/ondetailedstatsupdated)
|
|
381
|
-
| [`onDetailedTokenStatsUpdated`](https://docs.codex.io/api-reference/subscriptions/ondetailedtokenstatsupdated)
|
|
382
|
-
| [`onEventsCreated`](https://docs.codex.io/api-reference/subscriptions/oneventscreated)
|
|
383
|
-
| [`onPricesUpdated`](https://docs.codex.io/api-reference/subscriptions/onpricesupdated)
|
|
384
|
-
| [`onUnconfirmedEventsCreated`](https://docs.codex.io/api-reference/subscriptions/onunconfirmedeventscreated)
|
|
385
|
-
| [`onTokenEventsCreated`](https://docs.codex.io/api-reference/subscriptions/ontokeneventscreated)
|
|
386
|
-
| [`onLaunchpadTokenEvent`](https://docs.codex.io/api-reference/subscriptions/onlaunchpadtokenevent)
|
|
387
|
-
| [`onTokenBarsUpdated`](https://docs.codex.io/api-reference/subscriptions/ontokenbarsupdated)
|
|
388
|
-
| [`onLatestPairUpdated`](https://docs.codex.io/api-reference/subscriptions/onlatestpairupdated)
|
|
389
|
-
| [`onUnconfirmedBarsUpdated`](https://docs.codex.io/api-reference/subscriptions/onunconfirmedbarsupdated)
|
|
390
|
-
| [`onEventsCreatedByMaker`](https://docs.codex.io/api-reference/subscriptions/oneventscreatedbymaker)
|
|
391
|
-
| [`onBalanceUpdated`](https://docs.codex.io/api-reference/subscriptions/onbalanceupdated)
|
|
392
|
-
| [`onTokenLifecycleEventsCreated`](https://docs.codex.io/api-reference/subscriptions/ontokenlifecycleeventscreated) | Token lifecycle events
|
|
393
|
-
| [`onLatestTokens`](https://docs.codex.io/api-reference/subscriptions/onlatesttokens)
|
|
394
|
-
| [`onNftEventsCreated`](https://docs.codex.io/api-reference/subscriptions/onnfteventscreated)
|
|
479
|
+
| Method | Description |
|
|
480
|
+
| ------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------- |
|
|
481
|
+
| [`onPairMetadataUpdated`](https://docs.codex.io/api-reference/subscriptions/onpairmetadataupdated) | Live pair stat updates |
|
|
482
|
+
| [`onLaunchpadTokenEventBatch`](https://docs.codex.io/api-reference/subscriptions/onlaunchpadtokeneventbatch) | Batched launchpad events |
|
|
483
|
+
| [`onBarsUpdated`](https://docs.codex.io/api-reference/subscriptions/onbarsupdated) | Real-time OHLCV bars for a trading pair |
|
|
484
|
+
| [`onPriceUpdated`](https://docs.codex.io/api-reference/subscriptions/onpriceupdated) | Real-time price for a single token |
|
|
485
|
+
| [`onHoldersUpdated`](https://docs.codex.io/api-reference/subscriptions/onholdersupdated) | Live holder count and balance changes |
|
|
486
|
+
| [`onDetailedStatsUpdated`](https://docs.codex.io/api-reference/subscriptions/ondetailedstatsupdated) | Live detailed stats updates |
|
|
487
|
+
| [`onDetailedTokenStatsUpdated`](https://docs.codex.io/api-reference/subscriptions/ondetailedtokenstatsupdated) | Live detailed token stats aggregated across pools |
|
|
488
|
+
| [`onEventsCreated`](https://docs.codex.io/api-reference/subscriptions/oneventscreated) | Live buy/sell events for a pair |
|
|
489
|
+
| [`onPricesUpdated`](https://docs.codex.io/api-reference/subscriptions/onpricesupdated) | Real-time prices for multiple tokens |
|
|
490
|
+
| [`onUnconfirmedEventsCreated`](https://docs.codex.io/api-reference/subscriptions/onunconfirmedeventscreated) | Unconfirmed (mempool) trade events |
|
|
491
|
+
| [`onTokenEventsCreated`](https://docs.codex.io/api-reference/subscriptions/ontokeneventscreated) | Live events across all pools for a token |
|
|
492
|
+
| [`onLaunchpadTokenEvent`](https://docs.codex.io/api-reference/subscriptions/onlaunchpadtokenevent) | Individual launchpad events (Pump.fun, etc.) |
|
|
493
|
+
| [`onTokenBarsUpdated`](https://docs.codex.io/api-reference/subscriptions/ontokenbarsupdated) | Real-time OHLCV bars for a token |
|
|
494
|
+
| [`onLatestPairUpdated`](https://docs.codex.io/api-reference/subscriptions/onlatestpairupdated) | New trading pair creation events |
|
|
495
|
+
| [`onUnconfirmedBarsUpdated`](https://docs.codex.io/api-reference/subscriptions/onunconfirmedbarsupdated) | Unconfirmed bar updates |
|
|
496
|
+
| [`onEventsCreatedByMaker`](https://docs.codex.io/api-reference/subscriptions/oneventscreatedbymaker) | Live events for a specific wallet |
|
|
497
|
+
| [`onBalanceUpdated`](https://docs.codex.io/api-reference/subscriptions/onbalanceupdated) | Live wallet balance updates |
|
|
498
|
+
| [`onTokenLifecycleEventsCreated`](https://docs.codex.io/api-reference/subscriptions/ontokenlifecycleeventscreated) | Token lifecycle events |
|
|
499
|
+
| [`onLatestTokens`](https://docs.codex.io/api-reference/subscriptions/onlatesttokens) | New token creation events |
|
|
500
|
+
| [`onNftEventsCreated`](https://docs.codex.io/api-reference/subscriptions/onnfteventscreated) | NFT trade events |
|
|
395
501
|
|
|
396
502
|
### Mutations (`sdk.mutations.*`)
|
|
397
503
|
|
|
398
|
-
| Method
|
|
399
|
-
|
|
|
400
|
-
| [`createWebhooks`](https://docs.codex.io/api-reference/mutations/createwebhooks)
|
|
401
|
-
| [`deleteWebhooks`](https://docs.codex.io/api-reference/mutations/deletewebhooks)
|
|
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)
|
|
404
|
-
| [`deleteApiToken`](https://docs.codex.io/api-reference/mutations/deleteapitoken)
|
|
405
|
-
| [`refreshBalances`](https://docs.codex.io/api-reference/mutations/refreshbalances)
|
|
504
|
+
| Method | Description |
|
|
505
|
+
| ---------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- |
|
|
506
|
+
| [`createWebhooks`](https://docs.codex.io/api-reference/mutations/createwebhooks) | Create webhook alerts ([paid](https://dashboard.codex.io/dashboard/billing)) |
|
|
507
|
+
| [`deleteWebhooks`](https://docs.codex.io/api-reference/mutations/deletewebhooks) | Delete webhook alerts ([paid](https://dashboard.codex.io/dashboard/billing)) |
|
|
508
|
+
| [`backfillWalletAggregates`](https://docs.codex.io/api-reference/mutations/backfillwalletaggregates) | Trigger wallet data backfill ([paid](https://dashboard.codex.io/dashboard/billing)) |
|
|
509
|
+
| [`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)) |
|
|
510
|
+
| [`deleteApiToken`](https://docs.codex.io/api-reference/mutations/deleteapitoken) | Delete an API token ([paid](https://dashboard.codex.io/dashboard/billing)) |
|
|
511
|
+
| [`refreshBalances`](https://docs.codex.io/api-reference/mutations/refreshbalances) | Refresh wallet balances |
|
|
406
512
|
|
|
407
513
|
## Configuration
|
|
408
514
|
|
|
@@ -410,9 +516,9 @@ IDs in the Codex API follow the pattern `address:networkId`:
|
|
|
410
516
|
import { Codex } from "@codex-data/sdk";
|
|
411
517
|
|
|
412
518
|
const sdk = new Codex("YOUR_API_KEY", {
|
|
413
|
-
apiUrl: "https://graph.codex.io/graphql",
|
|
414
|
-
apiRealtimeUrl: "wss://graph.codex.io/graphql",
|
|
415
|
-
ws: true,
|
|
519
|
+
apiUrl: "https://graph.codex.io/graphql", // default
|
|
520
|
+
apiRealtimeUrl: "wss://graph.codex.io/graphql", // default
|
|
521
|
+
ws: true, // enable WebSocket (default: true)
|
|
416
522
|
});
|
|
417
523
|
|
|
418
524
|
// Update config at runtime
|
|
@@ -443,7 +549,7 @@ pnpm run lint # Lint the codebase
|
|
|
443
549
|
|
|
444
550
|
## Releasing
|
|
445
551
|
|
|
446
|
-
On a branch, make your changes then:
|
|
552
|
+
On a branch, make your changes then:
|
|
447
553
|
|
|
448
554
|
- `pnpm run build`
|
|
449
555
|
- change `package.json` version accordingly
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
1
|
export { Codex } from "./sdk";
|
|
2
2
|
export type { ApiConfig, CleanupFunction } from "./sdk";
|
|
3
3
|
export * from "./sdk/generated/graphql";
|
|
4
|
+
/**
|
|
5
|
+
* Recursively marks every field of a type as optional.
|
|
6
|
+
*
|
|
7
|
+
* Useful with `sdk.send()` when your query selects a subset of a type's
|
|
8
|
+
* fields: the exported query types (e.g. `FilterTokensQuery`) describe the
|
|
9
|
+
* full selection, so wrapping them in `DeepPartial` keeps the compiler honest
|
|
10
|
+
* about fields your query didn't ask for.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* const result = await sdk.send<DeepPartial<FilterTokensQuery>>(
|
|
14
|
+
* `query { filterTokens(limit: 10) { results { priceUSD } } }`,
|
|
15
|
+
* );
|
|
16
|
+
*/
|
|
17
|
+
export type DeepPartial<T> = T extends (infer U)[] ? DeepPartial<U>[] : T extends object ? {
|
|
18
|
+
[K in keyof T]?: DeepPartial<T[K]>;
|
|
19
|
+
} : T;
|
package/dist/sdk/Query.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ApiTokenQueryVariables, ApiTokensQueryVariables, BalancesQueryVariables, BlocksQueryVariables, CategoriesQueryVariables, CategoryQueryVariables, CategoryTokensQueryVariables, ChartUrlsQueryVariables, DetailedPredictionEventStatsQueryVariables, DetailedPredictionMarketStatsQueryVariables, DetailedPredictionTraderStatsQueryVariables, DetailedWalletStatsQueryVariables, EventScopedFilterPredictionMarketsQueryVariables, FilterExchangesQueryVariables, FilterPairsQueryVariables, FilterPredictionEventsQueryVariables, FilterPredictionMarketsQueryVariables, FilterPredictionTraderMarketsQueryVariables, FilterPredictionTradersQueryVariables, 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, PredictionCategoriesQueryVariables, PredictionEventBarsQueryVariables, PredictionEventTopMarketsBarsQueryVariables, PredictionMarketBarsQueryVariables, PredictionMarketPriceQueryVariables, PredictionMarketsQueryVariables, PredictionOutcomeOrderBooksQueryVariables, PredictionTokenHoldersQueryVariables, PredictionTraderBarsQueryVariables, PredictionTraderHoldingsQueryVariables, PredictionTraderMarketsStatsQueryVariables, PredictionTradersQueryVariables, PredictionTradesQueryVariables, TokenQueryVariables, TokenSparklinesQueryVariables, TokensQueryVariables, TokenTopTradersQueryVariables, Top10HoldersPercentQueryVariables, WalletAggregateBackfillStateQueryVariables, WalletChartQueryVariables, WalletLabelTypesQueryVariables } from "./generated/graphql";
|
|
1
|
+
import { ApiTokenQueryVariables, ApiTokensQueryVariables, BalancesQueryVariables, BlocksQueryVariables, CategoriesQueryVariables, CategoryQueryVariables, CategoryTokensQueryVariables, ChartUrlsQueryVariables, DetailedPredictionEventStatsQueryVariables, DetailedPredictionMarketStatsQueryVariables, DetailedPredictionTraderStatsQueryVariables, DetailedWalletStatsQueryVariables, EventScopedFilterPredictionMarketsQueryVariables, FilterExchangesQueryVariables, FilterNetworksQueryVariables, FilterPairsQueryVariables, FilterPredictionEventsQueryVariables, FilterPredictionMarketsQueryVariables, FilterPredictionTraderMarketsQueryVariables, FilterPredictionTradersQueryVariables, 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, PredictionCategoriesQueryVariables, PredictionEventBarsQueryVariables, PredictionEventTopMarketsBarsQueryVariables, PredictionMarketBarsQueryVariables, PredictionMarketPriceQueryVariables, PredictionMarketsQueryVariables, PredictionOutcomeOrderBooksQueryVariables, PredictionTokenHoldersQueryVariables, PredictionTraderBarsQueryVariables, PredictionTraderHoldingsQueryVariables, PredictionTraderMarketsStatsQueryVariables, PredictionTradersQueryVariables, PredictionTradesQueryVariables, TokenQueryVariables, TokenSparklinesQueryVariables, TokensQueryVariables, TokenTopTradersQueryVariables, Top10HoldersPercentQueryVariables, WalletAggregateBackfillStateQueryVariables, WalletChartQueryVariables, WalletLabelTypesQueryVariables } from "./generated/graphql";
|
|
2
2
|
import { Codex } from "./index";
|
|
3
3
|
export declare class Query {
|
|
4
4
|
private sdk;
|
|
@@ -17,6 +17,7 @@ export declare class Query {
|
|
|
17
17
|
detailedWalletStats: (vars: DetailedWalletStatsQueryVariables) => Promise<import("./generated/graphql").DetailedWalletStatsQuery>;
|
|
18
18
|
eventScopedFilterPredictionMarkets: (vars: EventScopedFilterPredictionMarketsQueryVariables) => Promise<import("./generated/graphql").EventScopedFilterPredictionMarketsQuery>;
|
|
19
19
|
filterExchanges: (vars: FilterExchangesQueryVariables) => Promise<import("./generated/graphql").FilterExchangesQuery>;
|
|
20
|
+
filterNetworks: (vars: FilterNetworksQueryVariables) => Promise<import("./generated/graphql").FilterNetworksQuery>;
|
|
20
21
|
filterPairs: (vars: FilterPairsQueryVariables) => Promise<import("./generated/graphql").FilterPairsQuery>;
|
|
21
22
|
filterPredictionEvents: (vars: FilterPredictionEventsQueryVariables) => Promise<import("./generated/graphql").FilterPredictionEventsQuery>;
|
|
22
23
|
filterPredictionMarkets: (vars: FilterPredictionMarketsQueryVariables) => Promise<import("./generated/graphql").FilterPredictionMarketsQuery>;
|
package/dist/sdk/Query.js
CHANGED
|
@@ -29,6 +29,7 @@ class Query {
|
|
|
29
29
|
this.detailedWalletStats = (vars) => __awaiter(this, void 0, void 0, function* () { return this.sdk.query(graphql_1.DetailedWalletStatsDocument, vars); });
|
|
30
30
|
this.eventScopedFilterPredictionMarkets = (vars) => __awaiter(this, void 0, void 0, function* () { return this.sdk.query(graphql_1.EventScopedFilterPredictionMarketsDocument, vars); });
|
|
31
31
|
this.filterExchanges = (vars) => __awaiter(this, void 0, void 0, function* () { return this.sdk.query(graphql_1.FilterExchangesDocument, vars); });
|
|
32
|
+
this.filterNetworks = (vars) => __awaiter(this, void 0, void 0, function* () { return this.sdk.query(graphql_1.FilterNetworksDocument, vars); });
|
|
32
33
|
this.filterPairs = (vars) => __awaiter(this, void 0, void 0, function* () { return this.sdk.query(graphql_1.FilterPairsDocument, vars); });
|
|
33
34
|
this.filterPredictionEvents = (vars) => __awaiter(this, void 0, void 0, function* () { return this.sdk.query(graphql_1.FilterPredictionEventsDocument, vars); });
|
|
34
35
|
this.filterPredictionMarkets = (vars) => __awaiter(this, void 0, void 0, function* () { return this.sdk.query(graphql_1.FilterPredictionMarketsDocument, vars); });
|
package/dist/sdk/Query.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// THIS FILE IS AUTOMATICALLY GENERATED, DO NOT EDIT IT DIRECTLY
|
|
2
|
-
import { ApiTokenDocument, ApiTokensDocument, BalancesDocument, BlocksDocument, CategoriesDocument, CategoryDocument, CategoryTokensDocument, ChartUrlsDocument, DetailedPredictionEventStatsDocument, DetailedPredictionMarketStatsDocument, DetailedPredictionTraderStatsDocument, DetailedWalletStatsDocument, EventScopedFilterPredictionMarketsDocument, FilterExchangesDocument, FilterPairsDocument, FilterPredictionEventsDocument, FilterPredictionMarketsDocument, FilterPredictionTraderMarketsDocument, FilterPredictionTradersDocument, FilterTokensDocument, FilterTokenWalletsDocument, FilterWalletsDocument, GetBarsDocument, GetCommunityNotesDocument, GetDetailedPairsStatsDocument, GetDetailedPairStatsDocument, GetDetailedTokenStatsDocument, GetEventLabelsDocument, GetExchangesDocument, GetNetworkConfigsDocument, GetNetworksDocument, GetNetworkStatsDocument, GetNetworkStatusDocument, GetSymbolDocument, GetTokenBarsDocument, GetTokenEventsDocument, GetTokenEventsForMakerDocument, GetTokenPricesDocument, GetWebhooksDocument, HoldersDocument, LiquidityLocksDocument, LiquidityMetadataByTokenDocument, LiquidityMetadataDocument, ListPairsForTokenDocument, ListPairsWithMetadataForTokenDocument, PairMetadataDocument, PredictionCategoriesDocument, PredictionEventBarsDocument, PredictionEventTopMarketsBarsDocument, PredictionMarketBarsDocument, PredictionMarketPriceDocument, PredictionMarketsDocument, PredictionOutcomeOrderBooksDocument, PredictionTokenHoldersDocument, PredictionTraderBarsDocument, PredictionTraderHoldingsDocument, PredictionTraderMarketsStatsDocument, PredictionTradersDocument, PredictionTradesDocument, TokenDocument, TokensDocument, TokenSparklinesDocument, TokenTopTradersDocument, Top10HoldersPercentDocument, WalletAggregateBackfillStateDocument, WalletChartDocument, WalletLabelTypesDocument, } from "./generated/graphql";
|
|
2
|
+
import { ApiTokenDocument, ApiTokensDocument, BalancesDocument, BlocksDocument, CategoriesDocument, CategoryDocument, CategoryTokensDocument, ChartUrlsDocument, DetailedPredictionEventStatsDocument, DetailedPredictionMarketStatsDocument, DetailedPredictionTraderStatsDocument, DetailedWalletStatsDocument, EventScopedFilterPredictionMarketsDocument, FilterExchangesDocument, FilterNetworksDocument, FilterPairsDocument, FilterPredictionEventsDocument, FilterPredictionMarketsDocument, FilterPredictionTraderMarketsDocument, FilterPredictionTradersDocument, FilterTokensDocument, FilterTokenWalletsDocument, FilterWalletsDocument, GetBarsDocument, GetCommunityNotesDocument, GetDetailedPairsStatsDocument, GetDetailedPairStatsDocument, GetDetailedTokenStatsDocument, GetEventLabelsDocument, GetExchangesDocument, GetNetworkConfigsDocument, GetNetworksDocument, GetNetworkStatsDocument, GetNetworkStatusDocument, GetSymbolDocument, GetTokenBarsDocument, GetTokenEventsDocument, GetTokenEventsForMakerDocument, GetTokenPricesDocument, GetWebhooksDocument, HoldersDocument, LiquidityLocksDocument, LiquidityMetadataByTokenDocument, LiquidityMetadataDocument, ListPairsForTokenDocument, ListPairsWithMetadataForTokenDocument, PairMetadataDocument, PredictionCategoriesDocument, PredictionEventBarsDocument, PredictionEventTopMarketsBarsDocument, PredictionMarketBarsDocument, PredictionMarketPriceDocument, PredictionMarketsDocument, PredictionOutcomeOrderBooksDocument, PredictionTokenHoldersDocument, PredictionTraderBarsDocument, PredictionTraderHoldingsDocument, PredictionTraderMarketsStatsDocument, PredictionTradersDocument, PredictionTradesDocument, TokenDocument, TokensDocument, TokenSparklinesDocument, TokenTopTradersDocument, Top10HoldersPercentDocument, WalletAggregateBackfillStateDocument, WalletChartDocument, WalletLabelTypesDocument, } from "./generated/graphql";
|
|
3
3
|
export class Query {
|
|
4
4
|
constructor(sdk) {
|
|
5
5
|
this.sdk = sdk;
|
|
@@ -17,6 +17,7 @@ export class Query {
|
|
|
17
17
|
this.detailedWalletStats = async (vars) => this.sdk.query(DetailedWalletStatsDocument, vars);
|
|
18
18
|
this.eventScopedFilterPredictionMarkets = async (vars) => this.sdk.query(EventScopedFilterPredictionMarketsDocument, vars);
|
|
19
19
|
this.filterExchanges = async (vars) => this.sdk.query(FilterExchangesDocument, vars);
|
|
20
|
+
this.filterNetworks = async (vars) => this.sdk.query(FilterNetworksDocument, vars);
|
|
20
21
|
this.filterPairs = async (vars) => this.sdk.query(FilterPairsDocument, vars);
|
|
21
22
|
this.filterPredictionEvents = async (vars) => this.sdk.query(FilterPredictionEventsDocument, vars);
|
|
22
23
|
this.filterPredictionMarkets = async (vars) => this.sdk.query(FilterPredictionMarketsDocument, vars);
|