You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
Copy file name to clipboardExpand all lines: CHANGELOG.md
+6Lines changed: 6 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,11 @@
1
1
# @opensea/api-types
2
2
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.
Copy file name to clipboardExpand all lines: opensea-api.json
+56-5Lines changed: 56 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -1967,7 +1967,7 @@
1967
1967
"get": {
1968
1968
"tags": ["Listing Endpoints"],
1969
1969
"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\"}]",
1971
1971
"operationId": "get_best_listings_collection",
1972
1972
"parameters": [
1973
1973
{
@@ -1988,6 +1988,21 @@
1988
1988
"type": "boolean"
1989
1989
}
1990
1990
},
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
+
},
1991
2006
{
1992
2007
"name": "limit",
1993
2008
"in": "query",
@@ -2203,7 +2218,7 @@
2203
2218
"get": {
2204
2219
"tags": ["Analytics Endpoints"],
2205
2220
"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.",
2207
2222
"operationId": "list_events_by_collection",
2208
2223
"parameters": [
2209
2224
{
@@ -2257,6 +2272,21 @@
2257
2272
}
2258
2273
}
2259
2274
},
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
+
},
2260
2290
{
2261
2291
"name": "limit",
2262
2292
"in": "query",
@@ -2997,7 +3027,7 @@
2997
3027
"get": {
2998
3028
"tags": ["NFT Endpoints"],
2999
3029
"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\"}]",
3001
3031
"operationId": "get_nfts_by_collection",
3002
3032
"parameters": [
3003
3033
{
@@ -3009,6 +3039,21 @@
3009
3039
"type": "string"
3010
3040
}
3011
3041
},
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
+
},
3012
3057
{
3013
3058
"name": "limit",
3014
3059
"in": "query",
@@ -3606,7 +3651,7 @@
3606
3651
{
3607
3652
"name": "limit",
3608
3653
"in": "query",
3609
-
"description": "Number of results to return (default: 20, max: 25)",
3654
+
"description": "Number of results to return (default: 20, max: 100)",
"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.",
3664
3709
"required": false,
3665
3710
"schema": {
3666
3711
"type": "boolean",
@@ -7869,6 +7914,12 @@
7869
7914
"opensea_url": {
7870
7915
"type": "string",
7871
7916
"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).",
Copy file name to clipboardExpand all lines: src/generated.ts
+41-5Lines changed: 41 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -543,7 +543,7 @@ export interface paths {
543
543
};
544
544
/**
545
545
* 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"}]
547
547
*/
548
548
get: operations["get_best_listings_collection"];
549
549
put?: never;
@@ -603,7 +603,7 @@ export interface paths {
603
603
};
604
604
/**
605
605
* 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.
607
607
*/
608
608
get: operations["list_events_by_collection"];
609
609
put?: never;
@@ -803,7 +803,7 @@ export interface paths {
803
803
};
804
804
/**
805
805
* 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"}]
/** @description URL to the token page on OpenSea */
2686
2686
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).
/** @description Whether to include private listings; defaults to false */
3788
3794
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"}]
/** @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. */
* @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"}]
* @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"}]
* @descriptionWhen 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.
0 commit comments