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/README.md +246 -0
- package/dist/cli.js +530 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +493 -0
- package/dist/index.js +293 -0
- package/dist/index.js.map +1 -0
- package/package.json +51 -0
package/README.md
ADDED
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
# opensea-cli
|
|
2
|
+
|
|
3
|
+
Query the OpenSea API from the command line or programmatically. Designed for both AI agents and developers.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install -g opensea-cli
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Or use without installing:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npx opensea-cli collections get boredapeyachtclub
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Local Development
|
|
18
|
+
|
|
19
|
+
To test locally without publishing:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
git clone https://github.com/ProjectOpenSea/opensea-cli.git
|
|
23
|
+
cd opensea-cli
|
|
24
|
+
npm install && npm run build
|
|
25
|
+
export OPENSEA_API_KEY=your-api-key
|
|
26
|
+
|
|
27
|
+
# Run directly with Node
|
|
28
|
+
node dist/cli.js collections get tiny-dinos-eth
|
|
29
|
+
|
|
30
|
+
# Or link globally to use the `opensea` command
|
|
31
|
+
npm link
|
|
32
|
+
opensea collections get tiny-dinos-eth
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Authentication
|
|
36
|
+
|
|
37
|
+
Set your API key via environment variable or flag:
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
export OPENSEA_API_KEY=your-api-key
|
|
41
|
+
opensea collections get boredapeyachtclub
|
|
42
|
+
|
|
43
|
+
# or pass inline
|
|
44
|
+
opensea --api-key your-api-key collections get boredapeyachtclub
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Get an API key at [docs.opensea.io](https://docs.opensea.io/reference/api-keys).
|
|
48
|
+
|
|
49
|
+
## CLI Usage
|
|
50
|
+
|
|
51
|
+
### Global Options
|
|
52
|
+
|
|
53
|
+
```
|
|
54
|
+
--api-key <key> OpenSea API key (or set OPENSEA_API_KEY env var)
|
|
55
|
+
--chain <chain> Default chain (default: ethereum)
|
|
56
|
+
--format <format> Output format: json or table (default: json)
|
|
57
|
+
--base-url <url> API base URL override
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Collections
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
opensea collections get <slug>
|
|
64
|
+
opensea collections list [--chain <chain>] [--order-by <field>] [--limit <n>]
|
|
65
|
+
opensea collections stats <slug>
|
|
66
|
+
opensea collections traits <slug>
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### NFTs
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
opensea nfts get <chain> <contract> <token-id>
|
|
73
|
+
opensea nfts list-by-collection <slug> [--limit <n>]
|
|
74
|
+
opensea nfts list-by-contract <chain> <contract> [--limit <n>]
|
|
75
|
+
opensea nfts list-by-account <chain> <address> [--limit <n>]
|
|
76
|
+
opensea nfts refresh <chain> <contract> <token-id>
|
|
77
|
+
opensea nfts contract <chain> <address>
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Listings
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
opensea listings all <collection> [--limit <n>]
|
|
84
|
+
opensea listings best <collection> [--limit <n>]
|
|
85
|
+
opensea listings best-for-nft <collection> <token-id>
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### Offers
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
opensea offers all <collection> [--limit <n>]
|
|
92
|
+
opensea offers collection <collection> [--limit <n>]
|
|
93
|
+
opensea offers best-for-nft <collection> <token-id>
|
|
94
|
+
opensea offers traits <collection> --type <type> --value <value>
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Events
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
opensea events list [--event-type <type>] [--chain <chain>] [--limit <n>]
|
|
101
|
+
opensea events by-account <address> [--event-type <type>]
|
|
102
|
+
opensea events by-collection <slug> [--event-type <type>]
|
|
103
|
+
opensea events by-nft <chain> <contract> <token-id> [--event-type <type>]
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### Accounts
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
opensea accounts get <address>
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## Programmatic SDK
|
|
113
|
+
|
|
114
|
+
Use as a TypeScript/JavaScript library:
|
|
115
|
+
|
|
116
|
+
```typescript
|
|
117
|
+
import { OpenSeaCLI } from "opensea-cli"
|
|
118
|
+
|
|
119
|
+
const client = new OpenSeaCLI({ apiKey: process.env.OPENSEA_API_KEY })
|
|
120
|
+
|
|
121
|
+
const collection = await client.collections.get("boredapeyachtclub")
|
|
122
|
+
const stats = await client.collections.stats("boredapeyachtclub")
|
|
123
|
+
const nfts = await client.nfts.listByCollection("boredapeyachtclub", { limit: 5 })
|
|
124
|
+
const listings = await client.listings.best("boredapeyachtclub", { limit: 10 })
|
|
125
|
+
const events = await client.events.byCollection("boredapeyachtclub", { eventType: "sale" })
|
|
126
|
+
const account = await client.accounts.get("0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045")
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
## Output Formats
|
|
130
|
+
|
|
131
|
+
JSON (default) - structured output for agents and scripts:
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
opensea collections get boredapeyachtclub
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
Table - human-readable output:
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
opensea --format table collections list --limit 5
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
## Examples
|
|
144
|
+
|
|
145
|
+
Here are real-world examples using the [tiny dinos](https://opensea.io/collection/tiny-dinos-eth) and [mfers](https://opensea.io/collection/mfers) collections:
|
|
146
|
+
|
|
147
|
+
### Collections
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
# Get collection details
|
|
151
|
+
opensea collections get tiny-dinos-eth
|
|
152
|
+
|
|
153
|
+
# List collections with a limit
|
|
154
|
+
opensea collections list --limit 2
|
|
155
|
+
|
|
156
|
+
# Get collection stats (volume, floor price, etc.)
|
|
157
|
+
opensea collections stats tiny-dinos-eth
|
|
158
|
+
|
|
159
|
+
# Get collection traits
|
|
160
|
+
opensea collections traits tiny-dinos-eth
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
### NFTs
|
|
164
|
+
|
|
165
|
+
```bash
|
|
166
|
+
# Get a specific NFT by chain/contract/token-id
|
|
167
|
+
opensea nfts get ethereum 0xd9b78a2f1dafc8bb9c60961790d2beefebee56f4 1
|
|
168
|
+
|
|
169
|
+
# List NFTs in a collection
|
|
170
|
+
opensea nfts list-by-collection tiny-dinos-eth --limit 2
|
|
171
|
+
|
|
172
|
+
# List NFTs by contract address
|
|
173
|
+
opensea nfts list-by-contract ethereum 0xd9b78a2f1dafc8bb9c60961790d2beefebee56f4 --limit 2
|
|
174
|
+
|
|
175
|
+
# List NFTs owned by an account
|
|
176
|
+
opensea nfts list-by-account ethereum 0xde7fce3a1cba4a705f299ce41d163017f165d666 --limit 2
|
|
177
|
+
|
|
178
|
+
# Get contract details
|
|
179
|
+
opensea nfts contract ethereum 0xd9b78a2f1dafc8bb9c60961790d2beefebee56f4
|
|
180
|
+
|
|
181
|
+
# Refresh NFT metadata
|
|
182
|
+
opensea nfts refresh ethereum 0xd9b78a2f1dafc8bb9c60961790d2beefebee56f4 1
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
### Listings
|
|
186
|
+
|
|
187
|
+
```bash
|
|
188
|
+
# Get all listings for a collection
|
|
189
|
+
opensea listings all tiny-dinos-eth --limit 2
|
|
190
|
+
|
|
191
|
+
# Get best (cheapest) listings
|
|
192
|
+
opensea listings best tiny-dinos-eth --limit 2
|
|
193
|
+
|
|
194
|
+
# Get the best listing for a specific NFT
|
|
195
|
+
opensea listings best-for-nft mfers 3490
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
### Offers
|
|
199
|
+
|
|
200
|
+
```bash
|
|
201
|
+
# Get all offers for a collection
|
|
202
|
+
opensea offers all tiny-dinos-eth --limit 2
|
|
203
|
+
|
|
204
|
+
# Get collection offers
|
|
205
|
+
opensea offers collection tiny-dinos-eth --limit 2
|
|
206
|
+
|
|
207
|
+
# Get best offer for a specific NFT
|
|
208
|
+
opensea offers best-for-nft tiny-dinos-eth 1
|
|
209
|
+
|
|
210
|
+
# Get trait offers (type and value are required)
|
|
211
|
+
opensea offers traits tiny-dinos-eth --type background --value blue --limit 2
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
### Events
|
|
215
|
+
|
|
216
|
+
```bash
|
|
217
|
+
# List recent events across all collections
|
|
218
|
+
opensea events list --limit 2
|
|
219
|
+
|
|
220
|
+
# Get events for a collection
|
|
221
|
+
opensea events by-collection tiny-dinos-eth --limit 2
|
|
222
|
+
|
|
223
|
+
# Get events for a specific NFT
|
|
224
|
+
opensea events by-nft ethereum 0xd9b78a2f1dafc8bb9c60961790d2beefebee56f4 1 --limit 2
|
|
225
|
+
|
|
226
|
+
# Get events for an account
|
|
227
|
+
opensea events by-account 0xde7fce3a1cba4a705f299ce41d163017f165d666 --limit 2
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
### Accounts
|
|
231
|
+
|
|
232
|
+
```bash
|
|
233
|
+
# Get account details
|
|
234
|
+
opensea accounts get 0xde7fce3a1cba4a705f299ce41d163017f165d666
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
## Exit Codes
|
|
238
|
+
|
|
239
|
+
- `0` - Success
|
|
240
|
+
- `1` - API error
|
|
241
|
+
- `2` - Authentication error
|
|
242
|
+
|
|
243
|
+
## Requirements
|
|
244
|
+
|
|
245
|
+
- Node.js >= 18.0.0
|
|
246
|
+
- OpenSea API key ([get one here](https://docs.opensea.io/reference/api-keys))
|