Skip to content
12 changes: 7 additions & 5 deletions developerDocs/api-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -964,11 +964,13 @@ asset_events.forEach((event) => {

**Event Types:**

- `AssetEventType.SALE` - NFT sales
- `AssetEventType.TRANSFER` - NFT transfers
- `AssetEventType.ORDER` - New listings and offers
- `AssetEventType.CANCEL` - Canceled orders
- `AssetEventType.REDEMPTION` - NFT redemptions
- `"sale"` - NFT sales
- `"transfer"` - NFT transfers
- `"mint"` - NFT mints
- `"listing"` - Item listings
- `"offer"` - Item offers
- `"trait_offer"` - Trait-based offers
- `"collection_offer"` - Collection offers

**Returns:** `GetEventsResponse` containing:

Expand Down
13 changes: 7 additions & 6 deletions developerDocs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -250,11 +250,13 @@ const { asset_events, next } = await openseaSDK.api.getEvents({

**Event Types:**

- `AssetEventType.SALE` - Sales of NFTs
- `AssetEventType.TRANSFER` - Transfers of NFTs
- `AssetEventType.ORDER` - New listings and offers
- `AssetEventType.CANCEL` - Canceled orders
- `AssetEventType.REDEMPTION` - NFT redemptions
- `"sale"` - NFT sales
- `"transfer"` - NFT transfers
- `"mint"` - NFT mints
- `"listing"` - Item listings
- `"offer"` - Item offers
- `"trait_offer"` - Trait-based offers
- `"collection_offer"` - Collection offers

### Get Events by Account

Expand All @@ -278,7 +280,6 @@ Fetch events for a specific collection:
const { asset_events } = await openseaSDK.api.getEventsByCollection(
"cool-cats-nft", // Collection slug
{
event_type: AssetEventType.ORDER,
limit: 100,
},
);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "opensea-js",
"version": "8.0.5",
"version": "8.0.6",
"description": "TypeScript SDK for the OpenSea marketplace helps developers build new experiences using NFTs and our marketplace data",
"license": "MIT",
"author": "OpenSea Developers",
Expand Down
11 changes: 7 additions & 4 deletions src/api/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import {
GetCollectionsResponse,
ListNFTsResponse,
GetNFTResponse,
ListCollectionOffersResponse,
GetOrdersResponse,
GetBestOfferResponse,
GetBestListingResponse,
Expand Down Expand Up @@ -352,12 +351,16 @@ export class OpenSeaAPI {
/**
* Get a list collection offers for a given slug.
* @param slug The slug (identifier) of the collection to list offers for
* @returns The {@link ListCollectionOffersResponse} returned by the API.
* @param limit Optional limit for number of results.
* @param next Optional cursor for pagination.
* @returns The {@link GetOffersResponse} returned by the API.
*/
public async getCollectionOffers(
slug: string,
): Promise<ListCollectionOffersResponse | null> {
return this.offersAPI.getCollectionOffers(slug);
limit?: number,
next?: string,
): Promise<GetOffersResponse> {
return this.offersAPI.getCollectionOffers(slug, limit, next);
}

/**
Expand Down
13 changes: 9 additions & 4 deletions src/api/offers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
} from "./apiPaths";
import {
BuildOfferResponse,
ListCollectionOffersResponse,
GetBestOfferResponse,
GetOffersResponse,
CollectionOffer,
Expand Down Expand Up @@ -141,13 +140,19 @@ export class OffersAPI {
}

/**
* Get a list collection offers for a given slug.
* Get a list of collection offers for a given slug.
*/
async getCollectionOffers(
slug: string,
): Promise<ListCollectionOffersResponse | null> {
return await this.fetcher.get<ListCollectionOffersResponse>(
limit?: number,
next?: string,
): Promise<GetOffersResponse> {
return await this.fetcher.get<GetOffersResponse>(
getCollectionOffersPath(slug),
{
limit,
next,
},
);
}

Expand Down
129 changes: 110 additions & 19 deletions src/api/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -338,18 +338,20 @@ export enum TraitDisplayType {
* @category API Models
*/
export enum AssetEventType {
ORDER = "order",
SALE = "sale",
TRANSFER = "transfer",
CANCEL = "cancel",
REDEMPTION = "redemption",
MINT = "mint",
LISTING = "listing",
OFFER = "offer",
TRAIT_OFFER = "trait_offer",
COLLECTION_OFFER = "collection_offer",
}

/**
* Order type for events.
* Order type for order events.
* @category API Models
*/
export enum EventOrderType {
export enum OrderEventType {
LISTING = "listing",
ITEM_OFFER = "item_offer",
COLLECTION_OFFER = "collection_offer",
Expand Down Expand Up @@ -408,27 +410,23 @@ type BaseEvent = {
};

/**
* Order event type.
* Listing event type.
* @category API Models
*/
export type OrderEvent = BaseEvent & {
event_type: AssetEventType.ORDER | "order";
export type ListingEvent = BaseEvent & {
event_type: AssetEventType.LISTING | "listing";
/** Payment information */
payment: EventPayment;
/** Type of order */
order_type: EventOrderType | string;
/** Start date of the order */
/** Start date of the listing */
start_date: number | null;
/** Expiration date of the order */
/** Expiration date of the listing */
expiration_date: number;
/** Asset involved in the order, null for collection/trait offers */
asset: EventAsset | null;
/** Maker of the order */
/** Asset involved in the listing */
asset: EventAsset;
/** Maker of the listing */
maker: string;
/** Taker of the order */
/** Taker of the listing */
taker: string;
/** Criteria for collection/trait offers */
criteria: Record<string, unknown> | null;
/** Whether the listing is private */
is_private_listing: boolean;
/** Order hash (optional) */
Expand All @@ -437,6 +435,92 @@ export type OrderEvent = BaseEvent & {
protocol_address?: string;
};

/**
* Offer event type.
* @category API Models
*/
export type OfferEvent = BaseEvent & {
event_type: AssetEventType.OFFER | "offer";
/** Payment information */
payment: EventPayment;
/** Start date of the offer */
start_date: number | null;
/** Expiration date of the offer */
expiration_date: number;
/** Asset involved in the offer */
asset: EventAsset;
/** Maker of the offer */
maker: string;
/** Taker of the offer */
taker: string;
/** Order hash (optional) */
order_hash?: string;
/** Protocol address (optional) */
protocol_address?: string;
};

/**
* Trait offer event type.
* @category API Models
*/
export type TraitOfferEvent = BaseEvent & {
event_type: AssetEventType.TRAIT_OFFER | "trait_offer";
/** Payment information */
payment: EventPayment;
/** Start date of the offer */
start_date: number | null;
/** Expiration date of the offer */
expiration_date: number;
/** Criteria for trait offers */
criteria: Record<string, unknown>;
/** Maker of the offer */
maker: string;
/** Taker of the offer */
taker: string;
/** Order hash (optional) */
order_hash?: string;
/** Protocol address (optional) */
protocol_address?: string;
};

/**
* Collection offer event type.
* @category API Models
*/
export type CollectionOfferEvent = BaseEvent & {
event_type: AssetEventType.COLLECTION_OFFER | "collection_offer";
/** Payment information */
payment: EventPayment;
/** Start date of the offer */
start_date: number | null;
/** Expiration date of the offer */
expiration_date: number;
/** Criteria for collection offers */
criteria: Record<string, unknown>;
/** Maker of the offer */
maker: string;
/** Taker of the offer */
taker: string;
/** Order hash (optional) */
order_hash?: string;
/** Protocol address (optional) */
protocol_address?: string;
};

/**
* Mint event type.
* @category API Models
*/
export type MintEvent = BaseEvent & {
event_type: AssetEventType.MINT | "mint";
/** Transaction hash */
transaction: string;
/** Address the NFT was minted to */
to_address: string;
/** NFT that was minted */
nft: EventAsset;
};

/**
* Sale event type.
* @category API Models
Expand Down Expand Up @@ -481,7 +565,14 @@ export type TransferEvent = BaseEvent & {
* Generic event type that can be any event type.
* @category API Models
*/
export type AssetEvent = OrderEvent | SaleEvent | TransferEvent;
export type AssetEvent =
| ListingEvent
| OfferEvent
| TraitOfferEvent
| CollectionOfferEvent
| SaleEvent
| TransferEvent
| MintEvent;

/**
* Query args for Get Events endpoints.
Expand Down
Loading