opensea-cli 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js ADDED
@@ -0,0 +1,530 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/cli.ts
4
+ import { Command as Command9 } from "commander";
5
+
6
+ // src/client.ts
7
+ var DEFAULT_BASE_URL = "https://api.opensea.io";
8
+ var OpenSeaClient = class {
9
+ apiKey;
10
+ baseUrl;
11
+ defaultChain;
12
+ constructor(config) {
13
+ this.apiKey = config.apiKey;
14
+ this.baseUrl = config.baseUrl ?? DEFAULT_BASE_URL;
15
+ this.defaultChain = config.chain ?? "ethereum";
16
+ }
17
+ async get(path, params) {
18
+ const url = new URL(`${this.baseUrl}${path}`);
19
+ if (params) {
20
+ for (const [key, value] of Object.entries(params)) {
21
+ if (value !== void 0 && value !== null) {
22
+ url.searchParams.set(key, String(value));
23
+ }
24
+ }
25
+ }
26
+ const response = await fetch(url.toString(), {
27
+ method: "GET",
28
+ headers: {
29
+ Accept: "application/json",
30
+ "x-api-key": this.apiKey
31
+ }
32
+ });
33
+ if (!response.ok) {
34
+ const body = await response.text();
35
+ throw new OpenSeaAPIError(response.status, body, path);
36
+ }
37
+ return response.json();
38
+ }
39
+ async post(path) {
40
+ const url = new URL(`${this.baseUrl}${path}`);
41
+ const response = await fetch(url.toString(), {
42
+ method: "POST",
43
+ headers: {
44
+ Accept: "application/json",
45
+ "x-api-key": this.apiKey
46
+ }
47
+ });
48
+ if (!response.ok) {
49
+ const body = await response.text();
50
+ throw new OpenSeaAPIError(response.status, body, path);
51
+ }
52
+ return response.json();
53
+ }
54
+ getDefaultChain() {
55
+ return this.defaultChain;
56
+ }
57
+ };
58
+ var OpenSeaAPIError = class extends Error {
59
+ constructor(statusCode, responseBody, path) {
60
+ super(`OpenSea API error ${statusCode} on ${path}: ${responseBody}`);
61
+ this.statusCode = statusCode;
62
+ this.responseBody = responseBody;
63
+ this.path = path;
64
+ this.name = "OpenSeaAPIError";
65
+ }
66
+ };
67
+
68
+ // src/commands/accounts.ts
69
+ import { Command } from "commander";
70
+
71
+ // src/output.ts
72
+ function formatOutput(data, format) {
73
+ if (format === "table") {
74
+ return formatTable(data);
75
+ }
76
+ return JSON.stringify(data, null, 2);
77
+ }
78
+ function formatTable(data) {
79
+ if (Array.isArray(data)) {
80
+ if (data.length === 0) return "(empty)";
81
+ const keys = Object.keys(data[0]);
82
+ const widths = keys.map(
83
+ (key) => Math.max(
84
+ key.length,
85
+ ...data.map((row) => {
86
+ const val = row[key];
87
+ return String(val ?? "").length;
88
+ })
89
+ )
90
+ );
91
+ const header = keys.map((key, i) => key.padEnd(widths[i])).join(" ");
92
+ const separator = widths.map((w) => "-".repeat(w)).join(" ");
93
+ const rows = data.map(
94
+ (row) => keys.map((key, i) => {
95
+ const val = row[key];
96
+ return String(val ?? "").padEnd(widths[i]);
97
+ }).join(" ")
98
+ );
99
+ return [header, separator, ...rows].join("\n");
100
+ }
101
+ if (data && typeof data === "object") {
102
+ const entries = Object.entries(data);
103
+ const maxKeyLength = Math.max(...entries.map(([k]) => k.length));
104
+ return entries.map(([key, value]) => {
105
+ const displayValue = typeof value === "object" && value !== null ? JSON.stringify(value) : String(value ?? "");
106
+ return `${key.padEnd(maxKeyLength)} ${displayValue}`;
107
+ }).join("\n");
108
+ }
109
+ return String(data);
110
+ }
111
+
112
+ // src/commands/accounts.ts
113
+ function accountsCommand(getClient2, getFormat2) {
114
+ const cmd = new Command("accounts").description("Query accounts");
115
+ cmd.command("get").description("Get an account by address").argument("<address>", "Wallet address").action(async (address) => {
116
+ const client = getClient2();
117
+ const result = await client.get(`/api/v2/accounts/${address}`);
118
+ console.log(formatOutput(result, getFormat2()));
119
+ });
120
+ return cmd;
121
+ }
122
+
123
+ // src/commands/collections.ts
124
+ import { Command as Command2 } from "commander";
125
+ function collectionsCommand(getClient2, getFormat2) {
126
+ const cmd = new Command2("collections").description(
127
+ "Manage and query NFT collections"
128
+ );
129
+ cmd.command("get").description("Get a single collection by slug").argument("<slug>", "Collection slug").action(async (slug) => {
130
+ const client = getClient2();
131
+ const result = await client.get(`/api/v2/collections/${slug}`);
132
+ console.log(formatOutput(result, getFormat2()));
133
+ });
134
+ cmd.command("list").description("List collections").option("--chain <chain>", "Filter by chain").option(
135
+ "--order-by <orderBy>",
136
+ "Order by field (created_date, one_day_change, seven_day_volume, seven_day_change, num_owners, market_cap)"
137
+ ).option("--creator <username>", "Filter by creator username").option("--include-hidden", "Include hidden collections").option("--limit <limit>", "Number of results", "20").option("--next <cursor>", "Pagination cursor").action(
138
+ async (options) => {
139
+ const client = getClient2();
140
+ const result = await client.get("/api/v2/collections", {
141
+ chain: options.chain,
142
+ order_by: options.orderBy,
143
+ creator_username: options.creator,
144
+ include_hidden: options.includeHidden,
145
+ limit: Number.parseInt(options.limit, 10),
146
+ next: options.next
147
+ });
148
+ console.log(formatOutput(result, getFormat2()));
149
+ }
150
+ );
151
+ cmd.command("stats").description("Get collection stats").argument("<slug>", "Collection slug").action(async (slug) => {
152
+ const client = getClient2();
153
+ const result = await client.get(
154
+ `/api/v2/collections/${slug}/stats`
155
+ );
156
+ console.log(formatOutput(result, getFormat2()));
157
+ });
158
+ cmd.command("traits").description("Get collection traits").argument("<slug>", "Collection slug").action(async (slug) => {
159
+ const client = getClient2();
160
+ const result = await client.get(
161
+ `/api/v2/traits/${slug}`
162
+ );
163
+ console.log(formatOutput(result, getFormat2()));
164
+ });
165
+ return cmd;
166
+ }
167
+
168
+ // src/commands/events.ts
169
+ import { Command as Command3 } from "commander";
170
+ function eventsCommand(getClient2, getFormat2) {
171
+ const cmd = new Command3("events").description("Query marketplace events");
172
+ cmd.command("list").description("List events").option(
173
+ "--event-type <type>",
174
+ "Event type (sale, transfer, mint, listing, offer, trait_offer, collection_offer)"
175
+ ).option("--after <timestamp>", "Filter events after this Unix timestamp").option("--before <timestamp>", "Filter events before this Unix timestamp").option("--chain <chain>", "Filter by chain").option("--limit <limit>", "Number of results", "20").option("--next <cursor>", "Pagination cursor").action(
176
+ async (options) => {
177
+ const client = getClient2();
178
+ const result = await client.get("/api/v2/events", {
179
+ event_type: options.eventType,
180
+ after: options.after ? Number.parseInt(options.after, 10) : void 0,
181
+ before: options.before ? Number.parseInt(options.before, 10) : void 0,
182
+ chain: options.chain,
183
+ limit: Number.parseInt(options.limit, 10),
184
+ next: options.next
185
+ });
186
+ console.log(formatOutput(result, getFormat2()));
187
+ }
188
+ );
189
+ cmd.command("by-account").description("Get events for an account").argument("<address>", "Account address").option("--event-type <type>", "Event type").option("--chain <chain>", "Filter by chain").option("--limit <limit>", "Number of results", "20").option("--next <cursor>", "Pagination cursor").action(
190
+ async (address, options) => {
191
+ const client = getClient2();
192
+ const result = await client.get(`/api/v2/events/accounts/${address}`, {
193
+ event_type: options.eventType,
194
+ chain: options.chain,
195
+ limit: Number.parseInt(options.limit, 10),
196
+ next: options.next
197
+ });
198
+ console.log(formatOutput(result, getFormat2()));
199
+ }
200
+ );
201
+ cmd.command("by-collection").description("Get events for a collection").argument("<slug>", "Collection slug").option("--event-type <type>", "Event type").option("--limit <limit>", "Number of results", "20").option("--next <cursor>", "Pagination cursor").action(
202
+ async (slug, options) => {
203
+ const client = getClient2();
204
+ const result = await client.get(`/api/v2/events/collection/${slug}`, {
205
+ event_type: options.eventType,
206
+ limit: Number.parseInt(options.limit, 10),
207
+ next: options.next
208
+ });
209
+ console.log(formatOutput(result, getFormat2()));
210
+ }
211
+ );
212
+ cmd.command("by-nft").description("Get events for a specific NFT").argument("<chain>", "Chain").argument("<contract>", "Contract address").argument("<token-id>", "Token ID").option("--event-type <type>", "Event type").option("--limit <limit>", "Number of results", "20").option("--next <cursor>", "Pagination cursor").action(
213
+ async (chain, contract, tokenId, options) => {
214
+ const client = getClient2();
215
+ const result = await client.get(
216
+ `/api/v2/events/chain/${chain}/contract/${contract}/nfts/${tokenId}`,
217
+ {
218
+ event_type: options.eventType,
219
+ limit: Number.parseInt(options.limit, 10),
220
+ next: options.next
221
+ }
222
+ );
223
+ console.log(formatOutput(result, getFormat2()));
224
+ }
225
+ );
226
+ return cmd;
227
+ }
228
+
229
+ // src/commands/listings.ts
230
+ import { Command as Command4 } from "commander";
231
+ function listingsCommand(getClient2, getFormat2) {
232
+ const cmd = new Command4("listings").description("Query NFT listings");
233
+ cmd.command("all").description("Get all listings for a collection").argument("<collection>", "Collection slug").option("--limit <limit>", "Number of results", "20").option("--next <cursor>", "Pagination cursor").action(
234
+ async (collection, options) => {
235
+ const client = getClient2();
236
+ const result = await client.get(`/api/v2/listings/collection/${collection}/all`, {
237
+ limit: Number.parseInt(options.limit, 10),
238
+ next: options.next
239
+ });
240
+ console.log(formatOutput(result, getFormat2()));
241
+ }
242
+ );
243
+ cmd.command("best").description("Get best listings for a collection").argument("<collection>", "Collection slug").option("--limit <limit>", "Number of results", "20").option("--next <cursor>", "Pagination cursor").action(
244
+ async (collection, options) => {
245
+ const client = getClient2();
246
+ const result = await client.get(`/api/v2/listings/collection/${collection}/best`, {
247
+ limit: Number.parseInt(options.limit, 10),
248
+ next: options.next
249
+ });
250
+ console.log(formatOutput(result, getFormat2()));
251
+ }
252
+ );
253
+ cmd.command("best-for-nft").description("Get best listing for a specific NFT").argument("<collection>", "Collection slug").argument("<token-id>", "Token ID").action(async (collection, tokenId) => {
254
+ const client = getClient2();
255
+ const result = await client.get(
256
+ `/api/v2/listings/collection/${collection}/nfts/${tokenId}/best`
257
+ );
258
+ console.log(formatOutput(result, getFormat2()));
259
+ });
260
+ return cmd;
261
+ }
262
+
263
+ // src/commands/nfts.ts
264
+ import { Command as Command5 } from "commander";
265
+ function nftsCommand(getClient2, getFormat2) {
266
+ const cmd = new Command5("nfts").description("Query NFTs");
267
+ cmd.command("get").description("Get a single NFT").argument("<chain>", "Chain (e.g. ethereum, base)").argument("<contract>", "Contract address").argument("<token-id>", "Token ID").action(async (chain, contract, tokenId) => {
268
+ const client = getClient2();
269
+ const result = await client.get(
270
+ `/api/v2/chain/${chain}/contract/${contract}/nfts/${tokenId}`
271
+ );
272
+ console.log(formatOutput(result, getFormat2()));
273
+ });
274
+ cmd.command("list-by-collection").description("List NFTs in a collection").argument("<slug>", "Collection slug").option("--limit <limit>", "Number of results", "20").option("--next <cursor>", "Pagination cursor").action(async (slug, options) => {
275
+ const client = getClient2();
276
+ const result = await client.get(
277
+ `/api/v2/collection/${slug}/nfts`,
278
+ {
279
+ limit: Number.parseInt(options.limit, 10),
280
+ next: options.next
281
+ }
282
+ );
283
+ console.log(formatOutput(result, getFormat2()));
284
+ });
285
+ cmd.command("list-by-contract").description("List NFTs by contract address").argument("<chain>", "Chain").argument("<contract>", "Contract address").option("--limit <limit>", "Number of results", "20").option("--next <cursor>", "Pagination cursor").action(
286
+ async (chain, contract, options) => {
287
+ const client = getClient2();
288
+ const result = await client.get(
289
+ `/api/v2/chain/${chain}/contract/${contract}/nfts`,
290
+ {
291
+ limit: Number.parseInt(options.limit, 10),
292
+ next: options.next
293
+ }
294
+ );
295
+ console.log(formatOutput(result, getFormat2()));
296
+ }
297
+ );
298
+ cmd.command("list-by-account").description("List NFTs owned by an account").argument("<chain>", "Chain").argument("<address>", "Account address").option("--limit <limit>", "Number of results", "20").option("--next <cursor>", "Pagination cursor").action(
299
+ async (chain, address, options) => {
300
+ const client = getClient2();
301
+ const result = await client.get(
302
+ `/api/v2/chain/${chain}/account/${address}/nfts`,
303
+ {
304
+ limit: Number.parseInt(options.limit, 10),
305
+ next: options.next
306
+ }
307
+ );
308
+ console.log(formatOutput(result, getFormat2()));
309
+ }
310
+ );
311
+ cmd.command("refresh").description("Refresh NFT metadata").argument("<chain>", "Chain").argument("<contract>", "Contract address").argument("<token-id>", "Token ID").action(async (chain, contract, tokenId) => {
312
+ const client = getClient2();
313
+ await client.post(
314
+ `/api/v2/chain/${chain}/contract/${contract}/nfts/${tokenId}/refresh`
315
+ );
316
+ console.log(
317
+ formatOutput(
318
+ { status: "ok", message: "Metadata refresh requested" },
319
+ getFormat2()
320
+ )
321
+ );
322
+ });
323
+ cmd.command("contract").description("Get contract details").argument("<chain>", "Chain").argument("<address>", "Contract address").action(async (chain, address) => {
324
+ const client = getClient2();
325
+ const result = await client.get(
326
+ `/api/v2/chain/${chain}/contract/${address}`
327
+ );
328
+ console.log(formatOutput(result, getFormat2()));
329
+ });
330
+ return cmd;
331
+ }
332
+
333
+ // src/commands/offers.ts
334
+ import { Command as Command6 } from "commander";
335
+ function offersCommand(getClient2, getFormat2) {
336
+ const cmd = new Command6("offers").description("Query NFT offers");
337
+ cmd.command("all").description("Get all offers for a collection").argument("<collection>", "Collection slug").option("--limit <limit>", "Number of results", "20").option("--next <cursor>", "Pagination cursor").action(
338
+ async (collection, options) => {
339
+ const client = getClient2();
340
+ const result = await client.get(`/api/v2/offers/collection/${collection}/all`, {
341
+ limit: Number.parseInt(options.limit, 10),
342
+ next: options.next
343
+ });
344
+ console.log(formatOutput(result, getFormat2()));
345
+ }
346
+ );
347
+ cmd.command("collection").description("Get collection offers").argument("<collection>", "Collection slug").option("--limit <limit>", "Number of results", "20").option("--next <cursor>", "Pagination cursor").action(
348
+ async (collection, options) => {
349
+ const client = getClient2();
350
+ const result = await client.get(`/api/v2/offers/collection/${collection}`, {
351
+ limit: Number.parseInt(options.limit, 10),
352
+ next: options.next
353
+ });
354
+ console.log(formatOutput(result, getFormat2()));
355
+ }
356
+ );
357
+ cmd.command("best-for-nft").description("Get best offer for a specific NFT").argument("<collection>", "Collection slug").argument("<token-id>", "Token ID").action(async (collection, tokenId) => {
358
+ const client = getClient2();
359
+ const result = await client.get(
360
+ `/api/v2/offers/collection/${collection}/nfts/${tokenId}/best`
361
+ );
362
+ console.log(formatOutput(result, getFormat2()));
363
+ });
364
+ cmd.command("traits").description("Get trait offers for a collection").argument("<collection>", "Collection slug").requiredOption("--type <type>", "Trait type (required)").requiredOption("--value <value>", "Trait value (required)").option("--limit <limit>", "Number of results", "20").option("--next <cursor>", "Pagination cursor").action(
365
+ async (collection, options) => {
366
+ const client = getClient2();
367
+ const result = await client.get(`/api/v2/offers/collection/${collection}/traits`, {
368
+ type: options.type,
369
+ value: options.value,
370
+ limit: Number.parseInt(options.limit, 10),
371
+ next: options.next
372
+ });
373
+ console.log(formatOutput(result, getFormat2()));
374
+ }
375
+ );
376
+ return cmd;
377
+ }
378
+
379
+ // src/commands/swaps.ts
380
+ import { Command as Command7 } from "commander";
381
+ function swapsCommand(getClient2, getFormat2) {
382
+ const cmd = new Command7("swaps").description(
383
+ "Get swap quotes for token trading"
384
+ );
385
+ cmd.command("quote").description(
386
+ "Get a quote for swapping tokens, including price details and executable transaction data"
387
+ ).requiredOption("--from-chain <chain>", "Chain of the token to swap from").requiredOption(
388
+ "--from-address <address>",
389
+ "Contract address of the token to swap from"
390
+ ).requiredOption("--to-chain <chain>", "Chain of the token to swap to").requiredOption(
391
+ "--to-address <address>",
392
+ "Contract address of the token to swap to"
393
+ ).requiredOption("--quantity <quantity>", "Amount to swap (in token units)").requiredOption("--address <address>", "Wallet address executing the swap").option(
394
+ "--slippage <slippage>",
395
+ "Slippage tolerance (0.0 to 0.5, default: 0.01)"
396
+ ).option(
397
+ "--recipient <recipient>",
398
+ "Recipient address (defaults to sender address)"
399
+ ).action(
400
+ async (options) => {
401
+ const client = getClient2();
402
+ const result = await client.get(
403
+ "/api/v2/swap/quote",
404
+ {
405
+ from_chain: options.fromChain,
406
+ from_address: options.fromAddress,
407
+ to_chain: options.toChain,
408
+ to_address: options.toAddress,
409
+ quantity: options.quantity,
410
+ address: options.address,
411
+ slippage: options.slippage ? Number.parseFloat(options.slippage) : void 0,
412
+ recipient: options.recipient
413
+ }
414
+ );
415
+ console.log(formatOutput(result, getFormat2()));
416
+ }
417
+ );
418
+ return cmd;
419
+ }
420
+
421
+ // src/commands/tokens.ts
422
+ import { Command as Command8 } from "commander";
423
+ function tokensCommand(getClient2, getFormat2) {
424
+ const cmd = new Command8("tokens").description(
425
+ "Query trending tokens, top tokens, and token details"
426
+ );
427
+ cmd.command("trending").description("Get trending tokens based on OpenSea's trending score").option("--chains <chains>", "Comma-separated list of chains to filter by").option("--limit <limit>", "Number of results (max 100)", "20").option("--cursor <cursor>", "Pagination cursor").action(
428
+ async (options) => {
429
+ const client = getClient2();
430
+ const result = await client.get(
431
+ "/api/v2/tokens/trending",
432
+ {
433
+ chains: options.chains,
434
+ limit: Number.parseInt(options.limit, 10),
435
+ cursor: options.cursor
436
+ }
437
+ );
438
+ console.log(formatOutput(result, getFormat2()));
439
+ }
440
+ );
441
+ cmd.command("top").description("Get top tokens ranked by 24-hour trading volume").option("--chains <chains>", "Comma-separated list of chains to filter by").option("--limit <limit>", "Number of results (max 100)", "20").option("--cursor <cursor>", "Pagination cursor").action(
442
+ async (options) => {
443
+ const client = getClient2();
444
+ const result = await client.get(
445
+ "/api/v2/tokens/top",
446
+ {
447
+ chains: options.chains,
448
+ limit: Number.parseInt(options.limit, 10),
449
+ cursor: options.cursor
450
+ }
451
+ );
452
+ console.log(formatOutput(result, getFormat2()));
453
+ }
454
+ );
455
+ cmd.command("get").description("Get detailed information about a specific token").argument("<chain>", "Blockchain chain").argument("<address>", "Token contract address").action(async (chain, address) => {
456
+ const client = getClient2();
457
+ const result = await client.get(
458
+ `/api/v2/chain/${chain}/token/${address}`
459
+ );
460
+ console.log(formatOutput(result, getFormat2()));
461
+ });
462
+ return cmd;
463
+ }
464
+
465
+ // src/cli.ts
466
+ var BANNER = `
467
+ ____ _____
468
+ / __ \\ / ____|
469
+ | | | |_ __ ___ _ _| (___ ___ __ _
470
+ | | | | '_ \\ / _ \\ '_ \\___ \\ / _ \\/ _\` |
471
+ | |__| | |_) | __/ | | |___) | __/ (_| |
472
+ \\____/| .__/ \\___|_| |_|____/ \\___|\\__,_|
473
+ | |
474
+ |_|
475
+ `;
476
+ var program = new Command9();
477
+ program.name("opensea").description("OpenSea CLI - Query the OpenSea API from the command line").version("0.1.0").addHelpText("before", BANNER).option("--api-key <key>", "OpenSea API key (or set OPENSEA_API_KEY env var)").option("--chain <chain>", "Default chain", "ethereum").option("--format <format>", "Output format (json or table)", "json").option("--base-url <url>", "API base URL");
478
+ function getClient() {
479
+ const opts = program.opts();
480
+ const apiKey = opts.apiKey ?? process.env.OPENSEA_API_KEY;
481
+ if (!apiKey) {
482
+ console.error(
483
+ "Error: API key required. Use --api-key or set OPENSEA_API_KEY environment variable."
484
+ );
485
+ process.exit(2);
486
+ }
487
+ return new OpenSeaClient({
488
+ apiKey,
489
+ chain: opts.chain,
490
+ baseUrl: opts.baseUrl
491
+ });
492
+ }
493
+ function getFormat() {
494
+ const opts = program.opts();
495
+ return opts.format === "table" ? "table" : "json";
496
+ }
497
+ program.addCommand(collectionsCommand(getClient, getFormat));
498
+ program.addCommand(nftsCommand(getClient, getFormat));
499
+ program.addCommand(listingsCommand(getClient, getFormat));
500
+ program.addCommand(offersCommand(getClient, getFormat));
501
+ program.addCommand(eventsCommand(getClient, getFormat));
502
+ program.addCommand(accountsCommand(getClient, getFormat));
503
+ program.addCommand(tokensCommand(getClient, getFormat));
504
+ program.addCommand(swapsCommand(getClient, getFormat));
505
+ program.hook("postAction", () => {
506
+ });
507
+ async function main() {
508
+ try {
509
+ await program.parseAsync(process.argv);
510
+ } catch (error) {
511
+ if (error instanceof OpenSeaAPIError) {
512
+ console.error(
513
+ JSON.stringify(
514
+ {
515
+ error: "API Error",
516
+ status: error.statusCode,
517
+ path: error.path,
518
+ message: error.responseBody
519
+ },
520
+ null,
521
+ 2
522
+ )
523
+ );
524
+ process.exit(1);
525
+ }
526
+ throw error;
527
+ }
528
+ }
529
+ main();
530
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/cli.ts","../src/client.ts","../src/commands/accounts.ts","../src/output.ts","../src/commands/collections.ts","../src/commands/events.ts","../src/commands/listings.ts","../src/commands/nfts.ts","../src/commands/offers.ts","../src/commands/swaps.ts","../src/commands/tokens.ts"],"sourcesContent":["import { Command } from \"commander\"\nimport { OpenSeaAPIError, OpenSeaClient } from \"./client.js\"\nimport {\n accountsCommand,\n collectionsCommand,\n eventsCommand,\n listingsCommand,\n nftsCommand,\n offersCommand,\n swapsCommand,\n tokensCommand,\n} from \"./commands/index.js\"\n\nconst BANNER = `\n ____ _____\n / __ \\\\ / ____|\n | | | |_ __ ___ _ _| (___ ___ __ _\n | | | | '_ \\\\ / _ \\\\ '_ \\\\___ \\\\ / _ \\\\/ _\\` |\n | |__| | |_) | __/ | | |___) | __/ (_| |\n \\\\____/| .__/ \\\\___|_| |_|____/ \\\\___|\\\\__,_|\n | |\n |_|\n`\n\nconst program = new Command()\n\nprogram\n .name(\"opensea\")\n .description(\"OpenSea CLI - Query the OpenSea API from the command line\")\n .version(\"0.1.0\")\n .addHelpText(\"before\", BANNER)\n .option(\"--api-key <key>\", \"OpenSea API key (or set OPENSEA_API_KEY env var)\")\n .option(\"--chain <chain>\", \"Default chain\", \"ethereum\")\n .option(\"--format <format>\", \"Output format (json or table)\", \"json\")\n .option(\"--base-url <url>\", \"API base URL\")\n\nfunction getClient(): OpenSeaClient {\n const opts = program.opts<{\n apiKey?: string\n chain: string\n baseUrl?: string\n }>()\n\n const apiKey = opts.apiKey ?? process.env.OPENSEA_API_KEY\n if (!apiKey) {\n console.error(\n \"Error: API key required. Use --api-key or set OPENSEA_API_KEY environment variable.\",\n )\n process.exit(2)\n }\n\n return new OpenSeaClient({\n apiKey,\n chain: opts.chain,\n baseUrl: opts.baseUrl,\n })\n}\n\nfunction getFormat(): \"json\" | \"table\" {\n const opts = program.opts<{ format: string }>()\n return opts.format === \"table\" ? \"table\" : \"json\"\n}\n\nprogram.addCommand(collectionsCommand(getClient, getFormat))\nprogram.addCommand(nftsCommand(getClient, getFormat))\nprogram.addCommand(listingsCommand(getClient, getFormat))\nprogram.addCommand(offersCommand(getClient, getFormat))\nprogram.addCommand(eventsCommand(getClient, getFormat))\nprogram.addCommand(accountsCommand(getClient, getFormat))\nprogram.addCommand(tokensCommand(getClient, getFormat))\nprogram.addCommand(swapsCommand(getClient, getFormat))\n\nprogram.hook(\"postAction\", () => {})\n\nasync function main() {\n try {\n await program.parseAsync(process.argv)\n } catch (error) {\n if (error instanceof OpenSeaAPIError) {\n console.error(\n JSON.stringify(\n {\n error: \"API Error\",\n status: error.statusCode,\n path: error.path,\n message: error.responseBody,\n },\n null,\n 2,\n ),\n )\n process.exit(1)\n }\n throw error\n }\n}\n\nmain()\n","import type { OpenSeaClientConfig } from \"./types/index.js\"\n\nconst DEFAULT_BASE_URL = \"https://api.opensea.io\"\n\nexport class OpenSeaClient {\n private apiKey: string\n private baseUrl: string\n private defaultChain: string\n\n constructor(config: OpenSeaClientConfig) {\n this.apiKey = config.apiKey\n this.baseUrl = config.baseUrl ?? DEFAULT_BASE_URL\n this.defaultChain = config.chain ?? \"ethereum\"\n }\n\n async get<T>(path: string, params?: Record<string, unknown>): Promise<T> {\n const url = new URL(`${this.baseUrl}${path}`)\n\n if (params) {\n for (const [key, value] of Object.entries(params)) {\n if (value !== undefined && value !== null) {\n url.searchParams.set(key, String(value))\n }\n }\n }\n\n const response = await fetch(url.toString(), {\n method: \"GET\",\n headers: {\n Accept: \"application/json\",\n \"x-api-key\": this.apiKey,\n },\n })\n\n if (!response.ok) {\n const body = await response.text()\n throw new OpenSeaAPIError(response.status, body, path)\n }\n\n return response.json() as Promise<T>\n }\n\n async post<T>(path: string): Promise<T> {\n const url = new URL(`${this.baseUrl}${path}`)\n\n const response = await fetch(url.toString(), {\n method: \"POST\",\n headers: {\n Accept: \"application/json\",\n \"x-api-key\": this.apiKey,\n },\n })\n\n if (!response.ok) {\n const body = await response.text()\n throw new OpenSeaAPIError(response.status, body, path)\n }\n\n return response.json() as Promise<T>\n }\n\n getDefaultChain(): string {\n return this.defaultChain\n }\n}\n\nexport class OpenSeaAPIError extends Error {\n constructor(\n public statusCode: number,\n public responseBody: string,\n public path: string,\n ) {\n super(`OpenSea API error ${statusCode} on ${path}: ${responseBody}`)\n this.name = \"OpenSeaAPIError\"\n }\n}\n","import { Command } from \"commander\"\nimport type { OpenSeaClient } from \"../client.js\"\nimport { formatOutput } from \"../output.js\"\nimport type { Account } from \"../types/index.js\"\n\nexport function accountsCommand(\n getClient: () => OpenSeaClient,\n getFormat: () => \"json\" | \"table\",\n): Command {\n const cmd = new Command(\"accounts\").description(\"Query accounts\")\n\n cmd\n .command(\"get\")\n .description(\"Get an account by address\")\n .argument(\"<address>\", \"Wallet address\")\n .action(async (address: string) => {\n const client = getClient()\n const result = await client.get<Account>(`/api/v2/accounts/${address}`)\n console.log(formatOutput(result, getFormat()))\n })\n\n return cmd\n}\n","export function formatOutput(data: unknown, format: \"json\" | \"table\"): string {\n if (format === \"table\") {\n return formatTable(data)\n }\n return JSON.stringify(data, null, 2)\n}\n\nfunction formatTable(data: unknown): string {\n if (Array.isArray(data)) {\n if (data.length === 0) return \"(empty)\"\n const keys = Object.keys(data[0] as Record<string, unknown>)\n const widths = keys.map(key =>\n Math.max(\n key.length,\n ...data.map(row => {\n const val = (row as Record<string, unknown>)[key]\n return String(val ?? \"\").length\n }),\n ),\n )\n\n const header = keys.map((key, i) => key.padEnd(widths[i])).join(\" \")\n const separator = widths.map(w => \"-\".repeat(w)).join(\" \")\n const rows = data.map(row =>\n keys\n .map((key, i) => {\n const val = (row as Record<string, unknown>)[key]\n return String(val ?? \"\").padEnd(widths[i])\n })\n .join(\" \"),\n )\n\n return [header, separator, ...rows].join(\"\\n\")\n }\n\n if (data && typeof data === \"object\") {\n const entries = Object.entries(data as Record<string, unknown>)\n const maxKeyLength = Math.max(...entries.map(([k]) => k.length))\n return entries\n .map(([key, value]) => {\n const displayValue =\n typeof value === \"object\" && value !== null\n ? JSON.stringify(value)\n : String(value ?? \"\")\n return `${key.padEnd(maxKeyLength)} ${displayValue}`\n })\n .join(\"\\n\")\n }\n\n return String(data)\n}\n","import { Command } from \"commander\"\nimport type { OpenSeaClient } from \"../client.js\"\nimport { formatOutput } from \"../output.js\"\nimport type {\n Chain,\n Collection,\n CollectionOrderBy,\n CollectionStats,\n GetTraitsResponse,\n} from \"../types/index.js\"\n\nexport function collectionsCommand(\n getClient: () => OpenSeaClient,\n getFormat: () => \"json\" | \"table\",\n): Command {\n const cmd = new Command(\"collections\").description(\n \"Manage and query NFT collections\",\n )\n\n cmd\n .command(\"get\")\n .description(\"Get a single collection by slug\")\n .argument(\"<slug>\", \"Collection slug\")\n .action(async (slug: string) => {\n const client = getClient()\n const result = await client.get<Collection>(`/api/v2/collections/${slug}`)\n console.log(formatOutput(result, getFormat()))\n })\n\n cmd\n .command(\"list\")\n .description(\"List collections\")\n .option(\"--chain <chain>\", \"Filter by chain\")\n .option(\n \"--order-by <orderBy>\",\n \"Order by field (created_date, one_day_change, seven_day_volume, seven_day_change, num_owners, market_cap)\",\n )\n .option(\"--creator <username>\", \"Filter by creator username\")\n .option(\"--include-hidden\", \"Include hidden collections\")\n .option(\"--limit <limit>\", \"Number of results\", \"20\")\n .option(\"--next <cursor>\", \"Pagination cursor\")\n .action(\n async (options: {\n chain?: string\n orderBy?: string\n creator?: string\n includeHidden?: boolean\n limit: string\n next?: string\n }) => {\n const client = getClient()\n const result = await client.get<{\n collections: Collection[]\n next?: string\n }>(\"/api/v2/collections\", {\n chain: options.chain as Chain | undefined,\n order_by: options.orderBy as CollectionOrderBy | undefined,\n creator_username: options.creator,\n include_hidden: options.includeHidden,\n limit: Number.parseInt(options.limit, 10),\n next: options.next,\n })\n console.log(formatOutput(result, getFormat()))\n },\n )\n\n cmd\n .command(\"stats\")\n .description(\"Get collection stats\")\n .argument(\"<slug>\", \"Collection slug\")\n .action(async (slug: string) => {\n const client = getClient()\n const result = await client.get<CollectionStats>(\n `/api/v2/collections/${slug}/stats`,\n )\n console.log(formatOutput(result, getFormat()))\n })\n\n cmd\n .command(\"traits\")\n .description(\"Get collection traits\")\n .argument(\"<slug>\", \"Collection slug\")\n .action(async (slug: string) => {\n const client = getClient()\n const result = await client.get<GetTraitsResponse>(\n `/api/v2/traits/${slug}`,\n )\n console.log(formatOutput(result, getFormat()))\n })\n\n return cmd\n}\n","import { Command } from \"commander\"\nimport type { OpenSeaClient } from \"../client.js\"\nimport { formatOutput } from \"../output.js\"\nimport type { AssetEvent } from \"../types/index.js\"\n\nexport function eventsCommand(\n getClient: () => OpenSeaClient,\n getFormat: () => \"json\" | \"table\",\n): Command {\n const cmd = new Command(\"events\").description(\"Query marketplace events\")\n\n cmd\n .command(\"list\")\n .description(\"List events\")\n .option(\n \"--event-type <type>\",\n \"Event type (sale, transfer, mint, listing, offer, trait_offer, collection_offer)\",\n )\n .option(\"--after <timestamp>\", \"Filter events after this Unix timestamp\")\n .option(\"--before <timestamp>\", \"Filter events before this Unix timestamp\")\n .option(\"--chain <chain>\", \"Filter by chain\")\n .option(\"--limit <limit>\", \"Number of results\", \"20\")\n .option(\"--next <cursor>\", \"Pagination cursor\")\n .action(\n async (options: {\n eventType?: string\n after?: string\n before?: string\n chain?: string\n limit: string\n next?: string\n }) => {\n const client = getClient()\n const result = await client.get<{\n asset_events: AssetEvent[]\n next?: string\n }>(\"/api/v2/events\", {\n event_type: options.eventType,\n after: options.after ? Number.parseInt(options.after, 10) : undefined,\n before: options.before\n ? Number.parseInt(options.before, 10)\n : undefined,\n chain: options.chain,\n limit: Number.parseInt(options.limit, 10),\n next: options.next,\n })\n console.log(formatOutput(result, getFormat()))\n },\n )\n\n cmd\n .command(\"by-account\")\n .description(\"Get events for an account\")\n .argument(\"<address>\", \"Account address\")\n .option(\"--event-type <type>\", \"Event type\")\n .option(\"--chain <chain>\", \"Filter by chain\")\n .option(\"--limit <limit>\", \"Number of results\", \"20\")\n .option(\"--next <cursor>\", \"Pagination cursor\")\n .action(\n async (\n address: string,\n options: {\n eventType?: string\n chain?: string\n limit: string\n next?: string\n },\n ) => {\n const client = getClient()\n const result = await client.get<{\n asset_events: AssetEvent[]\n next?: string\n }>(`/api/v2/events/accounts/${address}`, {\n event_type: options.eventType,\n chain: options.chain,\n limit: Number.parseInt(options.limit, 10),\n next: options.next,\n })\n console.log(formatOutput(result, getFormat()))\n },\n )\n\n cmd\n .command(\"by-collection\")\n .description(\"Get events for a collection\")\n .argument(\"<slug>\", \"Collection slug\")\n .option(\"--event-type <type>\", \"Event type\")\n .option(\"--limit <limit>\", \"Number of results\", \"20\")\n .option(\"--next <cursor>\", \"Pagination cursor\")\n .action(\n async (\n slug: string,\n options: {\n eventType?: string\n limit: string\n next?: string\n },\n ) => {\n const client = getClient()\n const result = await client.get<{\n asset_events: AssetEvent[]\n next?: string\n }>(`/api/v2/events/collection/${slug}`, {\n event_type: options.eventType,\n limit: Number.parseInt(options.limit, 10),\n next: options.next,\n })\n console.log(formatOutput(result, getFormat()))\n },\n )\n\n cmd\n .command(\"by-nft\")\n .description(\"Get events for a specific NFT\")\n .argument(\"<chain>\", \"Chain\")\n .argument(\"<contract>\", \"Contract address\")\n .argument(\"<token-id>\", \"Token ID\")\n .option(\"--event-type <type>\", \"Event type\")\n .option(\"--limit <limit>\", \"Number of results\", \"20\")\n .option(\"--next <cursor>\", \"Pagination cursor\")\n .action(\n async (\n chain: string,\n contract: string,\n tokenId: string,\n options: {\n eventType?: string\n limit: string\n next?: string\n },\n ) => {\n const client = getClient()\n const result = await client.get<{\n asset_events: AssetEvent[]\n next?: string\n }>(\n `/api/v2/events/chain/${chain}/contract/${contract}/nfts/${tokenId}`,\n {\n event_type: options.eventType,\n limit: Number.parseInt(options.limit, 10),\n next: options.next,\n },\n )\n console.log(formatOutput(result, getFormat()))\n },\n )\n\n return cmd\n}\n","import { Command } from \"commander\"\nimport type { OpenSeaClient } from \"../client.js\"\nimport { formatOutput } from \"../output.js\"\nimport type { Listing } from \"../types/index.js\"\n\nexport function listingsCommand(\n getClient: () => OpenSeaClient,\n getFormat: () => \"json\" | \"table\",\n): Command {\n const cmd = new Command(\"listings\").description(\"Query NFT listings\")\n\n cmd\n .command(\"all\")\n .description(\"Get all listings for a collection\")\n .argument(\"<collection>\", \"Collection slug\")\n .option(\"--limit <limit>\", \"Number of results\", \"20\")\n .option(\"--next <cursor>\", \"Pagination cursor\")\n .action(\n async (collection: string, options: { limit: string; next?: string }) => {\n const client = getClient()\n const result = await client.get<{\n listings: Listing[]\n next?: string\n }>(`/api/v2/listings/collection/${collection}/all`, {\n limit: Number.parseInt(options.limit, 10),\n next: options.next,\n })\n console.log(formatOutput(result, getFormat()))\n },\n )\n\n cmd\n .command(\"best\")\n .description(\"Get best listings for a collection\")\n .argument(\"<collection>\", \"Collection slug\")\n .option(\"--limit <limit>\", \"Number of results\", \"20\")\n .option(\"--next <cursor>\", \"Pagination cursor\")\n .action(\n async (collection: string, options: { limit: string; next?: string }) => {\n const client = getClient()\n const result = await client.get<{\n listings: Listing[]\n next?: string\n }>(`/api/v2/listings/collection/${collection}/best`, {\n limit: Number.parseInt(options.limit, 10),\n next: options.next,\n })\n console.log(formatOutput(result, getFormat()))\n },\n )\n\n cmd\n .command(\"best-for-nft\")\n .description(\"Get best listing for a specific NFT\")\n .argument(\"<collection>\", \"Collection slug\")\n .argument(\"<token-id>\", \"Token ID\")\n .action(async (collection: string, tokenId: string) => {\n const client = getClient()\n const result = await client.get<Listing>(\n `/api/v2/listings/collection/${collection}/nfts/${tokenId}/best`,\n )\n console.log(formatOutput(result, getFormat()))\n })\n\n return cmd\n}\n","import { Command } from \"commander\"\nimport type { OpenSeaClient } from \"../client.js\"\nimport { formatOutput } from \"../output.js\"\nimport type { Contract, NFT } from \"../types/index.js\"\n\nexport function nftsCommand(\n getClient: () => OpenSeaClient,\n getFormat: () => \"json\" | \"table\",\n): Command {\n const cmd = new Command(\"nfts\").description(\"Query NFTs\")\n\n cmd\n .command(\"get\")\n .description(\"Get a single NFT\")\n .argument(\"<chain>\", \"Chain (e.g. ethereum, base)\")\n .argument(\"<contract>\", \"Contract address\")\n .argument(\"<token-id>\", \"Token ID\")\n .action(async (chain: string, contract: string, tokenId: string) => {\n const client = getClient()\n const result = await client.get<{ nft: NFT }>(\n `/api/v2/chain/${chain}/contract/${contract}/nfts/${tokenId}`,\n )\n console.log(formatOutput(result, getFormat()))\n })\n\n cmd\n .command(\"list-by-collection\")\n .description(\"List NFTs in a collection\")\n .argument(\"<slug>\", \"Collection slug\")\n .option(\"--limit <limit>\", \"Number of results\", \"20\")\n .option(\"--next <cursor>\", \"Pagination cursor\")\n .action(async (slug: string, options: { limit: string; next?: string }) => {\n const client = getClient()\n const result = await client.get<{ nfts: NFT[]; next?: string }>(\n `/api/v2/collection/${slug}/nfts`,\n {\n limit: Number.parseInt(options.limit, 10),\n next: options.next,\n },\n )\n console.log(formatOutput(result, getFormat()))\n })\n\n cmd\n .command(\"list-by-contract\")\n .description(\"List NFTs by contract address\")\n .argument(\"<chain>\", \"Chain\")\n .argument(\"<contract>\", \"Contract address\")\n .option(\"--limit <limit>\", \"Number of results\", \"20\")\n .option(\"--next <cursor>\", \"Pagination cursor\")\n .action(\n async (\n chain: string,\n contract: string,\n options: { limit: string; next?: string },\n ) => {\n const client = getClient()\n const result = await client.get<{ nfts: NFT[]; next?: string }>(\n `/api/v2/chain/${chain}/contract/${contract}/nfts`,\n {\n limit: Number.parseInt(options.limit, 10),\n next: options.next,\n },\n )\n console.log(formatOutput(result, getFormat()))\n },\n )\n\n cmd\n .command(\"list-by-account\")\n .description(\"List NFTs owned by an account\")\n .argument(\"<chain>\", \"Chain\")\n .argument(\"<address>\", \"Account address\")\n .option(\"--limit <limit>\", \"Number of results\", \"20\")\n .option(\"--next <cursor>\", \"Pagination cursor\")\n .action(\n async (\n chain: string,\n address: string,\n options: { limit: string; next?: string },\n ) => {\n const client = getClient()\n const result = await client.get<{ nfts: NFT[]; next?: string }>(\n `/api/v2/chain/${chain}/account/${address}/nfts`,\n {\n limit: Number.parseInt(options.limit, 10),\n next: options.next,\n },\n )\n console.log(formatOutput(result, getFormat()))\n },\n )\n\n cmd\n .command(\"refresh\")\n .description(\"Refresh NFT metadata\")\n .argument(\"<chain>\", \"Chain\")\n .argument(\"<contract>\", \"Contract address\")\n .argument(\"<token-id>\", \"Token ID\")\n .action(async (chain: string, contract: string, tokenId: string) => {\n const client = getClient()\n await client.post(\n `/api/v2/chain/${chain}/contract/${contract}/nfts/${tokenId}/refresh`,\n )\n console.log(\n formatOutput(\n { status: \"ok\", message: \"Metadata refresh requested\" },\n getFormat(),\n ),\n )\n })\n\n cmd\n .command(\"contract\")\n .description(\"Get contract details\")\n .argument(\"<chain>\", \"Chain\")\n .argument(\"<address>\", \"Contract address\")\n .action(async (chain: string, address: string) => {\n const client = getClient()\n const result = await client.get<Contract>(\n `/api/v2/chain/${chain}/contract/${address}`,\n )\n console.log(formatOutput(result, getFormat()))\n })\n\n return cmd\n}\n","import { Command } from \"commander\"\nimport type { OpenSeaClient } from \"../client.js\"\nimport { formatOutput } from \"../output.js\"\nimport type { Offer } from \"../types/index.js\"\n\nexport function offersCommand(\n getClient: () => OpenSeaClient,\n getFormat: () => \"json\" | \"table\",\n): Command {\n const cmd = new Command(\"offers\").description(\"Query NFT offers\")\n\n cmd\n .command(\"all\")\n .description(\"Get all offers for a collection\")\n .argument(\"<collection>\", \"Collection slug\")\n .option(\"--limit <limit>\", \"Number of results\", \"20\")\n .option(\"--next <cursor>\", \"Pagination cursor\")\n .action(\n async (collection: string, options: { limit: string; next?: string }) => {\n const client = getClient()\n const result = await client.get<{\n offers: Offer[]\n next?: string\n }>(`/api/v2/offers/collection/${collection}/all`, {\n limit: Number.parseInt(options.limit, 10),\n next: options.next,\n })\n console.log(formatOutput(result, getFormat()))\n },\n )\n\n cmd\n .command(\"collection\")\n .description(\"Get collection offers\")\n .argument(\"<collection>\", \"Collection slug\")\n .option(\"--limit <limit>\", \"Number of results\", \"20\")\n .option(\"--next <cursor>\", \"Pagination cursor\")\n .action(\n async (collection: string, options: { limit: string; next?: string }) => {\n const client = getClient()\n const result = await client.get<{\n offers: Offer[]\n next?: string\n }>(`/api/v2/offers/collection/${collection}`, {\n limit: Number.parseInt(options.limit, 10),\n next: options.next,\n })\n console.log(formatOutput(result, getFormat()))\n },\n )\n\n cmd\n .command(\"best-for-nft\")\n .description(\"Get best offer for a specific NFT\")\n .argument(\"<collection>\", \"Collection slug\")\n .argument(\"<token-id>\", \"Token ID\")\n .action(async (collection: string, tokenId: string) => {\n const client = getClient()\n const result = await client.get<Offer>(\n `/api/v2/offers/collection/${collection}/nfts/${tokenId}/best`,\n )\n console.log(formatOutput(result, getFormat()))\n })\n\n cmd\n .command(\"traits\")\n .description(\"Get trait offers for a collection\")\n .argument(\"<collection>\", \"Collection slug\")\n .requiredOption(\"--type <type>\", \"Trait type (required)\")\n .requiredOption(\"--value <value>\", \"Trait value (required)\")\n .option(\"--limit <limit>\", \"Number of results\", \"20\")\n .option(\"--next <cursor>\", \"Pagination cursor\")\n .action(\n async (\n collection: string,\n options: {\n type: string\n value: string\n limit: string\n next?: string\n },\n ) => {\n const client = getClient()\n const result = await client.get<{\n offers: Offer[]\n next?: string\n }>(`/api/v2/offers/collection/${collection}/traits`, {\n type: options.type,\n value: options.value,\n limit: Number.parseInt(options.limit, 10),\n next: options.next,\n })\n console.log(formatOutput(result, getFormat()))\n },\n )\n\n return cmd\n}\n","import { Command } from \"commander\"\nimport type { OpenSeaClient } from \"../client.js\"\nimport { formatOutput } from \"../output.js\"\nimport type { SwapQuoteResponse } from \"../types/index.js\"\n\nexport function swapsCommand(\n getClient: () => OpenSeaClient,\n getFormat: () => \"json\" | \"table\",\n): Command {\n const cmd = new Command(\"swaps\").description(\n \"Get swap quotes for token trading\",\n )\n\n cmd\n .command(\"quote\")\n .description(\n \"Get a quote for swapping tokens, including price details and executable transaction data\",\n )\n .requiredOption(\"--from-chain <chain>\", \"Chain of the token to swap from\")\n .requiredOption(\n \"--from-address <address>\",\n \"Contract address of the token to swap from\",\n )\n .requiredOption(\"--to-chain <chain>\", \"Chain of the token to swap to\")\n .requiredOption(\n \"--to-address <address>\",\n \"Contract address of the token to swap to\",\n )\n .requiredOption(\"--quantity <quantity>\", \"Amount to swap (in token units)\")\n .requiredOption(\"--address <address>\", \"Wallet address executing the swap\")\n .option(\n \"--slippage <slippage>\",\n \"Slippage tolerance (0.0 to 0.5, default: 0.01)\",\n )\n .option(\n \"--recipient <recipient>\",\n \"Recipient address (defaults to sender address)\",\n )\n .action(\n async (options: {\n fromChain: string\n fromAddress: string\n toChain: string\n toAddress: string\n quantity: string\n address: string\n slippage?: string\n recipient?: string\n }) => {\n const client = getClient()\n const result = await client.get<SwapQuoteResponse>(\n \"/api/v2/swap/quote\",\n {\n from_chain: options.fromChain,\n from_address: options.fromAddress,\n to_chain: options.toChain,\n to_address: options.toAddress,\n quantity: options.quantity,\n address: options.address,\n slippage: options.slippage\n ? Number.parseFloat(options.slippage)\n : undefined,\n recipient: options.recipient,\n },\n )\n console.log(formatOutput(result, getFormat()))\n },\n )\n\n return cmd\n}\n","import { Command } from \"commander\"\nimport type { OpenSeaClient } from \"../client.js\"\nimport { formatOutput } from \"../output.js\"\nimport type { Chain, Token, TokenDetails } from \"../types/index.js\"\n\nexport function tokensCommand(\n getClient: () => OpenSeaClient,\n getFormat: () => \"json\" | \"table\",\n): Command {\n const cmd = new Command(\"tokens\").description(\n \"Query trending tokens, top tokens, and token details\",\n )\n\n cmd\n .command(\"trending\")\n .description(\"Get trending tokens based on OpenSea's trending score\")\n .option(\"--chains <chains>\", \"Comma-separated list of chains to filter by\")\n .option(\"--limit <limit>\", \"Number of results (max 100)\", \"20\")\n .option(\"--cursor <cursor>\", \"Pagination cursor\")\n .action(\n async (options: { chains?: string; limit: string; cursor?: string }) => {\n const client = getClient()\n const result = await client.get<{ tokens: Token[]; next?: string }>(\n \"/api/v2/tokens/trending\",\n {\n chains: options.chains,\n limit: Number.parseInt(options.limit, 10),\n cursor: options.cursor,\n },\n )\n console.log(formatOutput(result, getFormat()))\n },\n )\n\n cmd\n .command(\"top\")\n .description(\"Get top tokens ranked by 24-hour trading volume\")\n .option(\"--chains <chains>\", \"Comma-separated list of chains to filter by\")\n .option(\"--limit <limit>\", \"Number of results (max 100)\", \"20\")\n .option(\"--cursor <cursor>\", \"Pagination cursor\")\n .action(\n async (options: { chains?: string; limit: string; cursor?: string }) => {\n const client = getClient()\n const result = await client.get<{ tokens: Token[]; next?: string }>(\n \"/api/v2/tokens/top\",\n {\n chains: options.chains,\n limit: Number.parseInt(options.limit, 10),\n cursor: options.cursor,\n },\n )\n console.log(formatOutput(result, getFormat()))\n },\n )\n\n cmd\n .command(\"get\")\n .description(\"Get detailed information about a specific token\")\n .argument(\"<chain>\", \"Blockchain chain\")\n .argument(\"<address>\", \"Token contract address\")\n .action(async (chain: string, address: string) => {\n const client = getClient()\n const result = await client.get<TokenDetails>(\n `/api/v2/chain/${chain as Chain}/token/${address}`,\n )\n console.log(formatOutput(result, getFormat()))\n })\n\n return cmd\n}\n"],"mappings":";;;AAAA,SAAS,WAAAA,gBAAe;;;ACExB,IAAM,mBAAmB;AAElB,IAAM,gBAAN,MAAoB;AAAA,EACjB;AAAA,EACA;AAAA,EACA;AAAA,EAER,YAAY,QAA6B;AACvC,SAAK,SAAS,OAAO;AACrB,SAAK,UAAU,OAAO,WAAW;AACjC,SAAK,eAAe,OAAO,SAAS;AAAA,EACtC;AAAA,EAEA,MAAM,IAAO,MAAc,QAA8C;AACvE,UAAM,MAAM,IAAI,IAAI,GAAG,KAAK,OAAO,GAAG,IAAI,EAAE;AAE5C,QAAI,QAAQ;AACV,iBAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,MAAM,GAAG;AACjD,YAAI,UAAU,UAAa,UAAU,MAAM;AACzC,cAAI,aAAa,IAAI,KAAK,OAAO,KAAK,CAAC;AAAA,QACzC;AAAA,MACF;AAAA,IACF;AAEA,UAAM,WAAW,MAAM,MAAM,IAAI,SAAS,GAAG;AAAA,MAC3C,QAAQ;AAAA,MACR,SAAS;AAAA,QACP,QAAQ;AAAA,QACR,aAAa,KAAK;AAAA,MACpB;AAAA,IACF,CAAC;AAED,QAAI,CAAC,SAAS,IAAI;AAChB,YAAM,OAAO,MAAM,SAAS,KAAK;AACjC,YAAM,IAAI,gBAAgB,SAAS,QAAQ,MAAM,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F;AACA,YAAQ,KAAK,CAAC;AAAA,EAChB;AAEA,SAAO,IAAI,cAAc;AAAA,IACvB;AAAA,IACA,OAAO,KAAK;AAAA,IACZ,SAAS,KAAK;AAAA,EAChB,CAAC;AACH;AAEA,SAAS,YAA8B;AACrC,QAAM,OAAO,QAAQ,KAAyB;AAC9C,SAAO,KAAK,WAAW,UAAU,UAAU;AAC7C;AAEA,QAAQ,WAAW,mBAAmB,WAAW,SAAS,CAAC;AAC3D,QAAQ,WAAW,YAAY,WAAW,SAAS,CAAC;AACpD,QAAQ,WAAW,gBAAgB,WAAW,SAAS,CAAC;AACxD,QAAQ,WAAW,cAAc,WAAW,SAAS,CAAC;AACtD,QAAQ,WAAW,cAAc,WAAW,SAAS,CAAC;AACtD,QAAQ,WAAW,gBAAgB,WAAW,SAAS,CAAC;AACxD,QAAQ,WAAW,cAAc,WAAW,SAAS,CAAC;AACtD,QAAQ,WAAW,aAAa,WAAW,SAAS,CAAC;AAErD,QAAQ,KAAK,cAAc,MAAM;AAAC,CAAC;AAEnC,eAAe,OAAO;AACpB,MAAI;AACF,UAAM,QAAQ,WAAW,QAAQ,IAAI;AAAA,EACvC,SAAS,OAAO;AACd,QAAI,iBAAiB,iBAAiB;AACpC,cAAQ;AAAA,QACN,KAAK;AAAA,UACH;AAAA,YACE,OAAO;AAAA,YACP,QAAQ,MAAM;AAAA,YACd,MAAM,MAAM;AAAA,YACZ,SAAS,MAAM;AAAA,UACjB;AAAA,UACA;AAAA,UACA;AAAA,QACF;AAAA,MACF;AACA,cAAQ,KAAK,CAAC;AAAA,IAChB;AACA,UAAM;AAAA,EACR;AACF;AAEA,KAAK;","names":["Command","getClient","getFormat","Command","getClient","getFormat","Command","Command","getClient","getFormat","Command","Command","getClient","getFormat","Command","Command","getClient","getFormat","Command","Command","getClient","getFormat","Command","Command","getClient","getFormat","Command","Command","getClient","getFormat","Command","Command"]}