Skip to content

Commit 8a94c9c

Browse files
committed
Release v0.8.5
Origin-SHA: 202ca4118cc2ea8a9ea6b19ba4fcbea4116c0b20
1 parent 280725b commit 8a94c9c

6 files changed

Lines changed: 251 additions & 1 deletion

File tree

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.8.5
4+
5+
### Patch Changes
6+
7+
- 5962e13: Add generated request and response types for the token activity stats REST endpoint.
8+
39
## 0.8.4
410

511
### Patch Changes

opensea-api.json

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6508,6 +6508,70 @@
65086508
}
65096509
}
65106510
},
6511+
"/api/v2/chain/{chain}/token/{address}/activity/stats": {
6512+
"get": {
6513+
"tags": ["Token Endpoints"],
6514+
"summary": "Get token trading activity stats",
6515+
"description": "Get materialized trade count, USD volume, and average trade size for a token. Windows with no swaps are omitted; an omitted requested key means zero trades in that window. Each window ends at its own materialized snapshot; computed_at is the oldest snapshot among the returned windows and can precede request time because the response is cached.",
6516+
"operationId": "get_token_activity_stats",
6517+
"parameters": [
6518+
{
6519+
"name": "chain",
6520+
"in": "path",
6521+
"description": "The blockchain on which to filter the results",
6522+
"required": true,
6523+
"schema": {
6524+
"$ref": "#/components/schemas/ChainIdentifier"
6525+
},
6526+
"example": "ethereum"
6527+
},
6528+
{
6529+
"name": "address",
6530+
"in": "path",
6531+
"description": "The token contract address",
6532+
"required": true,
6533+
"schema": {
6534+
"type": "string"
6535+
},
6536+
"example": "0x0000000000000000000000000000000000000000"
6537+
},
6538+
{
6539+
"name": "windows",
6540+
"in": "query",
6541+
"description": "Comma-separated windows. Defaults to 5m,1h,4h,24h.",
6542+
"required": false,
6543+
"schema": {
6544+
"type": "string",
6545+
"maxLength": 32,
6546+
"minLength": 0,
6547+
"pattern": "^(5m|1h|4h|24h)(,(5m|1h|4h|24h))*$"
6548+
},
6549+
"example": "1h,24h"
6550+
}
6551+
],
6552+
"responses": {
6553+
"200": {
6554+
"description": "OK",
6555+
"content": {
6556+
"*/*": {
6557+
"schema": {
6558+
"$ref": "#/components/schemas/TokenActivityStatsResponse"
6559+
}
6560+
}
6561+
}
6562+
},
6563+
"400": {
6564+
"$ref": "#/components/responses/BadRequest"
6565+
},
6566+
"404": {
6567+
"$ref": "#/components/responses/NotFound"
6568+
},
6569+
"500": {
6570+
"$ref": "#/components/responses/InternalError"
6571+
}
6572+
}
6573+
}
6574+
},
65116575
"/api/v2/chain/{chain}/payment_token/{address}": {
65126576
"get": {
65136577
"tags": ["Contract Endpoints"],
@@ -16150,6 +16214,58 @@
1615016214
"transaction_hash"
1615116215
]
1615216216
},
16217+
"TokenActivityStatsResponse": {
16218+
"type": "object",
16219+
"description": "Windowed trading activity for a token",
16220+
"properties": {
16221+
"chain": {
16222+
"type": "string",
16223+
"description": "Blockchain slug",
16224+
"example": "base"
16225+
},
16226+
"address": {
16227+
"type": "string",
16228+
"description": "Token contract address"
16229+
},
16230+
"computed_at": {
16231+
"type": "string",
16232+
"format": "date-time",
16233+
"description": "End time of the oldest returned aggregation window, or null when no window is returned"
16234+
},
16235+
"windows": {
16236+
"type": "object",
16237+
"additionalProperties": {
16238+
"$ref": "#/components/schemas/TokenActivityWindowStatsResponse"
16239+
},
16240+
"description": "Trading activity keyed by requested window. A requested key is omitted when the token has no swaps in that window; an omitted key means zero trades."
16241+
}
16242+
},
16243+
"required": ["address", "chain", "windows"]
16244+
},
16245+
"TokenActivityWindowStatsResponse": {
16246+
"type": "object",
16247+
"description": "Trading activity within one time window",
16248+
"properties": {
16249+
"trades": {
16250+
"type": "integer",
16251+
"format": "int64",
16252+
"description": "Swap transaction count"
16253+
},
16254+
"volume_usd": {
16255+
"type": "string",
16256+
"description": "Total buy and sell volume in USD",
16257+
"example": 710410.75,
16258+
"pattern": "^[0-9]+(?:\\.[0-9]+)?$"
16259+
},
16260+
"average_trade_usd": {
16261+
"type": "string",
16262+
"description": "Average USD volume per trade",
16263+
"example": 232.92,
16264+
"pattern": "^[0-9]+(?:\\.[0-9]+)?$"
16265+
}
16266+
},
16267+
"required": ["average_trade_usd", "trades", "volume_usd"]
16268+
},
1615316269
"ContractResponse": {
1615416270
"type": "object",
1615516271
"properties": {

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.8.4",
3+
"version": "0.8.5",
44
"description": "Auto-generated TypeScript types from the OpenSea API OpenAPI spec",
55
"license": "MIT",
66
"author": "OpenSea Developers",

src/generated.ts

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1828,6 +1828,26 @@ export interface paths {
18281828
patch?: never;
18291829
trace?: never;
18301830
};
1831+
"/api/v2/chain/{chain}/token/{address}/activity/stats": {
1832+
parameters: {
1833+
query?: never;
1834+
header?: never;
1835+
path?: never;
1836+
cookie?: never;
1837+
};
1838+
/**
1839+
* Get token trading activity stats
1840+
* @description Get materialized trade count, USD volume, and average trade size for a token. Windows with no swaps are omitted; an omitted requested key means zero trades in that window. Each window ends at its own materialized snapshot; computed_at is the oldest snapshot among the returned windows and can precede request time because the response is cached.
1841+
*/
1842+
get: operations["get_token_activity_stats"];
1843+
put?: never;
1844+
post?: never;
1845+
delete?: never;
1846+
options?: never;
1847+
head?: never;
1848+
patch?: never;
1849+
trace?: never;
1850+
};
18311851
"/api/v2/chain/{chain}/payment_token/{address}": {
18321852
parameters: {
18331853
query?: never;
@@ -5704,6 +5724,43 @@ export interface components {
57045724
/** @description Blockchain the swap occurred on */
57055725
chain: string;
57065726
};
5727+
/** @description Windowed trading activity for a token */
5728+
TokenActivityStatsResponse: {
5729+
/**
5730+
* @description Blockchain slug
5731+
* @example base
5732+
*/
5733+
chain: string;
5734+
/** @description Token contract address */
5735+
address: string;
5736+
/**
5737+
* Format: date-time
5738+
* @description End time of the oldest returned aggregation window, or null when no window is returned
5739+
*/
5740+
computed_at?: string;
5741+
/** @description Trading activity keyed by requested window. A requested key is omitted when the token has no swaps in that window; an omitted key means zero trades. */
5742+
windows: {
5743+
[key: string]: components["schemas"]["TokenActivityWindowStatsResponse"];
5744+
};
5745+
};
5746+
/** @description Trading activity within one time window */
5747+
TokenActivityWindowStatsResponse: {
5748+
/**
5749+
* Format: int64
5750+
* @description Swap transaction count
5751+
*/
5752+
trades: number;
5753+
/**
5754+
* @description Total buy and sell volume in USD
5755+
* @example 710410.75
5756+
*/
5757+
volume_usd: string;
5758+
/**
5759+
* @description Average USD volume per trade
5760+
* @example 232.92
5761+
*/
5762+
average_trade_usd: string;
5763+
};
57075764
ContractResponse: {
57085765
address: string;
57095766
chain: string;
@@ -10066,6 +10123,46 @@ export interface operations {
1006610123
500: components["responses"]["InternalError"];
1006710124
};
1006810125
};
10126+
get_token_activity_stats: {
10127+
parameters: {
10128+
query?: {
10129+
/**
10130+
* @description Comma-separated windows. Defaults to 5m,1h,4h,24h.
10131+
* @example 1h,24h
10132+
*/
10133+
windows?: string;
10134+
};
10135+
header?: never;
10136+
path: {
10137+
/**
10138+
* @description The blockchain on which to filter the results
10139+
* @example ethereum
10140+
*/
10141+
chain: components["schemas"]["ChainIdentifier"];
10142+
/**
10143+
* @description The token contract address
10144+
* @example 0x0000000000000000000000000000000000000000
10145+
*/
10146+
address: string;
10147+
};
10148+
cookie?: never;
10149+
};
10150+
requestBody?: never;
10151+
responses: {
10152+
/** @description OK */
10153+
200: {
10154+
headers: {
10155+
[name: string]: unknown;
10156+
};
10157+
content: {
10158+
"*/*": components["schemas"]["TokenActivityStatsResponse"];
10159+
};
10160+
};
10161+
400: components["responses"]["BadRequest"];
10162+
404: components["responses"]["NotFound"];
10163+
500: components["responses"]["InternalError"];
10164+
};
10165+
};
1006910166
get_payment_token: {
1007010167
parameters: {
1007110168
query?: never;

src/schemas-generated.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,8 @@ export type TeamBlockModuleRequest = Schemas["TeamBlockModuleRequest"]
248248
export type TeamSectionRequest = Schemas["TeamSectionRequest"]
249249
export type TokenAccountActivityPaginatedResponse = Schemas["TokenAccountActivityPaginatedResponse"]
250250
export type TokenAccountActivityResponse = Schemas["TokenAccountActivityResponse"]
251+
export type TokenActivityStatsResponse = Schemas["TokenActivityStatsResponse"]
252+
export type TokenActivityWindowStatsResponse = Schemas["TokenActivityWindowStatsResponse"]
251253
export type TokenAmountResponse = Schemas["TokenAmountResponse"]
252254
export type TokenBalancePaginatedResponse = Schemas["TokenBalancePaginatedResponse"]
253255
export type TokenBalanceResponse = Schemas["TokenBalanceResponse"]

test/smoke.test.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ import type {
2424
Order,
2525
paths,
2626
Schemas,
27+
TokenActivityStatsResponse,
28+
TokenActivityWindowStatsResponse,
2729
} from "../src/index.js"
2830
import { AUTH_SCOPES } from "../src/index.js"
2931

@@ -45,6 +47,8 @@ describe("@opensea/api-types smoke tests", () => {
4547
type _events = paths["/api/v2/events"]
4648
type _account = paths["/api/v2/accounts/{address_or_username}"]
4749
type _traits = paths["/api/v2/traits/{slug}"]
50+
type _tokenActivityStats =
51+
paths["/api/v2/chain/{chain}/token/{address}/activity/stats"]["get"]
4852
expect(true).toBe(true) // if we get here, types compiled
4953
})
5054

@@ -61,6 +65,8 @@ describe("@opensea/api-types smoke tests", () => {
6165
type _event = Event
6266
type _account = AccountResponse
6367
type _contract = Contract
68+
type _tokenActivityStats = TokenActivityStatsResponse
69+
type _tokenActivityWindowStats = TokenActivityWindowStatsResponse
6470
expect(true).toBe(true)
6571
})
6672

@@ -69,9 +75,32 @@ describe("@opensea/api-types smoke tests", () => {
6975
type _postOffer = OperationRequestBody<"post_offer">
7076
type _getOffersByNftPath = OperationPathParams<"get_offers_nft">
7177
type _listCollectionsQuery = OperationQueryParams<"list_collections">
78+
type _getTokenActivityStats = OperationResponse<"get_token_activity_stats">
79+
type _getTokenActivityStatsPath =
80+
OperationPathParams<"get_token_activity_stats">
81+
type _getTokenActivityStatsQuery =
82+
OperationQueryParams<"get_token_activity_stats">
7283
expect(true).toBe(true)
7384
})
7485

86+
it("models token activity stats without losing decimal precision", () => {
87+
const response: TokenActivityStatsResponse = {
88+
chain: "base",
89+
address: "0x4200000000000000000000000000000000000006",
90+
computed_at: "2026-07-23T00:52:11.879132Z",
91+
windows: {
92+
"24h": {
93+
trades: 5714,
94+
volume_usd: "710410.75",
95+
average_trade_usd: "124.33",
96+
},
97+
},
98+
}
99+
100+
expect(response.computed_at).toBe("2026-07-23T00:52:11.879132Z")
101+
expect(response.windows["24h"]?.volume_usd).toBe("710410.75")
102+
})
103+
75104
it("Schemas indexer works for all schema names", () => {
76105
// Verify the Schemas type alias can index into any schema
77106
type _check1 = Schemas["CollectionResponse"]

0 commit comments

Comments
 (0)