Skip to content

Commit

Permalink
more endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
Pinta365 committed Sep 25, 2023
1 parent 0247b24 commit e49b774
Show file tree
Hide file tree
Showing 19 changed files with 773 additions and 18 deletions.
32 changes: 16 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,22 @@ Let me know if you want certain APIs to be prioritized.

### APIs implemented

| APIs | Status | Note |
| --------------------------------------------- | ------ | ---- |
| **World of Warcraft:** Game Data APIs || |
| **World of Warcraft:** Profile APIs || |
| | | |
| **World of Warcraft Classic:** Game Data APIs | | |
| | | |
| **Diablo III:** Community APIs | | |
| **Diablo III:** Game Data APIs | | |
| | | |
| **Hearthstone:** Game Data APIs | | |
| | | |
| **Overwatch League:** Community APIs** | | |
| | | |
| **StarCraft II:** Community APIs | | |
| **StarCraft II:** Game Data APIs | | |
| APIs | Status | Note |
| --------------------------------------------- | ------ | ----------------------------------------------------------------------------------- |
| **World of Warcraft:** Game Data APIs || |
| **World of Warcraft:** Profile APIs || |
| | | |
| **World of Warcraft Classic:** Game Data APIs | | |
| | | |
| **Diablo III:** Community APIs | | |
| **Diablo III:** Game Data APIs | | |
| | | |
| **Hearthstone:** Game Data APIs | | |
| | | |
| **Overwatch League:** Community APIs** | | Only seem to support US region and some data types are partially defined as Unknown |
| | | |
| **StarCraft II:** Community APIs | | |
| **StarCraft II:** Game Data APIs | | |

## Issues

Expand Down
6 changes: 4 additions & 2 deletions mod.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { authenticate, setup } from "./src/shared/index.ts";
import * as wow from "./src/wow/index.ts";
import * as wowClassic from "./src/wow_classic/index.ts";
import * as hearthstone from "./src/hearthstone/index.ts";
import * as owl from "./src/overwatch/index.ts";
import * as sc2 from "./src/starcraft2/index.ts";

export { authenticate, setup, wow, wowClassic };
export { authenticate, hearthstone, owl, sc2, setup, wow };
169 changes: 169 additions & 0 deletions src/diablo3/game_data/d3.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
import { LinkSelfHref, LocalizedString, request } from "../../shared/index.ts";

interface Seasons extends LinkSelfHref {
season: {
href: string;
}[];
current_season: number;
service_current_season: number;
service_season_state: string;
last_update_time: string;
generated_by: string;
}

interface Season extends LinkSelfHref {
leaderboard: {
team_size?: number;
ladder: {
href: string;
};
hardcore?: boolean;
hero_class_string?: LocalizedString;
}[];
season_id: number;
last_update_time: string;
generated_by: string;
}

interface LeaderboardData {
id: string;
string?: string;
number?: number;
timestamp?: number;
}

interface LeaderboardBase extends LinkSelfHref {
row: {
player: {
key: string;
accountId: number;
data: LeaderboardData[];
}[];
order: 1;
data: LeaderboardData[];
}[];
key: string;
title: LocalizedString;
column: {
id: string;
hidden: boolean;
order: number;
label: LocalizedString;
type: string;
}[];
last_update_time: string;
generated_by: string;
}

interface SeasonLeaderboard extends LeaderboardBase {
achievement_points: boolean;
season: number;
}

interface EraLeaderboard extends LeaderboardBase {
greater_rift: boolean;
greater_rift_solo_class: string;
era: number;
}

interface Eras extends LinkSelfHref {
era: {
href: string;
}[];
current_era: number;
last_update_time: string;
generated_by: string;
}

interface Era extends LinkSelfHref {
leaderboard: {
team_size?: number;
ladder: {
href: string;
};
hardcore?: boolean;
hero_class_string?: LocalizedString;
}[];
era_id: number;
era_start_date: number;
last_update_time: string;
generated_by: string;
}

/**
* Returns an index of available seasons.
*
* @returns A promise that resolves to an object representing an index of available seasons.
*/
export async function seasons(): Promise<Seasons> {
return await request({
method: "GET",
url: "/data/d3/season/",
});
}

/**
* Returns an index of available seasons.
*
* @param seasonId - The season for the leaderboard list.
* @returns A promise that resolves to an object representing the data for a league.
*/
export async function season(seasonId: number): Promise<Season> {
return await request({
method: "GET",
url: `/data/d3/season/${seasonId}`,
});
}

/**
* Returns a the specified leaderboard for the specified season.
*
* @param seasonId - The season for the leaderboard.
* @param leaderboard - The leaderboard to retrieve.
* @returns A promise that resolves to an object representing the data for a the specified leaderboard for the specified season.
*/
export async function seasonLeaderboard(seasonId: number, leaderboard: string): Promise<SeasonLeaderboard> {
return await request({
method: "GET",
url: `/data/d3/season/${seasonId}/leaderboard/${leaderboard}`,
});
}

/**
* Returns an index of available eras.
*
* @returns A promise that resolves to an object representing an index of available eras.
*/
export async function eras(): Promise<Eras> {
return await request({
method: "GET",
url: "/data/d3/era/",
});
}

/**
* Returns a leaderboard list for a particular era.
*
* @param eraId - The era to retrieve.
* @returns A promise that resolves to an object representing a leaderboard list for a particular era.
*/
export async function era(eraId: number): Promise<Era> {
return await request({
method: "GET",
url: `/data/d3/era/${eraId}`,
});
}

/**
* Returns the specified leaderboard for the specified era.
*
* @param eraId - The era for the leaderboard.
* @param leaderboard - The leaderboard to retrieve.
* @returns A promise that resolves to an object representing the data for a the specified leaderboard for the specified era.
*/
export async function eraLeaderboard(eraId: number, leaderboard: string): Promise<EraLeaderboard> {
return await request({
method: "GET",
url: `/data/d3/era/${eraId}/leaderboard/${leaderboard}`,
});
}
1 change: 1 addition & 0 deletions src/diablo3/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { era, eraLeaderboard, eras, season, seasonLeaderboard, seasons } from "./game_data/d3.ts";
32 changes: 32 additions & 0 deletions src/hearthstone/game_data/card_backs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { LocalizedString, request } from "../../shared/index.ts";
import { Search, search, SearchParameters } from "../search.ts";

interface Cardback {
id: number;
sortCategory: number;
text: LocalizedString;
name: LocalizedString;
}

/**
* Returns an up-to-date list of all card backs matching the search criteria.
*
* @param SearchParameters - Object containing search parameters.
* @returns A promise that resolves to an object representing an up-to-date list of all card backs matching the search criteria.
*/
export async function searchCardbacks(searchParameters: SearchParameters): Promise<Search> {
return await search("/cardback", searchParameters);
}

/**
* Returns the card back with an ID or slug that matches the one you specify.
*
* @param idorslug - The unique identifier for the card back by slug.
* @returns A promise that resolves to an object representing details about a card back.
*/
export async function fetchCardback(idorslug: string): Promise<Cardback> {
return await request({
method: "GET",
url: `/hearthstone/cardback/${idorslug}`,
});
}
53 changes: 53 additions & 0 deletions src/hearthstone/game_data/cards.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import { LocalizedString, request, RequestOptions } from "../../shared/index.ts";
import { Search, search, SearchParameters } from "../search.ts";

interface Card {
id: number;
collectible: number;
slug: string;
classId: number;
multiClassIds: number[];
cardTypeId: number;
cardSetId: number;
rarityId: number;
artistName: string;
health: number;
attack: number;
manaCost: number;
name: LocalizedString;
text: LocalizedString;
image: string;
imageGold: string;
flavorText: LocalizedString;
cropImage: string;
keywordIds: number[];
}

/**
* Returns an up-to-date list of all cards matching the search criteria.
*
* @param SearchParameters - Object containing search parameters.
* @returns A promise that resolves to an object representing an up-to-date list of all cards matching the search criteria.
*/
export async function searchCards(searchParameters: SearchParameters): Promise<Search> {
return await search("/cards", searchParameters);
}

/**
* Returns the card with an ID or slug that matches the one you specify.
*
* @param idorslug - The unique identifier for the card by slug.
* @returns A promise that resolves to an object representing details about a card.
*/
export async function fetchCard(idorslug: string, gameMode?: string): Promise<Card> {
const reqOptions: RequestOptions = {
method: "GET",
url: `/hearthstone/cards/${idorslug}`,
};

if (gameMode) {
reqOptions["qs"] = { gameMode };
}

return await request(reqOptions);
}
Loading

0 comments on commit e49b774

Please sign in to comment.