Skip to content

ProjectOpenSea/opensea-js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1,548 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Version npm Test CI Coverage Status License Docs Discussions

@opensea/sdk

This is the TypeScript SDK for OpenSea, the largest marketplace for NFTs.

It allows developers to access the official orderbook, filter it, create listings and offers, and complete trades programmatically.

Get started by requesting an API key and instantiating your own OpenSea SDK instance. Then you can create orders off-chain or fulfill orders onchain, and listen to events in the process.

Happy seafaring!

Quick Start

With ethers.js

import { ethers } from "ethers";
import { OpenSeaSDK, Chain } from "@opensea/sdk";

const provider = new ethers.JsonRpcProvider("https://eth-mainnet.g.alchemy.com/v2/YOUR_ALCHEMY_API_KEY");
const sdk = new OpenSeaSDK(provider, { chain: Chain.Mainnet, apiKey: "YOUR_API_KEY" });

With viem

import { createPublicClient, createWalletClient, http } from 'viem'
import { mainnet } from 'viem/chains'
import { OpenSeaSDK, Chain } from '@opensea/sdk/viem'

const publicClient = createPublicClient({ chain: mainnet, transport: http() })
const sdk = new OpenSeaSDK({ publicClient }, { chain: Chain.Mainnet, apiKey: 'YOUR_API_KEY' })

Documentation

Security Warning

Do not use this SDK directly in client-side/frontend applications.

The OpenSea SDK requires an API key for initialization. If you embed your API key in frontend code (e.g., browser applications, mobile apps), it will be publicly exposed and could be extracted by anyone, leading to potential abuse and rate limit issues.

Recommended Architecture

For frontend applications that need to interact with OpenSea functionality:

  1. Create a backend API wrapper: Set up your own backend server that securely stores your OpenSea API key
  2. Call OpenSea SDK server-side: Use @opensea/sdk on your backend to interact with OpenSea's APIs
  3. Return data to your frontend: Send the necessary data (like transaction parameters) back to your frontend
  4. Execute transactions in the browser: Have users sign transactions with their own wallets (e.g., MetaMask) in the browser

Changelog

The changelog for recent versions can be found at:

About

TypeScript SDK for the OpenSea marketplace

Resources

License

Contributing

Stars

Watchers

Forks

Contributors