Skip to content

Commit

Permalink
docs updates
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanio committed Nov 23, 2023
1 parent 9fd672d commit bf32288
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 22 deletions.
10 changes: 3 additions & 7 deletions developerDocs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,17 +125,17 @@ Note that auctions aren't supported with Ether directly due to limitations in Et

### Fetching Orders

To retrieve a list of offers and auctions on an asset, you can use an instance of the `OpenSeaAPI` exposed on the client. Parameters passed into API filter objects are camel-cased and serialized before being sent as [OpenSea API parameters](https://docs.opensea.io/v2.0/reference):
To retrieve a list of offers and auctions on an asset, you can use `getOrders`. Parameters passed into API filter objects are camel-cased and serialized before being sent as [API parameters](https://docs.opensea.io/v2.0/reference):

```typescript
// Get offers (bids), a.k.a. orders where `side == 0`
// Get offers (bids), a.k.a. orders where `side == "bid"`
const { orders, count } = await openseaSDK.api.getOrders({
assetContractAddress: tokenAddress,
tokenId,
side: "bid",
});

// Get page 2 of all auctions, a.k.a. orders where `side == 1`
// Get page 2 of all auctions, a.k.a. orders where `side == "ask"`
const { orders, count } = await openseaSDK.api.getOrders({
assetContractAddress: tokenAddress,
tokenId,
Expand All @@ -145,10 +145,6 @@ const { orders, count } = await openseaSDK.api.getOrders({

Note that the listing price of an asset is equal to the `currentPrice` of the **lowest listing** on the asset. Users can lower their listing price without invalidating previous listing, so all get shipped down until they're canceled, or one is fulfilled.

To learn more about signatures, makers, takers, listingTime vs createdTime and other kinds of order terminology, please read the [**Terminology Section**](https://docs.opensea.io/reference#terminology) of the API Docs.

The available API filters for the orders endpoint is documented in the `OrdersQueryOptions` interface. See the main [API Docs](https://docs.opensea.io/reference#reference-getting-started) for a playground, along with more up-to-date and detailed explanations.

#### Fetching All Offers and Best Listings for a given collection

There are two endpoints that return all offers and listings for a given collection, `getAllOffers` and `getAllListings`.
Expand Down
8 changes: 4 additions & 4 deletions src/api/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ export class OpenSeaAPI {
* @param collectionSlug The slug of the collection.
* @param limit The number of offers to return. Must be between 1 and 100. Default: 100
* @param next The cursor for the next page of results. This is returned from a previous request.
* @returns The {@link GetOrderResponse} returned by the API.
* @returns The {@link GetOffersResponse} returned by the API.
*/
public async getAllOffers(
collectionSlug: string,
Expand All @@ -212,7 +212,7 @@ export class OpenSeaAPI {
* @param collectionSlug The slug of the collection.
* @param limit The number of listings to return. Must be between 1 and 100. Default: 100
* @param next The cursor for the next page of results. This is returned from a previous request.
* @returns The {@link GetOrderResponse} returned by the API.
* @returns The {@link GetListingsResponse} returned by the API.
*/
public async getAllListings(
collectionSlug: string,
Expand All @@ -233,7 +233,7 @@ export class OpenSeaAPI {
* Gets the best offer for a given token.
* @param collectionSlug The slug of the collection.
* @param tokenId The token identifier.
* @returns The {@link GetOrderResponse} returned by the API.
* @returns The {@link GetBestOfferResponse} returned by the API.
*/
public async getBestOffer(
collectionSlug: string,
Expand All @@ -249,7 +249,7 @@ export class OpenSeaAPI {
* Gets the best listing for a given token.
* @param collectionSlug The slug of the collection.
* @param tokenId The token identifier.
* @returns The {@link GetOrderResponse} returned by the API.
* @returns The {@link GetBestListingResponse} returned by the API.
*/
public async getBestListing(
collectionSlug: string,
Expand Down
20 changes: 9 additions & 11 deletions src/api/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ export type GetCollectionResponse = {
};

/**
* Offer type.
* Base Order type shared between Listings and Offers.
* @category API Models
*/
export type Offer = {
export type Order = {
/** Offer Identifier */
order_hash: string;
/** Chain the offer exists on */
Expand All @@ -65,6 +65,12 @@ export type Offer = {
protocol_address: string;
};

/**
* Offer type.
* @category API Models
*/
export type Offer = Order;

/**
* Collection Offer type.
* @category API Models
Expand All @@ -90,17 +96,9 @@ export type Price = {
* Listing order type.
* @category API Models
*/
export type Listing = {
/** Listing Identifier */
order_hash: string;
/** Chain the offer exists on */
chain: string;
export type Listing = Order & {
/** The order type of the listing. */
type: OrderType;
/** The protocol data for the order. Only 'seaport' is currently supported. */
protocol_data: ProtocolData;
/** The contract address of the protocol. */
protocol_address: string;
/** The price of the listing. */
price: Price;
};
Expand Down

0 comments on commit bf32288

Please sign in to comment.