Skip to content

Commit e49b774

Browse files
committed
more endpoints
1 parent 0247b24 commit e49b774

File tree

19 files changed

+773
-18
lines changed

19 files changed

+773
-18
lines changed

README.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,22 @@ Let me know if you want certain APIs to be prioritized.
1212

1313
### APIs implemented
1414

15-
| APIs | Status | Note |
16-
| --------------------------------------------- | ------ | ---- |
17-
| **World of Warcraft:** Game Data APIs || |
18-
| **World of Warcraft:** Profile APIs || |
19-
| | | |
20-
| **World of Warcraft Classic:** Game Data APIs | | |
21-
| | | |
22-
| **Diablo III:** Community APIs | | |
23-
| **Diablo III:** Game Data APIs | | |
24-
| | | |
25-
| **Hearthstone:** Game Data APIs | | |
26-
| | | |
27-
| **Overwatch League:** Community APIs** | | |
28-
| | | |
29-
| **StarCraft II:** Community APIs | | |
30-
| **StarCraft II:** Game Data APIs | | |
15+
| APIs | Status | Note |
16+
| --------------------------------------------- | ------ | ----------------------------------------------------------------------------------- |
17+
| **World of Warcraft:** Game Data APIs || |
18+
| **World of Warcraft:** Profile APIs || |
19+
| | | |
20+
| **World of Warcraft Classic:** Game Data APIs | | |
21+
| | | |
22+
| **Diablo III:** Community APIs | | |
23+
| **Diablo III:** Game Data APIs | | |
24+
| | | |
25+
| **Hearthstone:** Game Data APIs | | |
26+
| | | |
27+
| **Overwatch League:** Community APIs** | | Only seem to support US region and some data types are partially defined as Unknown |
28+
| | | |
29+
| **StarCraft II:** Community APIs | | |
30+
| **StarCraft II:** Game Data APIs | | |
3131

3232
## Issues
3333

mod.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { authenticate, setup } from "./src/shared/index.ts";
22
import * as wow from "./src/wow/index.ts";
3-
import * as wowClassic from "./src/wow_classic/index.ts";
3+
import * as hearthstone from "./src/hearthstone/index.ts";
4+
import * as owl from "./src/overwatch/index.ts";
5+
import * as sc2 from "./src/starcraft2/index.ts";
46

5-
export { authenticate, setup, wow, wowClassic };
7+
export { authenticate, hearthstone, owl, sc2, setup, wow };

src/diablo3/game_data/d3.ts

Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
import { LinkSelfHref, LocalizedString, request } from "../../shared/index.ts";
2+
3+
interface Seasons extends LinkSelfHref {
4+
season: {
5+
href: string;
6+
}[];
7+
current_season: number;
8+
service_current_season: number;
9+
service_season_state: string;
10+
last_update_time: string;
11+
generated_by: string;
12+
}
13+
14+
interface Season extends LinkSelfHref {
15+
leaderboard: {
16+
team_size?: number;
17+
ladder: {
18+
href: string;
19+
};
20+
hardcore?: boolean;
21+
hero_class_string?: LocalizedString;
22+
}[];
23+
season_id: number;
24+
last_update_time: string;
25+
generated_by: string;
26+
}
27+
28+
interface LeaderboardData {
29+
id: string;
30+
string?: string;
31+
number?: number;
32+
timestamp?: number;
33+
}
34+
35+
interface LeaderboardBase extends LinkSelfHref {
36+
row: {
37+
player: {
38+
key: string;
39+
accountId: number;
40+
data: LeaderboardData[];
41+
}[];
42+
order: 1;
43+
data: LeaderboardData[];
44+
}[];
45+
key: string;
46+
title: LocalizedString;
47+
column: {
48+
id: string;
49+
hidden: boolean;
50+
order: number;
51+
label: LocalizedString;
52+
type: string;
53+
}[];
54+
last_update_time: string;
55+
generated_by: string;
56+
}
57+
58+
interface SeasonLeaderboard extends LeaderboardBase {
59+
achievement_points: boolean;
60+
season: number;
61+
}
62+
63+
interface EraLeaderboard extends LeaderboardBase {
64+
greater_rift: boolean;
65+
greater_rift_solo_class: string;
66+
era: number;
67+
}
68+
69+
interface Eras extends LinkSelfHref {
70+
era: {
71+
href: string;
72+
}[];
73+
current_era: number;
74+
last_update_time: string;
75+
generated_by: string;
76+
}
77+
78+
interface Era extends LinkSelfHref {
79+
leaderboard: {
80+
team_size?: number;
81+
ladder: {
82+
href: string;
83+
};
84+
hardcore?: boolean;
85+
hero_class_string?: LocalizedString;
86+
}[];
87+
era_id: number;
88+
era_start_date: number;
89+
last_update_time: string;
90+
generated_by: string;
91+
}
92+
93+
/**
94+
* Returns an index of available seasons.
95+
*
96+
* @returns A promise that resolves to an object representing an index of available seasons.
97+
*/
98+
export async function seasons(): Promise<Seasons> {
99+
return await request({
100+
method: "GET",
101+
url: "/data/d3/season/",
102+
});
103+
}
104+
105+
/**
106+
* Returns an index of available seasons.
107+
*
108+
* @param seasonId - The season for the leaderboard list.
109+
* @returns A promise that resolves to an object representing the data for a league.
110+
*/
111+
export async function season(seasonId: number): Promise<Season> {
112+
return await request({
113+
method: "GET",
114+
url: `/data/d3/season/${seasonId}`,
115+
});
116+
}
117+
118+
/**
119+
* Returns a the specified leaderboard for the specified season.
120+
*
121+
* @param seasonId - The season for the leaderboard.
122+
* @param leaderboard - The leaderboard to retrieve.
123+
* @returns A promise that resolves to an object representing the data for a the specified leaderboard for the specified season.
124+
*/
125+
export async function seasonLeaderboard(seasonId: number, leaderboard: string): Promise<SeasonLeaderboard> {
126+
return await request({
127+
method: "GET",
128+
url: `/data/d3/season/${seasonId}/leaderboard/${leaderboard}`,
129+
});
130+
}
131+
132+
/**
133+
* Returns an index of available eras.
134+
*
135+
* @returns A promise that resolves to an object representing an index of available eras.
136+
*/
137+
export async function eras(): Promise<Eras> {
138+
return await request({
139+
method: "GET",
140+
url: "/data/d3/era/",
141+
});
142+
}
143+
144+
/**
145+
* Returns a leaderboard list for a particular era.
146+
*
147+
* @param eraId - The era to retrieve.
148+
* @returns A promise that resolves to an object representing a leaderboard list for a particular era.
149+
*/
150+
export async function era(eraId: number): Promise<Era> {
151+
return await request({
152+
method: "GET",
153+
url: `/data/d3/era/${eraId}`,
154+
});
155+
}
156+
157+
/**
158+
* Returns the specified leaderboard for the specified era.
159+
*
160+
* @param eraId - The era for the leaderboard.
161+
* @param leaderboard - The leaderboard to retrieve.
162+
* @returns A promise that resolves to an object representing the data for a the specified leaderboard for the specified era.
163+
*/
164+
export async function eraLeaderboard(eraId: number, leaderboard: string): Promise<EraLeaderboard> {
165+
return await request({
166+
method: "GET",
167+
url: `/data/d3/era/${eraId}/leaderboard/${leaderboard}`,
168+
});
169+
}

src/diablo3/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { era, eraLeaderboard, eras, season, seasonLeaderboard, seasons } from "./game_data/d3.ts";
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { LocalizedString, request } from "../../shared/index.ts";
2+
import { Search, search, SearchParameters } from "../search.ts";
3+
4+
interface Cardback {
5+
id: number;
6+
sortCategory: number;
7+
text: LocalizedString;
8+
name: LocalizedString;
9+
}
10+
11+
/**
12+
* Returns an up-to-date list of all card backs matching the search criteria.
13+
*
14+
* @param SearchParameters - Object containing search parameters.
15+
* @returns A promise that resolves to an object representing an up-to-date list of all card backs matching the search criteria.
16+
*/
17+
export async function searchCardbacks(searchParameters: SearchParameters): Promise<Search> {
18+
return await search("/cardback", searchParameters);
19+
}
20+
21+
/**
22+
* Returns the card back with an ID or slug that matches the one you specify.
23+
*
24+
* @param idorslug - The unique identifier for the card back by slug.
25+
* @returns A promise that resolves to an object representing details about a card back.
26+
*/
27+
export async function fetchCardback(idorslug: string): Promise<Cardback> {
28+
return await request({
29+
method: "GET",
30+
url: `/hearthstone/cardback/${idorslug}`,
31+
});
32+
}

src/hearthstone/game_data/cards.ts

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import { LocalizedString, request, RequestOptions } from "../../shared/index.ts";
2+
import { Search, search, SearchParameters } from "../search.ts";
3+
4+
interface Card {
5+
id: number;
6+
collectible: number;
7+
slug: string;
8+
classId: number;
9+
multiClassIds: number[];
10+
cardTypeId: number;
11+
cardSetId: number;
12+
rarityId: number;
13+
artistName: string;
14+
health: number;
15+
attack: number;
16+
manaCost: number;
17+
name: LocalizedString;
18+
text: LocalizedString;
19+
image: string;
20+
imageGold: string;
21+
flavorText: LocalizedString;
22+
cropImage: string;
23+
keywordIds: number[];
24+
}
25+
26+
/**
27+
* Returns an up-to-date list of all cards matching the search criteria.
28+
*
29+
* @param SearchParameters - Object containing search parameters.
30+
* @returns A promise that resolves to an object representing an up-to-date list of all cards matching the search criteria.
31+
*/
32+
export async function searchCards(searchParameters: SearchParameters): Promise<Search> {
33+
return await search("/cards", searchParameters);
34+
}
35+
36+
/**
37+
* Returns the card with an ID or slug that matches the one you specify.
38+
*
39+
* @param idorslug - The unique identifier for the card by slug.
40+
* @returns A promise that resolves to an object representing details about a card.
41+
*/
42+
export async function fetchCard(idorslug: string, gameMode?: string): Promise<Card> {
43+
const reqOptions: RequestOptions = {
44+
method: "GET",
45+
url: `/hearthstone/cards/${idorslug}`,
46+
};
47+
48+
if (gameMode) {
49+
reqOptions["qs"] = { gameMode };
50+
}
51+
52+
return await request(reqOptions);
53+
}

0 commit comments

Comments
 (0)