Skip to content

Commit f297e23

Browse files
committed
Release v0.2.2
1 parent 39c197c commit f297e23

7 files changed

Lines changed: 162 additions & 23 deletions

File tree

AGENTS.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# api-types — Agent Conventions
2+
3+
Auto-generated TypeScript types from the OpenSea API v2 OpenAPI spec. Source of truth for API types across the devtools ecosystem.
4+
5+
## Quick Reference
6+
7+
```bash
8+
cd packages/api-types
9+
pnpm run update-spec # Fetch latest OpenAPI spec from api.opensea.io
10+
pnpm run build # Regenerate types from spec + bundle with tsup
11+
pnpm run lint # Type-check with tsc --noEmit
12+
pnpm run test # Run smoke tests with Vitest
13+
```
14+
15+
## Architecture
16+
17+
| File | Role |
18+
|------|------|
19+
| `opensea-api.json` | Local copy of the OpenAPI spec (fetched from `api.opensea.io/api/v2/openapi.json`) |
20+
| `scripts/update-spec.mjs` | Fetches the latest spec; falls back to existing local file on network errors |
21+
| `src/generated.ts` | Auto-generated types from `openapi-typescript` — do not edit manually |
22+
| `src/index.ts` | Named re-exports of commonly used schema types (collections, NFTs, orders, etc.) |
23+
| `test/smoke.test.ts` | Smoke test verifying the generated types compile and export correctly |
24+
25+
## Review Checklist
26+
27+
When reviewing changes to this package, verify:
28+
29+
1. **Never hand-edit `src/generated.ts`**. It is produced by `openapi-typescript` from `opensea-api.json`. Changes are overwritten on the next build.
30+
31+
2. **New types in `src/index.ts`**: When the spec adds new schemas, add named re-exports in `src/index.ts` grouped by domain (Collections, NFTs, Orders, etc.). Other packages import from `@opensea/api-types` — unnamed schemas are only accessible via `components["schemas"]["..."]`.
32+
33+
3. **Downstream consumers**: The SDK (`@opensea/sdk`) and CLI (`@opensea/cli`) depend on this package. After updating the spec, rebuild api-types and verify downstream packages still compile:
34+
```bash
35+
pnpm --filter @opensea/api-types run build
36+
pnpm --filter sdk run check-types
37+
pnpm --filter cli run build
38+
```
39+
40+
4. **Chain enum sync**: The SDK's `Chain` enum has a compile-time assertion against `ChainIdentifier` from this package. If the spec adds a new chain, the SDK build will fail until `Chain` is updated.
41+
42+
## Conventions
43+
44+
- ESM-only (`"type": "module"`).
45+
- Dual CJS/ESM output via tsup (consumers can `import` or `require`).
46+
- The `update-spec` script is idempotent — safe to run anytime. It prints the path/schema counts on success.
47+
- Use `/sync-openapi` (monorepo slash command) for the full flow: fetch spec, regenerate, open a PR if changed.

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# @opensea/api-types
22

3+
## 0.2.2
4+
5+
### Patch Changes
6+
7+
- 33bf144: Sync OpenAPI spec: add `traits` query param to three collection-scoped read endpoints (`GET /api/v2/collection/{slug}/nfts`, `GET /api/v2/listings/collection/{slug}/best`, `GET /api/v2/events/collection/{slug}`) — accepts a JSON-encoded array of `{traitType, value}` filters that are AND-combined server-side. Adds optional `status` field to `TokenBalanceResponse` (`OK` | `WARNING` | `SPAM` | `LOW_LIQUIDITY` | `LOW_VALUE`) surfaced when callers pass `disable_spam_filtering=true` on the account tokens endpoint, whose `limit` max also rises from 25 to 100. Non-breaking, additive.
8+
39
## 0.2.1
410

511
### Patch Changes

biome.json

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
"**/*.ts",
66
"**/*.js",
77
"**/*.json",
8-
"!**/node_modules/**",
9-
"!**/dist/**",
10-
"!**/lib/**",
11-
"!**/coverage/**",
12-
"!**/.nyc_output/**",
13-
"!packages/sdk/src/typechain/**",
14-
"!**/typechain/**",
8+
"!**/node_modules",
9+
"!**/dist",
10+
"!**/lib",
11+
"!**/coverage",
12+
"!**/.nyc_output",
13+
"!packages/sdk/src/typechain",
14+
"!**/typechain",
1515
"!packages/api-types/src/generated.ts",
1616
"!**/pnpm-lock.yaml",
1717
"!**/package-lock.json"
@@ -41,9 +41,10 @@
4141
"noExplicitAny": "off"
4242
},
4343
"correctness": {
44-
"noUnusedImports": "warn"
44+
"noUnusedImports": "error"
4545
},
4646
"style": {
47+
"noNonNullAssertion": "error",
4748
"noUnusedTemplateLiteral": "off"
4849
}
4950
}
@@ -53,8 +54,8 @@
5354
"includes": ["**/*.test.ts", "**/*.spec.ts", "**/test/**"],
5455
"linter": {
5556
"rules": {
56-
"correctness": {
57-
"noUnusedImports": "off"
57+
"style": {
58+
"noNonNullAssertion": "off"
5859
}
5960
}
6061
}

opensea-api.json

Lines changed: 56 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1967,7 +1967,7 @@
19671967
"get": {
19681968
"tags": ["Listing Endpoints"],
19691969
"summary": "Get best listings by collection",
1970-
"description": "Get the best listings for a collection sorted by price ascending. Note: results are not deduplicated by token ID — if a token has multiple listings, each listing is returned individually. Filter client-side if you need unique tokens.",
1970+
"description": "Get the best listings for a collection sorted by price ascending. Optionally filter by item traits using the 'traits' query parameter with a JSON array of trait filters. Multiple traits are AND-combined (items must match all). Note: results are not deduplicated by token ID — if a token has multiple listings, each listing is returned individually. Filter client-side if you need unique tokens. Example: ?traits=[{\"traitType\":\"Background\",\"value\":\"Red\"}]",
19711971
"operationId": "get_best_listings_collection",
19721972
"parameters": [
19731973
{
@@ -1988,6 +1988,21 @@
19881988
"type": "boolean"
19891989
}
19901990
},
1991+
{
1992+
"name": "traits",
1993+
"in": "query",
1994+
"description": "JSON array of trait filters to narrow listings by item traits. Each object has 'traitType' and 'value' fields. Multiple traits are AND-combined (items must match all). Example: [{\"traitType\":\"Background\",\"value\":\"Red\"}]",
1995+
"required": false,
1996+
"schema": {
1997+
"type": "string"
1998+
},
1999+
"example": [
2000+
{
2001+
"traitType": "Background",
2002+
"value": "Red"
2003+
}
2004+
]
2005+
},
19912006
{
19922007
"name": "limit",
19932008
"in": "query",
@@ -2203,7 +2218,7 @@
22032218
"get": {
22042219
"tags": ["Analytics Endpoints"],
22052220
"summary": "Get events (by collection)",
2206-
"description": "Get a list of events for a collection.",
2221+
"description": "Get a list of events for a collection. Optionally filter by traits to only return events for items matching the specified trait criteria.",
22072222
"operationId": "list_events_by_collection",
22082223
"parameters": [
22092224
{
@@ -2257,6 +2272,21 @@
22572272
}
22582273
}
22592274
},
2275+
{
2276+
"name": "traits",
2277+
"in": "query",
2278+
"description": "JSON array of trait filters. Each object has 'traitType' and 'value' fields. Multiple traits are AND-combined (items must match all). Example: [{\"traitType\":\"Background\",\"value\":\"Red\"}]",
2279+
"required": false,
2280+
"schema": {
2281+
"type": "string"
2282+
},
2283+
"example": [
2284+
{
2285+
"traitType": "Background",
2286+
"value": "Red"
2287+
}
2288+
]
2289+
},
22602290
{
22612291
"name": "limit",
22622292
"in": "query",
@@ -2997,7 +3027,7 @@
29973027
"get": {
29983028
"tags": ["NFT Endpoints"],
29993029
"summary": "Get NFTs by collection",
3000-
"description": "Get all NFTs in a specific collection.",
3030+
"description": "Get NFTs in a specific collection. Optionally filter by traits using the 'traits' query parameter with a JSON array of trait filters. Multiple traits are AND-combined (items must match all specified traits). Example: ?traits=[{\"traitType\":\"Background\",\"value\":\"Red\"},{\"traitType\":\"Eyes\",\"value\":\"Blue\"}]",
30013031
"operationId": "get_nfts_by_collection",
30023032
"parameters": [
30033033
{
@@ -3009,6 +3039,21 @@
30093039
"type": "string"
30103040
}
30113041
},
3042+
{
3043+
"name": "traits",
3044+
"in": "query",
3045+
"description": "JSON array of trait filters. Each object has 'traitType' and 'value' fields. Multiple traits are AND-combined (items must match all). Example: [{\"traitType\":\"Background\",\"value\":\"Red\"}]",
3046+
"required": false,
3047+
"schema": {
3048+
"type": "string"
3049+
},
3050+
"example": [
3051+
{
3052+
"traitType": "Background",
3053+
"value": "Red"
3054+
}
3055+
]
3056+
},
30123057
{
30133058
"name": "limit",
30143059
"in": "query",
@@ -3606,7 +3651,7 @@
36063651
{
36073652
"name": "limit",
36083653
"in": "query",
3609-
"description": "Number of results to return (default: 20, max: 25)",
3654+
"description": "Number of results to return (default: 20, max: 100)",
36103655
"required": false,
36113656
"schema": {
36123657
"type": "integer",
@@ -3660,7 +3705,7 @@
36603705
{
36613706
"name": "disable_spam_filtering",
36623707
"in": "query",
3663-
"description": "Disable spam token filtering (default: false)",
3708+
"description": "When true, disables OpenSea's heuristic spam filtering and returns tokens that would normally be hidden (low liquidity, dust, flagged-as-spam, etc.). Tokens flagged for trust & safety enforcement or as malicious are still filtered out regardless. Surfaced tokens carry a `status` field on the response indicating why they would have been filtered.",
36643709
"required": false,
36653710
"schema": {
36663711
"type": "boolean",
@@ -7869,6 +7914,12 @@
78697914
"opensea_url": {
78707915
"type": "string",
78717916
"description": "URL to the token page on OpenSea"
7917+
},
7918+
"status": {
7919+
"type": "string",
7920+
"default": "OK",
7921+
"description": "Token status relative to OpenSea's spam-classification rules. `OK` for tokens that pass all spam filters (the normal case); populated with a more specific value for tokens surfaced via `disable_spam_filtering=true` that would normally be hidden. Categories are intentionally broad and may evolve. Possible values, in decreasing severity: `WARNING` (flagged as risky/suspicious — caution advised), `SPAM` (flagged as spam), `LOW_LIQUIDITY` (insufficient pool liquidity), `LOW_VALUE` (dust holding < $0.01), `OK` (passes all filters).",
7922+
"enum": ["OK", "WARNING", "SPAM", "LOW_LIQUIDITY", "LOW_VALUE"]
78727923
}
78737924
},
78747925
"required": [

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@opensea/api-types",
3-
"version": "0.2.1",
3+
"version": "0.2.2",
44
"description": "Auto-generated TypeScript types from the OpenSea API OpenAPI spec",
55
"license": "MIT",
66
"author": "OpenSea Developers",

src/generated.ts

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,7 @@ export interface paths {
543543
};
544544
/**
545545
* Get best listings by collection
546-
* @description Get the best listings for a collection sorted by price ascending. Note: results are not deduplicated by token ID — if a token has multiple listings, each listing is returned individually. Filter client-side if you need unique tokens.
546+
* @description Get the best listings for a collection sorted by price ascending. Optionally filter by item traits using the 'traits' query parameter with a JSON array of trait filters. Multiple traits are AND-combined (items must match all). Note: results are not deduplicated by token ID — if a token has multiple listings, each listing is returned individually. Filter client-side if you need unique tokens. Example: ?traits=[{"traitType":"Background","value":"Red"}]
547547
*/
548548
get: operations["get_best_listings_collection"];
549549
put?: never;
@@ -603,7 +603,7 @@ export interface paths {
603603
};
604604
/**
605605
* Get events (by collection)
606-
* @description Get a list of events for a collection.
606+
* @description Get a list of events for a collection. Optionally filter by traits to only return events for items matching the specified trait criteria.
607607
*/
608608
get: operations["list_events_by_collection"];
609609
put?: never;
@@ -803,7 +803,7 @@ export interface paths {
803803
};
804804
/**
805805
* Get NFTs by collection
806-
* @description Get all NFTs in a specific collection.
806+
* @description Get NFTs in a specific collection. Optionally filter by traits using the 'traits' query parameter with a JSON array of trait filters. Multiple traits are AND-combined (items must match all specified traits). Example: ?traits=[{"traitType":"Background","value":"Red"},{"traitType":"Eyes","value":"Blue"}]
807807
*/
808808
get: operations["get_nfts_by_collection"];
809809
put?: never;
@@ -2684,6 +2684,12 @@ export interface components {
26842684
usd_value: string;
26852685
/** @description URL to the token page on OpenSea */
26862686
opensea_url: string;
2687+
/**
2688+
* @description Token status relative to OpenSea's spam-classification rules. `OK` for tokens that pass all spam filters (the normal case); populated with a more specific value for tokens surfaced via `disable_spam_filtering=true` that would normally be hidden. Categories are intentionally broad and may evolve. Possible values, in decreasing severity: `WARNING` (flagged as risky/suspicious — caution advised), `SPAM` (flagged as spam), `LOW_LIQUIDITY` (insufficient pool liquidity), `LOW_VALUE` (dust holding < $0.01), `OK` (passes all filters).
2689+
* @default OK
2690+
* @enum {string}
2691+
*/
2692+
status: "OK" | "WARNING" | "SPAM" | "LOW_LIQUIDITY" | "LOW_VALUE";
26872693
};
26882694
};
26892695
responses: {
@@ -3786,6 +3792,16 @@ export interface operations {
37863792
query?: {
37873793
/** @description Whether to include private listings; defaults to false */
37883794
include_private_listings?: boolean;
3795+
/**
3796+
* @description JSON array of trait filters to narrow listings by item traits. Each object has 'traitType' and 'value' fields. Multiple traits are AND-combined (items must match all). Example: [{"traitType":"Background","value":"Red"}]
3797+
* @example [
3798+
* {
3799+
* "traitType": "Background",
3800+
* "value": "Red"
3801+
* }
3802+
* ]
3803+
*/
3804+
traits?: string;
37893805
/**
37903806
* @description Number of items to return per page
37913807
* @example 20
@@ -3895,6 +3911,16 @@ export interface operations {
38953911
before?: number;
38963912
/** @description Filter by event types. To get order invalidation and revalidation events, please use the Stream API. The order status can also be checked on the Get Order endpoint. */
38973913
event_type?: ("sale" | "transfer" | "mint" | "listing" | "offer" | "trait_offer" | "collection_offer")[];
3914+
/**
3915+
* @description JSON array of trait filters. Each object has 'traitType' and 'value' fields. Multiple traits are AND-combined (items must match all). Example: [{"traitType":"Background","value":"Red"}]
3916+
* @example [
3917+
* {
3918+
* "traitType": "Background",
3919+
* "value": "Red"
3920+
* }
3921+
* ]
3922+
*/
3923+
traits?: string;
38983924
/**
38993925
* @description Number of items to return per page
39003926
* @example 20
@@ -4284,6 +4310,16 @@ export interface operations {
42844310
get_nfts_by_collection: {
42854311
parameters: {
42864312
query?: {
4313+
/**
4314+
* @description JSON array of trait filters. Each object has 'traitType' and 'value' fields. Multiple traits are AND-combined (items must match all). Example: [{"traitType":"Background","value":"Red"}]
4315+
* @example [
4316+
* {
4317+
* "traitType": "Background",
4318+
* "value": "Red"
4319+
* }
4320+
* ]
4321+
*/
4322+
traits?: string;
42874323
/**
42884324
* @description Number of items to return per page
42894325
* @example 20
@@ -4636,7 +4672,7 @@ export interface operations {
46364672
parameters: {
46374673
query?: {
46384674
/**
4639-
* @description Number of results to return (default: 20, max: 25)
4675+
* @description Number of results to return (default: 20, max: 100)
46404676
* @example 20
46414677
*/
46424678
limit?: number;
@@ -4656,7 +4692,7 @@ export interface operations {
46564692
*/
46574693
sort_direction?: "asc" | "desc";
46584694
/**
4659-
* @description Disable spam token filtering (default: false)
4695+
* @description When true, disables OpenSea's heuristic spam filtering and returns tokens that would normally be hidden (low liquidity, dust, flagged-as-spam, etc.). Tokens flagged for trust & safety enforcement or as malicious are still filtered out regardless. Surfaced tokens carry a `status` field on the response indicating why they would have been filtered.
46604696
* @example false
46614697
*/
46624698
disable_spam_filtering?: boolean;

test/smoke.test.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import type {
1111
ChainIdentifier,
1212
CollectionResponse,
1313
Contract,
14-
components,
1514
Event,
1615
FulfillListingResponse,
1716
Listing,
@@ -23,7 +22,6 @@ import type {
2322
OperationRequestBody,
2423
OperationResponse,
2524
Order,
26-
operations,
2725
paths,
2826
Schemas,
2927
} from "../src/index.js"

0 commit comments

Comments
 (0)