Options
All
  • Public
  • Public/Protected
  • All
Menu

Class OpenSeaAPI

Hierarchy

  • OpenSeaAPI

Index

Constructors

constructor

  • Create an instance of the OpenSea API

    Parameters

    • config: OpenSeaAPIConfig

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

    • Optional logger: undefined | function

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

    Returns OpenSeaAPI

Properties

apiBaseUrl

apiBaseUrl: string

Base url for the API

hostUrl

hostUrl: string

Host url for OpenSea

logger

logger: function

Logger function to use when debugging

Type declaration

    • (arg: string): void
    • Parameters

      • arg: string

      Returns void

pageSize

pageSize: number = 20

Page size to use for fetching orders

Methods

get

  • get(apiPath: string, query?: object): Promise<Response>
  • Get JSON data from API, sending auth token in headers

    Parameters

    • apiPath: string

      Path to URL endpoint under API

    • Default value query: object = {}

      Data to send. Will be stringified using QueryString

    Returns Promise<Response>

getAsset

  • getAsset(tokenAddress: string, tokenId: string | number | null, retries?: number): Promise<OpenSeaAsset>
  • Fetch an asset from the API, throwing if none is found

    Parameters

    • tokenAddress: string

      Address of the asset's contract

    • tokenId: string | number | null

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

    • Default value retries: number = 1

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

    Returns Promise<OpenSeaAsset>

getAssets

  • Fetch list of assets from the API, returning the page of assets and the count of total assets

    Parameters

    • Default value query: OpenSeaAssetQuery = {}

      Query to use for getting orders. A subset of parameters on the OpenSeaAssetJSON type is supported

    • Default value page: number = 1

      Page number, defaults to 1. Can be overridden by limit and offset attributes from OpenSeaAssetQuery

    Returns Promise<object>

getBundle

  • Fetch an bundle from the API, return null if it isn't found

    Parameters

    • slug: string

    Returns Promise<OpenSeaAssetBundle | null>

getBundles

  • Fetch list of bundles from the API, returning the page of bundles and the count of total bundles

    Parameters

    • Default value query: OpenSeaAssetBundleQuery = {}

      Query to use for getting orders. A subset of parameters on the OpenSeaAssetBundleJSON type is supported

    • Default value page: number = 1

      Page number, defaults to 1. Can be overridden by limit and offset attributes from OpenSeaAssetBundleQuery

    Returns Promise<object>

getOrder

  • Get an order from the orderbook, throwing if none is found.

    Parameters

    • query: OrderQuery

      Query to use for getting orders. A subset of parameters on the OrderJSON type is supported

    Returns Promise<Order>

getOrders

  • getOrders(query?: OrderQuery, page?: number): Promise<object>
  • Get a list of orders from the orderbook, returning the page of orders and the count of total orders found.

    Parameters

    • Default value query: OrderQuery = {}

      Query to use for getting orders. A subset of parameters on the OrderJSON type is supported

    • Default value page: number = 1

      Page number, defaults to 1. Can be overridden by limit and offset attributes from OrderQuery

    Returns Promise<object>

getPaymentTokens

  • Fetch list of fungible tokens from the API matching paramters

    Parameters

    • Default value query: OpenSeaFungibleTokenQuery = {}

      Query to use for getting orders. A subset of parameters on the OpenSeaAssetJSON type is supported

    • Default value page: number = 1

      Page number, defaults to 1. Can be overridden by limit and offset attributes from OpenSeaFungibleTokenQuery

    • Default value retries: number = 1

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

    Returns Promise<object>

post

  • post(apiPath: string, body?: undefined | object, opts?: RequestInit): Promise<Response>
  • POST JSON data to API, sending auth token in headers

    Parameters

    • apiPath: string

      Path to URL endpoint under API

    • Optional body: undefined | object

      Data to send. Will be JSON.stringified

    • Default value opts: RequestInit = {}

      RequestInit opts, similar to Fetch API. If it contains a body, it won't be stringified.

    Returns Promise<Response>

postAssetWhitelist

  • postAssetWhitelist(tokenAddress: string, tokenId: string | number, email: string): Promise<boolean>
  • Create a whitelist entry for an asset to prevent others from buying. Buyers will have to have verified at least one of the emails on an asset in order to buy. This will throw a 403 if the given API key isn't allowed to create whitelist entries for this contract or asset.

    Parameters

    • tokenAddress: string

      Address of the asset's contract

    • tokenId: string | number

      The asset's token ID

    • email: string

      The email allowed to buy.

    Returns Promise<boolean>

postOrder

  • Send an order to the orderbook. Throws when the order is invalid. IN NEXT VERSION: change order input to Order type

    Parameters

    • order: OrderJSON

      Order JSON to post to the orderbook

    • Default value retries: number = 2

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

    Returns Promise<Order>

put

  • put(apiPath: string, body: object, opts?: RequestInit): Promise<Response>
  • PUT JSON data to API, sending auth token in headers

    Parameters

    • apiPath: string

      Path to URL endpoint under API

    • body: object

      Data to send

    • Default value opts: RequestInit = {}

      RequestInit opts, similar to Fetch API. If it contains a body, it won't be stringified.

    Returns Promise<Response>

Generated using TypeDoc