v10.2.1
What's Changed
Patch release adding server-side trait filtering on three collection-scoped read methods.
Server-side trait filtering
getNFTsByCollection, getBestListings, and getEventsByCollection now accept an optional traits argument:
import type { TraitFilter } from "@opensea/sdk"
const { nfts } = await openseaSDK.api.getNFTsByCollection(
"doodles-official",
undefined, undefined,
[{ traitType: "Background", value: "Red" }],
)- Multiple entries are AND-combined server-side.
- Empty result when no items match (not all items).
- Returns 400 if a single trait matches more than 1000 items.
- The SDK accepts a structured
TraitFilter[]and JSON-encodes it for the wire — callers don't need toJSON.stringify.
New exports
TraitFilter—{ traitType, value }shape.GetEventsByCollectionArgs— extendsGetEventsArgswithtraits. Type-restricts the field to the collection endpoint, so the other event methods rejecttraitsat compile time.encodeTraitsParam— exposed for callers building requests directly (e.g. via the genericapi.get()).
Requirements
- Requires
@opensea/api-types@^0.2.2(already a transitive dep on install).
Full Changelog: ProjectOpenSea/opensea-devtools@sdk-v10.2.0...sdk-v10.2.1