@opensea/cli 0.2.1 → 0.4.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/README.md +91 -227
- package/dist/cli.js +386 -39
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +13 -8
- package/dist/index.js +367 -12
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -15,22 +15,14 @@ Query the OpenSea API from the command line or programmatically. Designed for bo
|
|
|
15
15
|
|
|
16
16
|
- [Install](#install)
|
|
17
17
|
- [Authentication](#authentication)
|
|
18
|
-
- [
|
|
19
|
-
|
|
20
|
-
- [Collections](#collections)
|
|
21
|
-
- [NFTs](#nfts)
|
|
22
|
-
- [Listings](#listings)
|
|
23
|
-
- [Offers](#offers)
|
|
24
|
-
- [Events](#events)
|
|
25
|
-
- [Search](#search)
|
|
26
|
-
- [Tokens](#tokens)
|
|
27
|
-
- [Swaps](#swaps)
|
|
28
|
-
- [Accounts](#accounts)
|
|
18
|
+
- [Quick Start](#quick-start)
|
|
19
|
+
- [Commands](#commands)
|
|
29
20
|
- [Programmatic SDK](#programmatic-sdk)
|
|
30
21
|
- [Output Formats](#output-formats)
|
|
31
|
-
- [Examples](#examples)
|
|
32
22
|
- [Exit Codes](#exit-codes)
|
|
33
23
|
- [Requirements](#requirements)
|
|
24
|
+
- [Development](#development)
|
|
25
|
+
- [Docs](#docs)
|
|
34
26
|
|
|
35
27
|
## Install
|
|
36
28
|
|
|
@@ -58,109 +50,78 @@ opensea --api-key your-api-key collections get mfers
|
|
|
58
50
|
|
|
59
51
|
Get an API key at [docs.opensea.io](https://docs.opensea.io/reference/api-keys).
|
|
60
52
|
|
|
61
|
-
##
|
|
62
|
-
|
|
63
|
-
### Global Options
|
|
64
|
-
|
|
65
|
-
```
|
|
66
|
-
--api-key <key> OpenSea API key (or set OPENSEA_API_KEY env var)
|
|
67
|
-
--chain <chain> Default chain (default: ethereum)
|
|
68
|
-
--format <format> Output format: json or table (default: json)
|
|
69
|
-
--base-url <url> API base URL override
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
### Collections
|
|
73
|
-
|
|
74
|
-
```bash
|
|
75
|
-
opensea collections get <slug>
|
|
76
|
-
opensea collections list [--chain <chain>] [--order-by <field>] [--limit <n>]
|
|
77
|
-
opensea collections stats <slug>
|
|
78
|
-
opensea collections traits <slug>
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
### NFTs
|
|
82
|
-
|
|
83
|
-
```bash
|
|
84
|
-
opensea nfts get <chain> <contract> <token-id>
|
|
85
|
-
opensea nfts list-by-collection <slug> [--limit <n>]
|
|
86
|
-
opensea nfts list-by-contract <chain> <contract> [--limit <n>]
|
|
87
|
-
opensea nfts list-by-account <chain> <address> [--limit <n>]
|
|
88
|
-
opensea nfts refresh <chain> <contract> <token-id>
|
|
89
|
-
opensea nfts contract <chain> <address>
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
### Listings
|
|
53
|
+
## Quick Start
|
|
93
54
|
|
|
94
55
|
```bash
|
|
95
|
-
|
|
96
|
-
opensea
|
|
97
|
-
opensea listings best-for-nft <collection> <token-id>
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
### Offers
|
|
56
|
+
# Get collection details
|
|
57
|
+
opensea collections get mfers
|
|
101
58
|
|
|
102
|
-
|
|
103
|
-
opensea
|
|
104
|
-
opensea offers collection <collection> [--limit <n>]
|
|
105
|
-
opensea offers best-for-nft <collection> <token-id>
|
|
106
|
-
opensea offers traits <collection> --type <type> --value <value>
|
|
107
|
-
```
|
|
59
|
+
# Get floor price and volume stats
|
|
60
|
+
opensea collections stats mfers
|
|
108
61
|
|
|
109
|
-
|
|
62
|
+
# List NFTs in a collection
|
|
63
|
+
opensea nfts list-by-collection mfers --limit 5
|
|
110
64
|
|
|
111
|
-
|
|
112
|
-
opensea
|
|
113
|
-
opensea events by-account <address> [--event-type <type>]
|
|
114
|
-
opensea events by-collection <slug> [--event-type <type>]
|
|
115
|
-
opensea events by-nft <chain> <contract> <token-id> [--event-type <type>]
|
|
116
|
-
```
|
|
65
|
+
# Get best listings
|
|
66
|
+
opensea listings best mfers --limit 5
|
|
117
67
|
|
|
118
|
-
|
|
68
|
+
# Search across OpenSea
|
|
69
|
+
opensea search collections "cool cats"
|
|
119
70
|
|
|
120
|
-
|
|
121
|
-
opensea
|
|
122
|
-
opensea search nfts <query> [--collection <slug>] [--chains <chains>] [--limit <n>]
|
|
123
|
-
opensea search tokens <query> [--chain <chain>] [--limit <n>]
|
|
124
|
-
opensea search accounts <query> [--limit <n>]
|
|
125
|
-
```
|
|
126
|
-
|
|
127
|
-
### Tokens
|
|
71
|
+
# Get trending tokens
|
|
72
|
+
opensea tokens trending --limit 5
|
|
128
73
|
|
|
129
|
-
|
|
130
|
-
opensea
|
|
131
|
-
opensea tokens top [--chains <chains>] [--limit <n>] [--cursor <cursor>]
|
|
132
|
-
opensea tokens get <chain> <address>
|
|
74
|
+
# Human-readable table output
|
|
75
|
+
opensea --format table collections stats mfers
|
|
133
76
|
```
|
|
134
77
|
|
|
135
|
-
|
|
78
|
+
## Commands
|
|
136
79
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
80
|
+
| Command | Description |
|
|
81
|
+
|---|---|
|
|
82
|
+
| `collections` | Get, list, stats, and traits for NFT collections |
|
|
83
|
+
| `nfts` | Get, list, refresh metadata, and contract details for NFTs |
|
|
84
|
+
| `listings` | Get all, best, or best-for-nft listings |
|
|
85
|
+
| `offers` | Get all, collection, best-for-nft, and trait offers |
|
|
86
|
+
| `events` | List marketplace events (sales, transfers, mints, etc.) |
|
|
87
|
+
| `search` | Search collections, NFTs, tokens, and accounts |
|
|
88
|
+
| `tokens` | Get trending tokens, top tokens, and token details |
|
|
89
|
+
| `swaps` | Get swap quotes for token trading |
|
|
90
|
+
| `accounts` | Get account details |
|
|
140
91
|
|
|
141
|
-
|
|
92
|
+
Global options: `--api-key`, `--chain` (default: ethereum), `--format` (json/table/toon), `--base-url`
|
|
142
93
|
|
|
143
|
-
|
|
144
|
-
opensea accounts get <address>
|
|
145
|
-
```
|
|
94
|
+
Full command reference with all options and flags: [docs/cli-reference.md](docs/cli-reference.md)
|
|
146
95
|
|
|
147
96
|
## Programmatic SDK
|
|
148
97
|
|
|
149
|
-
Use as a TypeScript/JavaScript library:
|
|
150
|
-
|
|
151
98
|
```typescript
|
|
152
|
-
import { OpenSeaCLI } from "@opensea/cli"
|
|
99
|
+
import { OpenSeaCLI, OpenSeaAPIError } from "@opensea/cli"
|
|
153
100
|
|
|
154
101
|
const client = new OpenSeaCLI({ apiKey: process.env.OPENSEA_API_KEY })
|
|
155
102
|
|
|
156
103
|
const collection = await client.collections.get("mfers")
|
|
157
|
-
const
|
|
158
|
-
const
|
|
159
|
-
const
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
const
|
|
163
|
-
|
|
104
|
+
const { nfts } = await client.nfts.listByCollection("mfers", { limit: 5 })
|
|
105
|
+
const { listings } = await client.listings.best("mfers", { limit: 10 })
|
|
106
|
+
const { asset_events } = await client.events.byCollection("mfers", {
|
|
107
|
+
eventType: "sale",
|
|
108
|
+
})
|
|
109
|
+
const { tokens } = await client.tokens.trending({ chains: ["base"], limit: 5 })
|
|
110
|
+
const results = await client.search.collections("mfers", { limit: 5 })
|
|
111
|
+
|
|
112
|
+
// Error handling
|
|
113
|
+
try {
|
|
114
|
+
await client.collections.get("nonexistent")
|
|
115
|
+
} catch (error) {
|
|
116
|
+
if (error instanceof OpenSeaAPIError) {
|
|
117
|
+
console.error(error.statusCode) // e.g. 404
|
|
118
|
+
console.error(error.responseBody) // raw API response
|
|
119
|
+
console.error(error.path) // request path
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
Full SDK reference: [docs/sdk.md](docs/sdk.md)
|
|
164
125
|
|
|
165
126
|
## Output Formats
|
|
166
127
|
|
|
@@ -176,150 +137,31 @@ Table - human-readable output:
|
|
|
176
137
|
opensea --format table collections list --limit 5
|
|
177
138
|
```
|
|
178
139
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
Here are real-world examples using the [tiny dinos](https://opensea.io/collection/tiny-dinos-eth) and [mfers](https://opensea.io/collection/mfers) collections:
|
|
182
|
-
|
|
183
|
-
### Collections
|
|
140
|
+
TOON - [Token-Oriented Object Notation](https://github.com/toon-format/toon), a compact format that uses ~40% fewer tokens than JSON. Ideal for piping output into LLM / AI agent context windows:
|
|
184
141
|
|
|
185
142
|
```bash
|
|
186
|
-
|
|
187
|
-
opensea collections get tiny-dinos-eth
|
|
188
|
-
|
|
189
|
-
# List collections with a limit
|
|
190
|
-
opensea collections list --limit 2
|
|
191
|
-
|
|
192
|
-
# Get collection stats (volume, floor price, etc.)
|
|
193
|
-
opensea collections stats tiny-dinos-eth
|
|
194
|
-
|
|
195
|
-
# Get collection traits
|
|
196
|
-
opensea collections traits tiny-dinos-eth
|
|
143
|
+
opensea --format toon tokens trending --limit 5
|
|
197
144
|
```
|
|
198
145
|
|
|
199
|
-
|
|
146
|
+
Example TOON output for a list of tokens:
|
|
200
147
|
|
|
201
|
-
```bash
|
|
202
|
-
# Get a specific NFT by chain/contract/token-id
|
|
203
|
-
opensea nfts get ethereum 0xd9b78a2f1dafc8bb9c60961790d2beefebee56f4 1
|
|
204
|
-
|
|
205
|
-
# List NFTs in a collection
|
|
206
|
-
opensea nfts list-by-collection tiny-dinos-eth --limit 2
|
|
207
|
-
|
|
208
|
-
# List NFTs by contract address
|
|
209
|
-
opensea nfts list-by-contract ethereum 0xd9b78a2f1dafc8bb9c60961790d2beefebee56f4 --limit 2
|
|
210
|
-
|
|
211
|
-
# List NFTs owned by an account
|
|
212
|
-
opensea nfts list-by-account ethereum 0x21130e908bba2d41b63fbca7caa131285b8724f8 --limit 2
|
|
213
|
-
|
|
214
|
-
# Get contract details
|
|
215
|
-
opensea nfts contract ethereum 0xd9b78a2f1dafc8bb9c60961790d2beefebee56f4
|
|
216
|
-
|
|
217
|
-
# Refresh NFT metadata
|
|
218
|
-
opensea nfts refresh ethereum 0xd9b78a2f1dafc8bb9c60961790d2beefebee56f4 1
|
|
219
148
|
```
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
opensea listings all tiny-dinos-eth --limit 2
|
|
226
|
-
|
|
227
|
-
# Get best (cheapest) listings
|
|
228
|
-
opensea listings best tiny-dinos-eth --limit 2
|
|
229
|
-
|
|
230
|
-
# Get the best listing for a specific NFT
|
|
231
|
-
opensea listings best-for-nft mfers 3490
|
|
232
|
-
```
|
|
233
|
-
|
|
234
|
-
### Offers
|
|
235
|
-
|
|
236
|
-
```bash
|
|
237
|
-
# Get all offers for a collection
|
|
238
|
-
opensea offers all tiny-dinos-eth --limit 2
|
|
239
|
-
|
|
240
|
-
# Get collection offers
|
|
241
|
-
opensea offers collection tiny-dinos-eth --limit 2
|
|
242
|
-
|
|
243
|
-
# Get best offer for a specific NFT
|
|
244
|
-
opensea offers best-for-nft tiny-dinos-eth 1
|
|
245
|
-
|
|
246
|
-
# Get trait offers (type and value are required)
|
|
247
|
-
opensea offers traits tiny-dinos-eth --type background --value blue --limit 2
|
|
248
|
-
```
|
|
249
|
-
|
|
250
|
-
### Events
|
|
251
|
-
|
|
252
|
-
```bash
|
|
253
|
-
# List recent events across all collections
|
|
254
|
-
opensea events list --limit 2
|
|
255
|
-
|
|
256
|
-
# Get events for a collection
|
|
257
|
-
opensea events by-collection tiny-dinos-eth --limit 2
|
|
258
|
-
|
|
259
|
-
# Get events for a specific NFT
|
|
260
|
-
opensea events by-nft ethereum 0xd9b78a2f1dafc8bb9c60961790d2beefebee56f4 1 --limit 2
|
|
261
|
-
|
|
262
|
-
# Get events for an account
|
|
263
|
-
opensea events by-account 0x21130e908bba2d41b63fbca7caa131285b8724f8 --limit 2
|
|
264
|
-
```
|
|
265
|
-
|
|
266
|
-
### Search
|
|
267
|
-
|
|
268
|
-
```bash
|
|
269
|
-
# Search for collections
|
|
270
|
-
opensea search collections mfers
|
|
271
|
-
|
|
272
|
-
# Search for NFTs
|
|
273
|
-
opensea search nfts "cool cat" --limit 5
|
|
274
|
-
|
|
275
|
-
# Search for NFTs within a specific collection
|
|
276
|
-
opensea search nfts "rare" --collection tiny-dinos-eth --limit 5
|
|
277
|
-
|
|
278
|
-
# Search for tokens/currencies
|
|
279
|
-
opensea search tokens eth --limit 5
|
|
280
|
-
|
|
281
|
-
# Search for tokens on a specific chain
|
|
282
|
-
opensea search tokens usdc --chain base --limit 5
|
|
283
|
-
|
|
284
|
-
# Search for accounts
|
|
285
|
-
opensea search accounts vitalik --limit 5
|
|
149
|
+
tokens[3]{name,symbol,chain,market_cap,price_usd}:
|
|
150
|
+
Ethereum,ETH,ethereum,250000000000,2100.50
|
|
151
|
+
Bitcoin,BTC,bitcoin,900000000000,48000.00
|
|
152
|
+
Solana,SOL,solana,30000000000,95.25
|
|
153
|
+
next: abc123
|
|
286
154
|
```
|
|
287
155
|
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
```bash
|
|
291
|
-
# Get trending tokens
|
|
292
|
-
opensea tokens trending --limit 2
|
|
293
|
-
|
|
294
|
-
# Get trending tokens on a specific chain
|
|
295
|
-
opensea tokens trending --chains base --limit 2
|
|
296
|
-
|
|
297
|
-
# Get top tokens by 24-hour volume
|
|
298
|
-
opensea tokens top --limit 2
|
|
299
|
-
|
|
300
|
-
# Get top tokens on a specific chain
|
|
301
|
-
opensea tokens top --chains base --limit 2
|
|
302
|
-
|
|
303
|
-
# Get details for a specific token (DebtReliefBot on Base)
|
|
304
|
-
opensea tokens get base 0x3ec2156d4c0a9cbdab4a016633b7bcf6a8d68ea2
|
|
305
|
-
```
|
|
156
|
+
TOON collapses uniform arrays of objects into CSV-like tables with a single header row, while nested objects use YAML-like indentation. The encoder follows the [TOON v3.0 spec](https://github.com/toon-format/spec/blob/main/SPEC.md) and is implemented without external dependencies.
|
|
306
157
|
|
|
307
|
-
|
|
158
|
+
TOON is also available programmatically via the SDK:
|
|
308
159
|
|
|
309
|
-
```
|
|
310
|
-
|
|
311
|
-
opensea swaps quote \
|
|
312
|
-
--from-chain base --from-address 0x833589fcd6edb6e08f4c7c32d4f71b54bda02913 \
|
|
313
|
-
--to-chain base --to-address 0x3ec2156d4c0a9cbdab4a016633b7bcf6a8d68ea2 \
|
|
314
|
-
--quantity 1000000 \
|
|
315
|
-
--address 0x21130e908bba2d41b63fbca7caa131285b8724f8
|
|
316
|
-
```
|
|
317
|
-
|
|
318
|
-
### Accounts
|
|
160
|
+
```typescript
|
|
161
|
+
import { formatToon } from "@opensea/cli"
|
|
319
162
|
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
opensea accounts get 0x21130e908bba2d41b63fbca7caa131285b8724f8
|
|
163
|
+
const data = await client.tokens.trending({ limit: 5 })
|
|
164
|
+
console.log(formatToon(data))
|
|
323
165
|
```
|
|
324
166
|
|
|
325
167
|
## Exit Codes
|
|
@@ -333,6 +175,28 @@ opensea accounts get 0x21130e908bba2d41b63fbca7caa131285b8724f8
|
|
|
333
175
|
- Node.js >= 18.0.0
|
|
334
176
|
- OpenSea API key ([get one here](https://docs.opensea.io/reference/api-keys))
|
|
335
177
|
|
|
178
|
+
## Development
|
|
179
|
+
|
|
180
|
+
```bash
|
|
181
|
+
npm install # Install dependencies
|
|
182
|
+
npm run build # Build CLI + SDK
|
|
183
|
+
npm run dev # Build in watch mode
|
|
184
|
+
npm run test # Run tests
|
|
185
|
+
npm run lint # Lint with Biome
|
|
186
|
+
npm run format # Format with Biome
|
|
187
|
+
npm run type-check # TypeScript type checking
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
## Docs
|
|
191
|
+
|
|
192
|
+
| Document | Description |
|
|
193
|
+
|---|---|
|
|
194
|
+
| [CLI Reference](docs/cli-reference.md) | Full command reference with all options and flags |
|
|
195
|
+
| [Examples](docs/examples.md) | Real-world usage examples for every command |
|
|
196
|
+
| [SDK Reference](docs/sdk.md) | Full programmatic SDK API with all methods |
|
|
197
|
+
| [Pagination](docs/pagination.md) | Cursor-based pagination patterns for CLI and SDK |
|
|
198
|
+
| [Event Types](docs/events.md) | Event type values and filtering |
|
|
199
|
+
|
|
336
200
|
[version-badge]: https://img.shields.io/github/package-json/v/ProjectOpenSea/opensea-cli
|
|
337
201
|
[version-link]: https://github.com/ProjectOpenSea/opensea-cli/releases
|
|
338
202
|
[npm-badge]: https://img.shields.io/npm/v/@opensea/cli?color=red
|