diff --git a/package.json b/package.json index 08b30ab17..2a2aac765 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "opensea-js", - "version": "6.1.14", + "version": "6.1.15", "description": "JavaScript SDK for the OpenSea marketplace helps developers build new experiences using NFTs and our marketplace data!", "license": "MIT", "author": "OpenSea Developers", diff --git a/src/api/api.ts b/src/api/api.ts index 94964e57f..d79ea6f40 100644 --- a/src/api/api.ts +++ b/src/api/api.ts @@ -199,10 +199,10 @@ export class OpenSeaAPI { ): Promise { const response = await this.get( getAllOffersAPIPath(collectionSlug), - serializeOrdersQueryOptions({ + { limit, next, - }), + }, ); return response; } @@ -221,10 +221,10 @@ export class OpenSeaAPI { ): Promise { const response = await this.get( getAllListingsAPIPath(collectionSlug), - serializeOrdersQueryOptions({ + { limit, next, - }), + }, ); return response; } diff --git a/src/api/types.ts b/src/api/types.ts index 789dae3a5..ab7efb949 100644 --- a/src/api/types.ts +++ b/src/api/types.ts @@ -156,11 +156,19 @@ export type GetOrdersResponse = QueryCursors & { orders: OrderV2[]; }; +/** + * Base query cursors response from OpenSea API. + * @category API Response Types + */ +export type QueryCursorsV2 = { + next?: string; +}; + /** * Response from OpenSea API for fetching offers. * @category API Response Types */ -export type GetOffersResponse = QueryCursors & { +export type GetOffersResponse = QueryCursorsV2 & { offers: Offer[]; }; @@ -168,7 +176,7 @@ export type GetOffersResponse = QueryCursors & { * Response from OpenSea API for fetching listings. * @category API Response Types */ -export type GetListingsResponse = QueryCursors & { +export type GetListingsResponse = QueryCursorsV2 & { listings: Listing[]; }; diff --git a/test/integration/getListingsAndOffers.spec.ts b/test/integration/getListingsAndOffers.spec.ts index 94a45e511..c3f28f6c7 100644 --- a/test/integration/getListingsAndOffers.spec.ts +++ b/test/integration/getListingsAndOffers.spec.ts @@ -37,6 +37,25 @@ suite("SDK: getAllListings", () => { response.listings[0].protocol_data, "Protocol data should not be null", ); + assert(response.next, "Cursor for next page should not be null"); + + // Should get the next page of listings + const responsePage2 = await sdk.api.getAllListings( + slug, + undefined, + response.next, + ); + assert(responsePage2, "Response should not be null"); + assert.notDeepEqual( + response.listings, + responsePage2.listings, + "Response of second page should not equal the response of first page", + ); + assert.notEqual( + response.next, + responsePage2.next, + "Next cursor should change", + ); }); });