Skip to content

Commit

Permalink
add new api fields (#1343)
Browse files Browse the repository at this point in the history
* add new api fields:
- collection.totalSupply
- collection.createdDate
- nft.traits

* fix comment
  • Loading branch information
ryanio authored Jan 3, 2024
1 parent c119561 commit 8ca95c8
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 4 deletions.
35 changes: 32 additions & 3 deletions src/api/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ export type GetBestListingResponse = Listing;
* @category API Models
*/
export type NFT = {
/** NFT Identifier (also commonly referred to as Token Id) */
/** NFT Identifier (also commonly referred to as tokenId) */
identifier: string;
/** Slug identifier of collection */
collection: string;
Expand All @@ -211,12 +211,41 @@ export type NFT = {
image_url: string;
/** URL of metadata */
metadata_url: string;
/** Date of NFT creation */
created_at: string;
/** Date of latest NFT update */
updated_at: string;
/** Whether NFT is disabled for trading on OpenSea */
is_disabled: boolean;
/** Whether NFT is NSFW (Not Safe For Work) */
is_nsfw: boolean;
/** Traits for the NFT, returns null if the NFT has than 50 traits */
traits: Trait[] | null;
};

/**
* Trait type returned by OpenSea API.
* @category API Models
*/
export type Trait = {
/** The name of the trait category (e.g. 'Background') */
trait_type: string;
/** A field indicating how to display. None is used for string traits. */
display_type: TraitDisplayType;
/** Ceiling for possible numeric trait values */
max_value: string;
/** The value of the trait (e.g. 'Red') */
value: string | number | Date;
};

/**
* Trait display type returned by OpenSea API.
* @category API Models
*/
export enum TraitDisplayType {
NUMBER = "number",
BOOST_PERCENTAGE = "boost_percentage",
BOOST_NUMBER = "boost_number",
AUTHOR = "author",
DATE = "date",
/** "None" is used for string traits */
NONE = "None",
}
6 changes: 5 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -312,8 +312,12 @@ export interface OpenSeaCollection {
fees: Fee[];
/** The rarity strategy for the collection */
rarity: RarityStrategy | null;
/** Tokens allowed for this collection */
/** Payment tokens allowed for orders for this collection */
paymentTokens: OpenSeaPaymentToken[];
/** The total supply of the collection (minted minus burned) */
totalSupply: number;
/** The created date of the collection */
createdDate: string;
}

/**
Expand Down
2 changes: 2 additions & 0 deletions src/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ export const collectionFromJSON = (collection: any): OpenSeaCollection => {
fees: (collection.fees ?? []).map(feeFromJSON),
rarity: rarityFromJSON(collection.rarity),
paymentTokens: (collection.payment_tokens ?? []).map(paymentTokenFromJSON),
totalSupply: collection.total_supply,
createdDate: collection.created_date,
};
};

Expand Down

0 comments on commit 8ca95c8

Please sign in to comment.