Skip to content

Commit 9f74986

Browse files
authored
Add leaderboard and featured creators queries (#1430)
1 parent fc6fd3b commit 9f74986

File tree

8 files changed

+433
-33
lines changed

8 files changed

+433
-33
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@zoralabs/coins-sdk": patch
3+
---
4+
5+
Add new leaderboard and featured creators queries

docs/pages/coins/sdk/queries/explore.mdx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ The Coins SDK provides several explore functions to discover coins based on diff
1212
- [`getCoinsLastTradedUnique`](#getcoinslasttradedunique)
1313
- [`getCreatorCoins`](#getcreatorcoins)
1414
- [`getMostValuableCreatorCoins`](#getmostvaluablecreatorcoins)
15+
- [`getMostValuableCreatorCoins`](#getmostvaluablecreatorcoins)
16+
1517

1618
## Available Explore Queries
1719

@@ -272,6 +274,8 @@ async function fetchMostValuableCreatorCoins() {
272274
return tokens;
273275
}
274276
```
277+
278+
275279

276280
## Response Structure
277281

@@ -319,7 +323,8 @@ type ListType =
319323
| "FEATURED"
320324
| "FEATURED_VIDEOS"
321325
| "NEW_CREATORS"
322-
| "MOST_VALUABLE_CREATORS";
326+
| "MOST_VALUABLE_CREATORS"
327+
| "FEATURED_CREATORS";
323328
```
324329

325330
## Pagination

docs/pages/coins/sdk/queries/index.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ The query functions are divided into several categories:
99
1. **[Coin Queries](/coins/sdk/queries/coin)**: Retrieve information on specific coins such as metadata, market data, and comments
1010
2. **[Profile Queries](/coins/sdk/queries/profile)**: Retrieve information associated with users/wallets like holdings and activity
1111
3. **[Explore Queries](/coins/sdk/queries/explore)**: Retrieve information about all coins (new, trending, top gainers, etc.)
12+
4. **[Leaderboard](/coins/sdk/queries/leaderboard)**: Featured creators and weekly trader leaderboard (defaults to current week/year if not specified)
1213

1314
## Using the REST API
1415

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Leaderboard Queries
2+
3+
The Coins SDK exposes queries for weekly Featured Creators and the Trader Leaderboard.
4+
5+
- These queries support optional `year` and `week` parameters.
6+
- Weeks use ISO week numbering (starting at 1).
7+
- If `year` and `week` are not provided, the current ISO week and year are used.
8+
- Passing a specific `year` and `week` retrieves data for that week of that year.
9+
10+
## getFeaturedCreators
11+
12+
Retrieves a weekly featured creators list. Supports optional `year`, `week`, and pagination via `first` and `after`.
13+
14+
```ts twoslash
15+
import { getFeaturedCreators } from "@zoralabs/coins-sdk";
16+
17+
async function fetchFeaturedCreators() {
18+
// If year/week not passed, uses the current week/year by default
19+
const response = await getFeaturedCreators({
20+
year: undefined, // optional
21+
week: undefined, // optional
22+
first: 10, // optional: page size
23+
});
24+
25+
return response.data?.traderLeaderboardFeaturedCreators?.edges?.map((e: any) => e.node);
26+
}
27+
```
28+
29+
## getTraderLeaderboard
30+
31+
Retrieves the weekly trader leaderboard. Supports optional `year`, `week`, `first`, and `after`.
32+
33+
Passing in a `year` and `week` will return the leaderboard for that specific week of the year. If no year or week is passed in, it will return the current week's leaderboard.
34+
35+
```ts twoslash
36+
import { getTraderLeaderboard } from "@zoralabs/coins-sdk";
37+
38+
async function fetchTraderLeaderboard() {
39+
// Defaults to the current week/year when omitted
40+
const response = await getTraderLeaderboard({
41+
year: undefined, // optional
42+
week: undefined, // optional
43+
first: 10, // optional: page size
44+
});
45+
46+
return response.data?.exploreTraderLeaderboard?.edges?.map((e: any) => e.node);
47+
}
48+
```
49+
50+

docs/vocs.config.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,10 @@ export default defineConfig({
147147
text: "Explore Coins",
148148
link: "/coins/sdk/queries/explore",
149149
},
150+
{
151+
text: "Leaderboard",
152+
link: "/coins/sdk/queries/leaderboard",
153+
},
150154
],
151155
},
152156
],

packages/coins-sdk/src/api/queries.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ import {
1515
GetProfileCoinsResponse,
1616
GetProfileData,
1717
GetProfileResponse,
18+
GetFeaturedCreatorsData,
19+
GetFeaturedCreatorsResponse,
20+
GetTraderLeaderboardData,
21+
GetTraderLeaderboardResponse,
1822
} from "../client/types.gen";
1923
import {
2024
getCoin as getCoinSDK,
@@ -25,6 +29,8 @@ import {
2529
getProfile as getProfileSDK,
2630
getProfileBalances as getProfileBalancesSDK,
2731
getProfileCoins as getProfileCoinsSDK,
32+
getFeaturedCreators as getFeaturedCreatorsSDK,
33+
getTraderLeaderboard as getTraderLeaderboardSDK,
2834
} from "../client/sdk.gen";
2935
import { getApiKeyMeta } from "./api-key";
3036
import { RequestOptionsType } from "./query-types";
@@ -155,3 +161,33 @@ export const getProfileBalances = async (
155161
...options,
156162
});
157163
};
164+
165+
type GetFeaturedCreatorsQuery = GetFeaturedCreatorsData["query"];
166+
export type { GetFeaturedCreatorsQuery, GetFeaturedCreatorsData };
167+
export type { GetFeaturedCreatorsResponse } from "../client/types.gen";
168+
169+
export const getFeaturedCreators = async (
170+
query: GetFeaturedCreatorsQuery = {},
171+
options?: RequestOptionsType<GetFeaturedCreatorsData>,
172+
): Promise<RequestResult<GetFeaturedCreatorsResponse>> => {
173+
return await getFeaturedCreatorsSDK({
174+
query,
175+
...getApiKeyMeta(),
176+
...options,
177+
});
178+
};
179+
180+
type GetTraderLeaderboardQuery = GetTraderLeaderboardData["query"];
181+
export type { GetTraderLeaderboardQuery, GetTraderLeaderboardData };
182+
export type { GetTraderLeaderboardResponse } from "../client/types.gen";
183+
184+
export const getTraderLeaderboard = async (
185+
query: GetTraderLeaderboardQuery = {},
186+
options?: RequestOptionsType<GetTraderLeaderboardData>,
187+
): Promise<RequestResult<GetTraderLeaderboardResponse>> => {
188+
return await getTraderLeaderboardSDK({
189+
query,
190+
...getApiKeyMeta(),
191+
...options,
192+
});
193+
};

packages/coins-sdk/src/client/sdk.gen.ts

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,18 @@ import type {
2222
SetCreateUploadJwtResponse,
2323
GetExploreData,
2424
GetExploreResponse,
25+
GetFeaturedCreatorsData,
26+
GetFeaturedCreatorsResponse,
2527
GetProfileData,
2628
GetProfileResponse,
2729
GetProfileBalancesData,
2830
GetProfileBalancesResponse,
2931
GetProfileCoinsData,
3032
GetProfileCoinsResponse,
33+
GetTokenInfoData,
34+
GetTokenInfoResponse,
35+
GetTraderLeaderboardData,
36+
GetTraderLeaderboardResponse,
3137
PostQuoteData,
3238
PostQuoteResponse,
3339
PostQuoteError,
@@ -237,6 +243,28 @@ export const getExplore = <ThrowOnError extends boolean = false>(
237243
});
238244
};
239245

246+
/**
247+
* zoraSDK_featuredCreators query
248+
*/
249+
export const getFeaturedCreators = <ThrowOnError extends boolean = false>(
250+
options?: Options<GetFeaturedCreatorsData, ThrowOnError>,
251+
) => {
252+
return (options?.client ?? _heyApiClient).get<
253+
GetFeaturedCreatorsResponse,
254+
unknown,
255+
ThrowOnError
256+
>({
257+
security: [
258+
{
259+
name: "api-key",
260+
type: "apiKey",
261+
},
262+
],
263+
url: "/featuredCreators",
264+
...options,
265+
});
266+
};
267+
240268
/**
241269
* zoraSDK_profile query
242270
*/
@@ -303,6 +331,50 @@ export const getProfileCoins = <ThrowOnError extends boolean = false>(
303331
});
304332
};
305333

334+
/**
335+
* zoraSDK_tokenInfo query
336+
*/
337+
export const getTokenInfo = <ThrowOnError extends boolean = false>(
338+
options: Options<GetTokenInfoData, ThrowOnError>,
339+
) => {
340+
return (options.client ?? _heyApiClient).get<
341+
GetTokenInfoResponse,
342+
unknown,
343+
ThrowOnError
344+
>({
345+
security: [
346+
{
347+
name: "api-key",
348+
type: "apiKey",
349+
},
350+
],
351+
url: "/tokenInfo",
352+
...options,
353+
});
354+
};
355+
356+
/**
357+
* zoraSDK_traderLeaderboard query
358+
*/
359+
export const getTraderLeaderboard = <ThrowOnError extends boolean = false>(
360+
options?: Options<GetTraderLeaderboardData, ThrowOnError>,
361+
) => {
362+
return (options?.client ?? _heyApiClient).get<
363+
GetTraderLeaderboardResponse,
364+
unknown,
365+
ThrowOnError
366+
>({
367+
security: [
368+
{
369+
name: "api-key",
370+
type: "apiKey",
371+
},
372+
],
373+
url: "/traderLeaderboard",
374+
...options,
375+
});
376+
};
377+
306378
export const postQuote = <ThrowOnError extends boolean = false>(
307379
options?: Options<PostQuoteData, ThrowOnError>,
308380
) => {

0 commit comments

Comments
 (0)