Skip to content

Commit f136cb8

Browse files
docs: improve README and add docs/ folder with SDK, pagination, and events references (#26)
* docs: improve README and add docs/ folder with SDK, pagination, and events references Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * docs: slim down README, move detailed reference and examples to docs/ Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --------- Co-authored-by: unknown <> Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
1 parent 9a55c8b commit f136cb8

6 files changed

Lines changed: 639 additions & 240 deletions

File tree

README.md

Lines changed: 77 additions & 240 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,14 @@ Query the OpenSea API from the command line or programmatically. Designed for bo
1515

1616
- [Install](#install)
1717
- [Authentication](#authentication)
18-
- [CLI Usage](#cli-usage)
19-
- [Global Options](#global-options)
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)
2920
- [Programmatic SDK](#programmatic-sdk)
3021
- [Output Formats](#output-formats)
31-
- [Examples](#examples)
3222
- [Exit Codes](#exit-codes)
3323
- [Requirements](#requirements)
24+
- [Development](#development)
25+
- [Docs](#docs)
3426

3527
## Install
3628

@@ -58,109 +50,78 @@ opensea --api-key your-api-key collections get mfers
5850

5951
Get an API key at [docs.opensea.io](https://docs.opensea.io/reference/api-keys).
6052

61-
## CLI Usage
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
53+
## Quick Start
8254

8355
```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
93-
94-
```bash
95-
opensea listings all <collection> [--limit <n>]
96-
opensea listings best <collection> [--limit <n>]
97-
opensea listings best-for-nft <collection> <token-id>
98-
```
56+
# Get collection details
57+
opensea collections get mfers
9958

100-
### Offers
59+
# Get floor price and volume stats
60+
opensea collections stats mfers
10161

102-
```bash
103-
opensea offers all <collection> [--limit <n>]
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-
```
62+
# List NFTs in a collection
63+
opensea nfts list-by-collection mfers --limit 5
10864

109-
### Events
65+
# Get best listings
66+
opensea listings best mfers --limit 5
11067

111-
```bash
112-
opensea events list [--event-type <type>] [--chain <chain>] [--limit <n>]
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-
```
68+
# Search across OpenSea
69+
opensea search collections "cool cats"
11770

118-
### Search
71+
# Get trending tokens
72+
opensea tokens trending --limit 5
11973

120-
```bash
121-
opensea search collections <query> [--chains <chains>] [--limit <n>]
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>]
74+
# Human-readable table output
75+
opensea --format table collections stats mfers
12576
```
12677

127-
### Tokens
78+
## Commands
12879

129-
```bash
130-
opensea tokens trending [--chains <chains>] [--limit <n>] [--cursor <cursor>]
131-
opensea tokens top [--chains <chains>] [--limit <n>] [--cursor <cursor>]
132-
opensea tokens get <chain> <address>
133-
```
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 |
13491

135-
### Swaps
92+
Global options: `--api-key`, `--chain` (default: ethereum), `--format` (json/table), `--base-url`
13693

137-
```bash
138-
opensea swaps quote --from-chain <chain> --from-address <address> --to-chain <chain> --to-address <address> --quantity <quantity> --address <address> [--slippage <slippage>] [--recipient <recipient>]
139-
```
140-
141-
### Accounts
142-
143-
```bash
144-
opensea accounts get <address>
145-
```
94+
Full command reference with all options and flags: [docs/cli-reference.md](docs/cli-reference.md)
14695

14796
## Programmatic SDK
14897

149-
Use as a TypeScript/JavaScript library:
150-
15198
```typescript
152-
import { OpenSeaCLI } from "@opensea/cli"
99+
import { OpenSeaCLI, OpenSeaAPIError } from "@opensea/cli"
153100

154101
const client = new OpenSeaCLI({ apiKey: process.env.OPENSEA_API_KEY })
155102

156103
const collection = await client.collections.get("mfers")
157-
const stats = await client.collections.stats("mfers")
158-
const nfts = await client.nfts.listByCollection("mfers", { limit: 5 })
159-
const listings = await client.listings.best("mfers", { limit: 10 })
160-
const events = await client.events.byCollection("mfers", { eventType: "sale" })
161-
const account = await client.accounts.get("0x21130e908bba2d41b63fbca7caa131285b8724f8")
162-
const searchResults = await client.search.collections("mfers", { limit: 5 })
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)
164125

165126
## Output Formats
166127

@@ -176,152 +137,6 @@ Table - human-readable output:
176137
opensea --format table collections list --limit 5
177138
```
178139

179-
## Examples
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
184-
185-
```bash
186-
# Get collection details
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
197-
```
198-
199-
### NFTs
200-
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-
```
220-
221-
### Listings
222-
223-
```bash
224-
# Get all listings for a collection
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
286-
```
287-
288-
### Tokens
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-
```
306-
307-
### Swaps
308-
309-
```bash
310-
# Get a swap quote for USDC to DRB on Base
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
319-
320-
```bash
321-
# Get account details
322-
opensea accounts get 0x21130e908bba2d41b63fbca7caa131285b8724f8
323-
```
324-
325140
## Exit Codes
326141

327142
- `0` - Success
@@ -333,6 +148,28 @@ opensea accounts get 0x21130e908bba2d41b63fbca7caa131285b8724f8
333148
- Node.js >= 18.0.0
334149
- OpenSea API key ([get one here](https://docs.opensea.io/reference/api-keys))
335150

151+
## Development
152+
153+
```bash
154+
npm install # Install dependencies
155+
npm run build # Build CLI + SDK
156+
npm run dev # Build in watch mode
157+
npm run test # Run tests
158+
npm run lint # Lint with Biome
159+
npm run format # Format with Biome
160+
npm run type-check # TypeScript type checking
161+
```
162+
163+
## Docs
164+
165+
| Document | Description |
166+
|---|---|
167+
| [CLI Reference](docs/cli-reference.md) | Full command reference with all options and flags |
168+
| [Examples](docs/examples.md) | Real-world usage examples for every command |
169+
| [SDK Reference](docs/sdk.md) | Full programmatic SDK API with all methods |
170+
| [Pagination](docs/pagination.md) | Cursor-based pagination patterns for CLI and SDK |
171+
| [Event Types](docs/events.md) | Event type values and filtering |
172+
336173
[version-badge]: https://img.shields.io/github/package-json/v/ProjectOpenSea/opensea-cli
337174
[version-link]: https://github.com/ProjectOpenSea/opensea-cli/releases
338175
[npm-badge]: https://img.shields.io/npm/v/@opensea/cli?color=red

0 commit comments

Comments
 (0)