Class OpenSeaAPI

The API class for the OpenSea SDK.

Constructors

  • Create an instance of the OpenSea API

    Parameters

    • config: OpenSeaAPIConfig

      OpenSeaAPIConfig for setting up the API, including an optional API key, Chain name, and base URL

    • Optional logger: ((arg) => void)

      Optional function for logging debug strings before and after requests are made

        • (arg): void
        • Parameters

          • arg: string

          Returns void

    Returns OpenSeaAPI

Properties

apiBaseUrl: string

Base url for the API

logger: ((arg) => void)

Type declaration

    • (arg): void
    • Logger function to use when debugging

      Parameters

      • arg: string

      Returns void

pageSize: number = 20

Default size to use for fetching orders

Methods

  • Build a OpenSea collection offer.

    Parameters

    • offererAddress: string

      The wallet address which is creating the offer.

    • quantity: number

      The number of NFTs requested in the offer.

    • collectionSlug: string

      The slug (identifier) of the collection to build the offer for.

    Returns Promise<BuildOfferResponse>

    The BuildOfferResponse returned by the API.

  • Generate the data needed to fulfill a listing or an offer onchain.

    Parameters

    • fulfillerAddress: string

      The wallet address which will be used to fulfill the order

    • orderHash: string

      The hash of the order to fulfill

    • protocolAddress: string

      The address of the seaport contract

    • side: OrderSide

    Returns Promise<FulfillmentDataResponse>

    The FulfillmentDataResponse

    Side

    The side of the order (buy or sell)

  • Generic fetch method for any API endpoint

    Type Parameters

    • T

      The response from the API.

    Parameters

    • apiPath: string

      Path to URL endpoint under API

    • query: object = {}

      URL query params. Will be used to create a URLSearchParams object.

    Returns Promise<T>

  • Gets all listings for a given collection.

    Parameters

    • collectionSlug: string

      The slug of the collection.

    • Optional limit: number

      The number of listings to return. Must be between 1 and 100. Default: 100

    • Optional next: string

      The cursor for the next page of results. This is returned from a previous request.

    Returns Promise<GetListingsResponse>

    The GetListingsResponse returned by the API.

  • Gets all offers for a given collection.

    Parameters

    • collectionSlug: string

      The slug of the collection.

    • Optional limit: number

      The number of offers to return. Must be between 1 and 100. Default: 100

    • Optional next: string

      The cursor for the next page of results. This is returned from a previous request.

    Returns Promise<GetOffersResponse>

    The GetOffersResponse returned by the API.

  • Fetch an asset.

    Parameters

    • options: {
          tokenAddress: string;
          tokenId: null | string | number;
      }
      • tokenAddress: string

        The asset's contract address.

      • tokenId: null | string | number

        The asset's token ID, or null if ERC-20

    • retries: number = 1

      Number of times to retry if the service is unavailable for any reason

    Returns Promise<OpenSeaAsset>

    The OpenSeaAsset returned by the API.

    Deprecated

    Use getNFT for multichain capabilities.

    Throws

    An error if the function is called on an unsupported chain.

  • Gets the best listing for a given token.

    Parameters

    • collectionSlug: string

      The slug of the collection.

    • tokenId: string | number

      The token identifier.

    Returns Promise<Listing>

    The GetBestListingResponse returned by the API.

  • Fetch list of bundles from the API.

    Parameters

    • query: OpenSeaAssetBundleQuery = {}

      Query to use for getting bundles. See OpenSeaAssetBundleQuery.

    • page: number = 1

      Page number to fetch. Defaults to 1.

    Returns Promise<GetBundlesResponse>

    The GetBundlesResponse returned by the API.

  • Fetch metadata, traits, ownership information, and rarity for a single NFT.

    Parameters

    • chain: Chain

      The NFT's chain.

    • address: string

      The NFT's contract address.

    • identifier: string

      the identifier of the NFT (i.e. Token ID)

    • retries: number = 1

      Number of times to retry if the service is unavailable for any reason

    Returns Promise<GetNFTResponse>

    The GetNFTResponse returned by the API.

  • Fetch NFTs owned by an account.

    Parameters

    • address: string

      The address of the account

    • limit: undefined | number = undefined

      The number of NFTs to retrieve. Must be greater than 0 and less than 51.

    • next: undefined | string = undefined

      Cursor to retrieve the next page of NFTs

    • retries: number = 1

      Number of times to retry if the service is unavailable for any reason.

    • chain: Chain = ...

      The chain to query. Defaults to the chain set in the constructor.

    Returns Promise<ListNFTsResponse>

    The ListNFTsResponse returned by the API.

  • Fetch multiple NFTs for a collection.

    Parameters

    • slug: string

      The slug (identifier) of the collection

    • limit: undefined | number = undefined

      The number of NFTs to retrieve. Must be greater than 0 and less than 51.

    • next: undefined | string = undefined

      Cursor to retrieve the next page of NFTs

    • retries: number = 1

      Number of times to retry if the service is unavailable for any reason.

    Returns Promise<ListNFTsResponse>

    The ListNFTsResponse returned by the API.

  • Fetch multiple NFTs for a contract.

    Parameters

    • chain: Chain

      The NFT's chain.

    • address: string

      The NFT's contract address.

    • limit: undefined | number = undefined

      The number of NFTs to retrieve. Must be greater than 0 and less than 51.

    • next: undefined | string = undefined

      Cursor to retrieve the next page of NFTs.

    • retries: number = 1

      Number of times to retry if the service is unavailable for any reason.

    Returns Promise<ListNFTsResponse>

    The ListNFTsResponse returned by the API.

  • Gets an order from API based on query options.

    Parameters

    • options: Omit<OrdersQueryOptions, "limit">

    Returns Promise<OrderV2>

    The first OrderV2 returned by the API

    Throws

    An error if there are no matching orders.

  • Fetch list of fungible tokens.

    Parameters

    • query: OpenSeaFungibleTokenQuery = {}

      Query to use for getting tokens. See OpenSeaFungibleTokenQuery.

    • page: number = 1

      Page number to fetch. Defaults to 1.

    • retries: number = 1

      Number of times to retry if the service is unavailable for any reason.

    Returns Promise<GetPaymentTokensResponse>

    The GetPaymentTokensResponse returned by the API.

    Throws

    An error if the function is called on an unsupported chain.

  • Generic post method for any API endpoint.

    Type Parameters

    • T

      The response from the API.

    Parameters

    • apiPath: string

      Path to URL endpoint under API

    • Optional body: object

      Data to send.

    • Optional opts: ConnectionInfo

      ethers ConnectionInfo, similar to Fetch API.

    Returns Promise<T>

  • Post a collection offer to OpenSea.

    Parameters

    • order: OrderWithCounter

      The collection offer to post.

    • slug: string

      The slug (identifier) of the collection to post the offer for.

    • retries: number = 0

      Number of times to retry if the service is unavailable for any reason.

    Returns Promise<null | CollectionOffer>

    The Offer returned to the API.

  • Post an order to OpenSea.

    Parameters

    • order: OrderWithCounter

      The order to post

    • apiOptions: OrderAPIOptions
    • options: {
          retries?: number;
      } = {}
      • Optional retries?: number

        Number of times to retry if the service is unavailable for any reason.

    Returns Promise<OrderV2>

    The OrderV2 posted to the API.

  • Force refresh the metadata for an NFT.

    Parameters

    • chain: Chain

      The chain where the NFT is located.

    • address: string

      The address of the NFT's contract.

    • identifier: string

      The identifier of the NFT.

    • retries: number = 1

      Number of times to retry if the service is unavailable for any reason.

    Returns Promise<Response>

    The response from the API.

Generated using TypeDoc