Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add new api fields #1343

Merged
merged 2 commits into from
Jan 3, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
/** Display type of trait */
max_value: string;
ryanio marked this conversation as resolved.
Show resolved Hide resolved
/** 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 @@ -48,6 +48,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