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): Promise<OpenSeaAsset | null>
  • Fetch an asset from the API, return null if it isn't found

    Parameters

    • tokenAddress: string

      Address of the asset's contract

    • tokenId: string | number

      The asset's token ID

    Returns Promise<OpenSeaAsset | null>

getAssets

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

    Parameters

    • Default value query: Partial<OpenSeaAssetJSON> = {}

      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

    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: Partial<OpenSeaAssetBundleJSON> = {}

      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

    Returns Promise<object>

getOrder

  • Get an order from the orderbook, returning null if none are found.

    Parameters

    • query: Partial<OrderJSON>

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

    Returns Promise<Order | null>

getOrders

  • getOrders(query?: Partial<OrderJSON>, 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: Partial<OrderJSON> = {}

      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

    Returns Promise<object>

getTokens

  • getTokens(query?: Partial<FungibleToken>, page?: number): Promise<object>
  • Fetch list of fungible tokens from the API matching paramters

    Parameters

    • Default value query: Partial<FungibleToken> = {}

      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

    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>

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 to post to the orderbook

    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