File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -4,9 +4,11 @@ import type {
44 Account ,
55 AccountResolveResponse ,
66 AssetEvent ,
7+ AssetMetadataResponse ,
78 Chain ,
89 ChainListResponse ,
910 Collection ,
11+ CollectionDetailedResponse ,
1012 CollectionOrderBy ,
1113 CollectionPaginatedResponse ,
1214 CollectionStats ,
@@ -284,6 +286,24 @@ class NFTsAPI {
284286 params ,
285287 )
286288 }
289+
290+ async getCollection (
291+ chain : Chain ,
292+ address : string ,
293+ identifier : string ,
294+ ) : Promise < CollectionDetailedResponse > {
295+ return this . client . get (
296+ `/api/v2/chain/${ chain } /contract/${ address } /nfts/${ identifier } /collection` ,
297+ )
298+ }
299+
300+ async getMetadata (
301+ chain : Chain ,
302+ address : string ,
303+ tokenId : string ,
304+ ) : Promise < AssetMetadataResponse > {
305+ return this . client . get ( `/api/v2/metadata/${ chain } /${ address } /${ tokenId } ` )
306+ }
287307}
288308
289309class ListingsAPI {
Original file line number Diff line number Diff line change @@ -66,6 +66,7 @@ export type DropPaginatedResponse = Schemas["DropPaginatedResponse"]
6666export type DropMintRequest = Schemas [ "DropMintRequest" ]
6767export type DropMintResponse = Schemas [ "DropMintResponse" ]
6868export type AccountResolveResponse = Schemas [ "AccountResolveResponse" ]
69+ export type AssetMetadataResponse = Schemas [ "AssetMetadataResponse" ]
6970
7071// ── CLI-specific types (not from API spec) ──────────────────────────
7172
Original file line number Diff line number Diff line change @@ -216,6 +216,25 @@ describe("OpenSeaCLI", () => {
216216 "/api/v2/chain/ethereum/contract/0xabc" ,
217217 )
218218 } )
219+
220+ it ( "getCollection calls correct endpoint" , async ( ) => {
221+ mockGet . mockResolvedValue ( {
222+ name : "Art Blocks" ,
223+ collection : "art-blocks" ,
224+ } )
225+ const result = await sdk . nfts . getCollection ( "ethereum" , "0xabc" , "42" )
226+ expect ( mockGet ) . toHaveBeenCalledWith (
227+ "/api/v2/chain/ethereum/contract/0xabc/nfts/42/collection" ,
228+ )
229+ expect ( result . name ) . toBe ( "Art Blocks" )
230+ } )
231+
232+ it ( "getMetadata calls correct endpoint" , async ( ) => {
233+ mockGet . mockResolvedValue ( { name : "Cool NFT" , traits : [ ] } )
234+ const result = await sdk . nfts . getMetadata ( "ethereum" , "0xabc" , "1" )
235+ expect ( mockGet ) . toHaveBeenCalledWith ( "/api/v2/metadata/ethereum/0xabc/1" )
236+ expect ( result . name ) . toBe ( "Cool NFT" )
237+ } )
219238 } )
220239
221240 describe ( "listings" , ( ) => {
You can’t perform that action at this time.
0 commit comments