Query the OpenSea API from the command line or programmatically with @opensea/cli. Designed for both AI agents and developers.
What is @opensea/cli?
@opensea/cli is a command-line tool and TypeScript SDK for querying the OpenSea API. It supports collections, NFTs, listings, offers, events, search, tokens, swaps, drops, and accounts, with JSON, table, and TOON output formats.
Quick Start
Install globally:
npm install -g @opensea/cliOr use without installing:
npx @opensea/cli collections get mfersAuthentication
Use an API key for public marketplace data:
export OPENSEA_API_KEY=your-api-key
opensea collections get mfers
# or pass inline
opensea --api-key your-api-key collections get mfersGet an API key at Settings -> Developer.
Wallet-specific endpoints also need a scoped wallet JWT. For interactive use, sign in with OAuth:
opensea login --scopes read:favorites
opensea auth status
opensea whoamiFor a server-side agent, keep the private key in an environment variable and sign in headlessly with SIWE:
export OPENSEA_PRIVATE_KEY="..."
opensea login --private-key --scopes read:eligibilityThe CLI stores the resulting credentials in ~/.opensea/auth.json with file mode 0600. It does not store the private key. Use opensea auth refresh to renew the short-lived JWT and opensea auth revoke to revoke the underlying PAT and clear the local credential.
See Authentication for credential types, scopes, and the manual REST flow. Never pass a private key as a command argument or include keys, tokens, cookies, signatures, or authorization headers in logs.
Examples
# Get collection details
opensea collections get mfers
# Get floor price and volume stats
opensea collections stats mfers
# List NFTs in a collection
opensea nfts list-by-collection mfers --limit 5
# Get best listings
opensea listings best mfers --limit 5
# Search across OpenSea
opensea search collections "cool cats"
# Get trending tokens
opensea tokens trending --limit 5
# Human-readable table output
opensea --format table collections stats mfersRequirements
- Node.js >= 18.0.0
- OpenSea API key for public REST data (get one here)
Documentation
Full documentation including the commands reference, programmatic SDK, output formats, pagination, and examples is maintained in the GitHub repository:
github.com/ProjectOpenSea/opensea-cli
