### Project Navigation Guide Source: https://github.com/pewtro/blizzard-api/blob/main/_autodocs/README.md This diagram illustrates the recommended path for navigating the project's documentation, from initial setup to deep dives into architecture and API references. ```text Start Here ↓ [overview.md] → Understand what this is ↓ [quick-start.md] → Get it working in 5 minutes ↓ [configuration.md] → Fine-tune how it works ↓ [api-reference/] → Learn specific endpoints ├─ [core.md] → Core types ├─ [client.md] → HTTP client ├─ [wow-endpoints.md] → WoW APIs └─ [other-games.md] → D3/SC2/Hearthstone ↓ [types.md] → Find exact type definitions ↓ [architecture.md] → Deep dive into design ↓ [INDEX.md] → Search by function name ``` -------------------------------- ### Install Classic WoW Package Source: https://github.com/pewtro/blizzard-api/blob/main/packages/classic-wow/README.md Install the classic-wow package along with the core package. ```sh npm i @blizzard-api/core @blizzard-api/classic-wow ``` -------------------------------- ### Install @blizzard-api/core and @blizzard-api/wow Source: https://github.com/pewtro/blizzard-api/blob/main/packages/wow/README.md Install the core package and the World of Warcraft package using npm. ```sh npm i @blizzard-api/core @blizzard-api/wow ``` -------------------------------- ### Install Core Package Source: https://github.com/pewtro/blizzard-api/blob/main/packages/core/README.md Install the core package using npm. ```sh npm i @blizzard-api/core ``` -------------------------------- ### Full HTTP Client Configuration Example Source: https://github.com/pewtro/blizzard-api/blob/main/_autodocs/configuration.md A comprehensive example demonstrating the configuration of timeout, retry logic, custom headers, and hooks for the HTTP client. ```typescript const client = await createBlizzardApiClient({ key: process.env.BLIZZARD_CLIENT_ID, secret: process.env.BLIZZARD_CLIENT_SECRET, origin: 'us', locale: 'en_US', kyOptions: { timeout: 30_000, retry: { limit: 3, methods: ['get'], statusCodes: [429, 500, 502, 503, 504], }, headers: { 'User-Agent': 'MyBlizzardApp/1.0', }, hooks: { beforeRequest: [ (request) => { // Log all requests console.log(`[${new Date().toISOString()}] ${request.method} ${request.url}`); }, ], afterResponse: [ (request, options, response) => { // Log response status if (!response.ok) { console.error(`[${new Date().toISOString()}] ${response.status} ${request.url}`); } }, ], }, }, }); ``` -------------------------------- ### Install Blizzard API Client Source: https://github.com/pewtro/blizzard-api/blob/main/README.md Install the client package to enable an API client with built-in helpers for easier connection and data consumption. ```sh npm i @blizzard-api/client ``` -------------------------------- ### Install Blizzard API Client and Game Packages Source: https://github.com/pewtro/blizzard-api/blob/main/_autodocs/quick-start.md Install the core client library along with specific game packages like World of Warcraft (WoW). Use this command to set up the necessary dependencies for your project. ```bash # Install the client and WoW package npm install @blizzard-api/client @blizzard-api/wow # Or for other games npm install @blizzard-api/client @blizzard-api/d3 npm install @blizzard-api/client @blizzard-api/sc2 npm install @blizzard-api/client @blizzard-api/hs ``` -------------------------------- ### Install @blizzard-api/hs Package Source: https://github.com/pewtro/blizzard-api/blob/main/packages/hs/README.md Install the Hearthstone package along with the core package using npm. ```sh npm i @blizzard-api/core @blizzard-api/hs ``` -------------------------------- ### Install World of Warcraft Package Source: https://github.com/pewtro/blizzard-api/blob/main/README.md Install the World of Warcraft specific package for API access. If your package manager does not automatically install peer dependencies, also install the core package. ```sh npm i @blizzard-api/wow ``` ```sh npm i @blizzard-api/core ``` -------------------------------- ### Install @blizzard-api/sc2 Package Source: https://github.com/pewtro/blizzard-api/blob/main/packages/sc2/README.md Install the SC2 package along with the core package using npm. ```sh npm i @blizzard-api/core @blizzard-api/sc2 ``` -------------------------------- ### Install @blizzard-api/d3 Package Source: https://github.com/pewtro/blizzard-api/blob/main/packages/d3/README.md Install the Diablo 3 package along with the core package using npm. ```sh npm i @blizzard-api/core @blizzard-api/d3 ``` -------------------------------- ### WoW Index Endpoint Example Source: https://github.com/pewtro/blizzard-api/blob/main/_autodocs/api-reference/wow-endpoints.md Use index endpoints to retrieve a list of related resources. This example shows how to get the achievement index. ```typescript const achievementIndex = wow.achievementIndex(); // Resource with path: '/data/wow/achievement/index' ``` -------------------------------- ### WoW Get by ID Endpoint Example Source: https://github.com/pewtro/blizzard-api/blob/main/_autodocs/api-reference/wow-endpoints.md Use single-resource endpoints that accept an ID parameter to fetch a specific resource. This example retrieves a specific achievement by its ID. ```typescript const achievement = wow.achievement(123); // Resource with path: '/data/wow/achievement/123' ``` -------------------------------- ### Item Endpoint Example Source: https://github.com/pewtro/blizzard-api/blob/main/_autodocs/api-reference/wow-endpoints.md Demonstrates how to get an item resource by its ID. The resource object contains the API path and namespace, which can then be used with a client to fetch the actual data. ```APIDOC ## GET /data/wow/item/{itemId} ### Description Retrieves information about a specific item using its unique ID. ### Method GET ### Endpoint /data/wow/item/{itemId} ### Parameters #### Path Parameters - **itemId** (number) - Required - The unique identifier for the item. ### Request Example ```typescript import { wow } from '@blizzard-api/wow'; const itemResource = wow.item(12345); // Resource object: { path: '/data/wow/item/12345', namespace: 'static' } ``` ### Response #### Success Response (200) - **id** (number) - The item's ID. - **name** (string) - The item's name. - **quality** (object) - The item's quality. - **icon** (string) - The item's icon path. #### Response Example ```json { "id": 12345, "name": "Example Item", "quality": { "type": "POOR", "name": "Poor" }, "icon": "inv_sword_01" } ``` ``` -------------------------------- ### Achievement Index Endpoint Example Source: https://github.com/pewtro/blizzard-api/blob/main/_autodocs/api-reference/wow-endpoints.md Shows how to retrieve a list of all achievements. This is an example of an index endpoint that returns a collection of resources. ```APIDOC ## GET /data/wow/achievement/index ### Description Retrieves a list of all available achievements. ### Method GET ### Endpoint /data/wow/achievement/index ### Response #### Success Response (200) - **achievements** (array) - A list of achievement objects. - **id** (number) - The achievement's ID. - **key** (object) - A key object containing the achievement's HATEOAS link. - **href** (string) - The URL to retrieve the achievement details. - **name** (string) - The name of the achievement. #### Response Example ```json { "achievements": [ { "id": 1, "key": { "href": "/data/wow/achievement/1?namespace=static-us" }, "name": "Level 10" } ] } ``` ``` -------------------------------- ### Direct Dependencies Example Source: https://github.com/pewtro/blizzard-api/blob/main/_autodocs/architecture.md Illustrates the direct dependencies of the Application module within the Blizzard API project. ```text Application ├── @blizzard-api/wow (or d3, sc2, hs) │ └── @blizzard-api/core └── @blizzard-api/client └── @blizzard-api/core └── ky (external) ``` -------------------------------- ### WoW Search Endpoint Example Source: https://github.com/pewtro/blizzard-api/blob/main/_autodocs/api-reference/wow-endpoints.md Utilize search endpoints to query for resources using various parameters like name, locale, and sorting. This example searches for items named 'sword'. ```typescript const results = wow.itemSearch({ name: 'sword', locale: 'en_US', orderby: 'name', _page: 0, }); ``` -------------------------------- ### Peer Dependencies Example Source: https://github.com/pewtro/blizzard-api/blob/main/_autodocs/architecture.md Lists the peer dependencies required by various Blizzard API modules. ```text - @blizzard-api/wow → requires @blizzard-api/core - @blizzard-api/d3 → requires @blizzard-api/core - @blizzard-api/sc2 → requires @blizzard-api/core - @blizzard-api/hs → requires @blizzard-api/core - @blizzard-api/classic-wow → requires @blizzard-api/core - @blizzard-api/client → requires @blizzard-api/core ``` -------------------------------- ### WoW Protected Endpoint Example Source: https://github.com/pewtro/blizzard-api/blob/main/_autodocs/api-reference/wow-endpoints.md Protected endpoints require a user OAuth token for authentication. This example shows how to construct a resource for a protected character endpoint. ```typescript const resource = wow.protectedCharacterProfileSummary(realmId, characterId, token); // Resource with token field set ``` -------------------------------- ### WoW Character Endpoint Example Source: https://github.com/pewtro/blizzard-api/blob/main/_autodocs/api-reference/wow-endpoints.md Character endpoints require both the realm ID and character name to fetch specific character data. This example retrieves a character's profile summary. ```typescript const profile = wow.characterProfileSummary('area-52', 'varian'); // Path: '/profile/wow/character/area-52/varian' ``` -------------------------------- ### Create Blizzard API Client and Fetch Data Source: https://github.com/pewtro/blizzard-api/blob/main/_autodocs/api-reference/wow-endpoints.md Demonstrates how to initialize the Blizzard API client and make requests to WoW endpoints for items, character profiles, item searches, and auctions. Includes examples for specifying locale. ```typescript import { createBlizzardApiClient } from '@blizzard-api/client'; import { wow } from '@blizzard-api/wow'; const client = await createBlizzardApiClient({ key: process.env.BLIZZARD_CLIENT_ID, secret: process.env.BLIZZARD_CLIENT_SECRET, origin: 'us', }); // Fetch item const item = await client.sendRequest(wow.item(12345)); console.log(item.name); // Fetch character profile const char = await client.sendRequest( wow.characterProfileSummary('area-52', 'varian') ); console.log(char.character.name, char.character.level); // Search items const results = await client.sendRequest( wow.itemSearch({ name: 'sword', locale: 'en_US', }) ); console.log(results.results.length, 'items found'); // Fetch with specific locale const itemEu = await client.sendRequest(wow.item(12345), { locale: 'de_DE', }); // Fetch auction house const auctions = await client.sendRequest(wow.auctions(1)); // connected realm 1 console.log(auctions.auctions.length, 'active auctions'); ``` -------------------------------- ### External Dependencies Example Source: https://github.com/pewtro/blizzard-api/blob/main/_autodocs/architecture.md Identifies external dependencies used by the Blizzard API project, such as the 'ky' HTTP client. ```text - ky (v2.0.2) — HTTP client library used by @blizzard-api/client ``` -------------------------------- ### Get Realm Index Source: https://github.com/pewtro/blizzard-api/blob/main/_autodocs/api-reference/wow-endpoints.md Fetch a list of all available realms. ```typescript realmIndex(): Resource ``` -------------------------------- ### Constructing API Path with Base Path Source: https://github.com/pewtro/blizzard-api/blob/main/_autodocs/api-reference/core.md Example demonstrating how to use a base path constant (wowBasePath) to construct a complete API endpoint URL for a specific resource. ```typescript import { wowBasePath } from '@blizzard-api/core'; const path = `${wowBasePath}/item/12345`; // '/data/wow/item/12345' ``` -------------------------------- ### Make a World of Warcraft Item Data Request Source: https://github.com/pewtro/blizzard-api/blob/main/_autodocs/quick-start.md Use the initialized client to fetch data for a specific World of Warcraft item by its ID. This example demonstrates how to retrieve item name, quality, and sell price. ```typescript import { wow } from '@blizzard-api/wow'; // Fetch item data const item = await client.sendRequest(wow.item(12345)); console.log(item.name); // Item name console.log(item.quality); // Rarity console.log(item.sell_price); // Vendor price ``` -------------------------------- ### Example Usage of Hearthstone API Client Source: https://github.com/pewtro/blizzard-api/blob/main/_autodocs/api-reference/other-games.md Demonstrates how to use the Hearthstone API client to search cards, fetch a single card, decode a deck, and retrieve metadata. Requires prior initialization of the Blizzard API client. ```typescript import { createBlizzardApiClient } from '@blizzard-api/client'; import { hs } from '@blizzard-api/hs'; const client = await createBlizzardApiClient({...}); // Search cards const results = await client.sendRequest( hs.cardSearch({ q: 'fireball', locale: 'en_US', }) ); console.log(results.cards.length, 'cards found'); // Fetch single card const card = await client.sendRequest(hs.fetchOneCard(1234)); console.log(card.name, card.manaCost); // Fetch deck from code const deck = await client.sendRequest( hs.getDeck('AAECAQcc...') ); console.log(deck.cards.length, 'cards in deck'); // Get metadata const metadata = await client.sendRequest( hs.allMetadata('en_US') ); console.log(metadata.classes.length, 'classes'); ``` -------------------------------- ### Item Search Endpoint Example Source: https://github.com/pewtro/blizzard-api/blob/main/_autodocs/api-reference/wow-endpoints.md Illustrates how to search for items using various query parameters like name, locale, and sorting. This demonstrates a search endpoint pattern. ```APIDOC ## GET /data/wow/search/item ### Description Searches for items based on specified criteria. ### Method GET ### Endpoint /data/wow/search/item ### Parameters #### Query Parameters - **name** (string) - Required - The name of the item to search for. - **locale** (string) - Optional - The locale to use for the search (e.g., 'en_US'). - **orderby** (string) - Optional - The field to sort the results by (e.g., 'name'). - **_page** (number) - Optional - The page number for paginated results. ### Request Example ```typescript import { wow } from '@blizzard-api/wow'; const results = wow.itemSearch({ name: 'sword', locale: 'en_US', orderby: 'name', _page: 0, }); ``` ### Response #### Success Response (200) - **results** (array) - A list of items matching the search criteria. - **id** (number) - The item's ID. - **name** (string) - The item's name. - **item_class** (object) - The item's class. - **item_subclass** (object) - The item's subclass. - **quality** (object) - The item's quality. - **icon** (string) - The item's icon path. #### Response Example ```json { "results": [ { "id": 1001, "name": "Sword of Power", "item_class": {"key": {"href": "/data/wow/item-class/2?namespace=static-us"}, "name": "Weapon"}, "item_subclass": {"key": {"href": "/data/wow/item-class/2/item-subclass/3?namespace=static-us"}, "name": "Two-Handed Swords"}, "quality": {"type": "RARE", "name": "Rare"}, "icon": "inv_sword_02" } ] } ``` ``` -------------------------------- ### Get Realm by Slug Source: https://github.com/pewtro/blizzard-api/blob/main/_autodocs/api-reference/wow-endpoints.md Retrieve details for a specific realm using its slug. ```typescript realm(realmSlug: string): Resource ``` -------------------------------- ### Configure Client with Specific Locale Source: https://github.com/pewtro/blizzard-api/blob/main/_autodocs/configuration.md Examples demonstrating how to configure the client for different regions and locales. The 'origin' parameter is required, while 'locale' is optional and defaults to the region's default if not specified. ```typescript // US region with Spanish (Mexico) const clientMx = await createBlizzardApiClient({ key: 'id', secret: 'secret', origin: 'us', locale: 'es_MX', }); // EU region with German const clientDe = await createBlizzardApiClient({ key: 'id', secret: 'secret', origin: 'eu', locale: 'de_DE', }); // Korea region (defaults to ko_KR) const clientKr = await createBlizzardApiClient({ key: 'id', secret: 'secret', origin: 'kr', }); ``` -------------------------------- ### StarCraft II API Usage Example Source: https://github.com/pewtro/blizzard-api/blob/main/_autodocs/api-reference/other-games.md Demonstrates fetching various StarCraft II data like player profiles, ladder summaries, Grandmaster leaderboards, and league data using the Blizzard API client. ```typescript import { createBlizzardApiClient } from '@blizzard-api/client'; import { sc2 } from '@blizzard-api/sc2'; const client = await createBlizzardApiClient({...}); // Fetch player profile const profile = await client.sendRequest(sc2.profile(1, 1, 12345678)); console.log(profile.profile.name); // Fetch ladder summary const ladders = await client.sendRequest( sc2.ladderSummary(1, 1, 12345678) ); console.log(ladders.allLadders[0].ladderName); // Fetch Grandmaster leaderboard const gm = await client.sendRequest(sc2.grandmasterLeaderboard(2)); // EU console.log(gm.ladderTeams.length, 'Grandmasters'); // Fetch league data const league = await client.sendRequest( sc2.getLeagueData(60, 201, 1, 5000) // season, queue, teamtype, league ); console.log(league.tier[0].division[0].member.length, 'players'); ``` -------------------------------- ### Get Item Media Source: https://github.com/pewtro/blizzard-api/blob/main/_autodocs/api-reference/wow-endpoints.md Retrieves the icon or media for a specific item using its ID. ```typescript itemMedia(itemId: number): Resource ``` -------------------------------- ### Get Request URL Source: https://github.com/pewtro/blizzard-api/blob/main/_autodocs/INDEX.md Constructs the full URL for a given API resource and options. ```typescript client.getRequestUrl(resource, options?): string ``` -------------------------------- ### TypeScript - Fetching WoW Item Data Source: https://github.com/pewtro/blizzard-api/blob/main/_autodocs/api-reference/client.md Example of using sendRequest to fetch item data from the World of Warcraft API. Requires client initialization with API keys. ```typescript import { createBlizzardApiClient } from '@blizzard-api/client'; import { wow } from '@blizzard-api/wow'; const client = await createBlizzardApiClient({ key: 'my-id', secret: 'my-secret', origin: 'us', }); // Fetch item data const itemResource = wow.item(12345); const item = await client.sendRequest(itemResource); console.log(item.name); // Item name ``` -------------------------------- ### Get Character Equipment Summary Source: https://github.com/pewtro/blizzard-api/blob/main/_autodocs/api-reference/wow-endpoints.md Retrieves a list of currently equipped items on a character. Requires realm slug and character name. ```typescript characterEquipmentSummary(realmSlug: string, characterName: string): Resource ``` -------------------------------- ### Get Guild by Realm and Name Source: https://github.com/pewtro/blizzard-api/blob/main/_autodocs/api-reference/wow-endpoints.md Fetch details for a specific guild using its realm slug and guild name. ```typescript guild(realmSlug: string, guildName: string): Resource ``` -------------------------------- ### Character Profile Summary Endpoint Example Source: https://github.com/pewtro/blizzard-api/blob/main/_autodocs/api-reference/wow-endpoints.md Shows how to retrieve a character's profile summary using their realm and character name. This is a common endpoint for character-related data. ```APIDOC ## GET /profile/wow/character/{realmName}/{characterName}/profile ### Description Retrieves a summary of a character's profile, including basic information like level, class, and realm. ### Method GET ### Endpoint /profile/wow/character/{realmName}/{characterName}/profile ### Parameters #### Path Parameters - **realmName** (string) - Required - The name of the realm the character belongs to. - **characterName** (string) - Required - The name of the character. ### Request Example ```typescript import { wow } from '@blizzard-api/wow'; const profile = wow.characterProfileSummary('area-52', 'varian'); // Resource object: { path: '/profile/wow/character/area-52/varian/profile', namespace: 'profile' } ``` ### Response #### Success Response (200) - **id** (number) - The character's ID. - **name** (string) - The character's name. - **realm** (object) - Information about the character's realm. - **level** (number) - The character's level. - **class** (object) - Information about the character's class. #### Response Example ```json { "id": 123456, "name": "Varian", "realm": {"key": {"href": "/data/wow/realm/123?namespace=dynamic-us"}, "name": "Area 52", "id": 123}, "level": 70, "class": {"key": {"href": "/data/wow/character-class/7?namespace=static-us"}, "name": "Demon Hunter", "id": 7} } ``` ``` -------------------------------- ### Get Request Configuration Source: https://github.com/pewtro/blizzard-api/blob/main/_autodocs/api-reference/client.md Builds HTTP request configuration, including headers and query parameters, for a given resource. This is useful for preparing requests to the Blizzard API. ```typescript public getRequestConfig( resource: Resource, options?: Partial, headers?: Record, ): { headers: Record & { Authorization: `Bearer ${string}`; 'Battlenet-Namespace'?: string; 'Content-Type': 'application/json'; }; searchParams: Record & { locale: Locales; }; } ``` ```typescript const resource = wow.item(12345); const config = client.getRequestConfig(resource); console.log(config.headers.Authorization); // 'Bearer access_token_here' console.log(config.searchParams.locale); // 'en_US' ``` -------------------------------- ### Get Blizzard API Configuration Source: https://github.com/pewtro/blizzard-api/blob/main/_autodocs/api-reference/core.md Retrieves the hostname and default locale for a given region. Use the default locale if none is specified. ```typescript import { getBlizzardApi } from '@blizzard-api/core'; const api = getBlizzardApi('us', 'en_US'); console.log(api.hostname); // 'https://us.api.blizzard.com' console.log(api.locale); // 'en_US' // Use default locale const apiDefault = getBlizzardApi('eu'); console.log(apiDefault.locale); // 'en_GB' ``` -------------------------------- ### Initialize Client with Environment Variables Source: https://github.com/pewtro/blizzard-api/blob/main/_autodocs/configuration.md Import and create a Blizzard API client instance using environment variables for configuration. Ensure you have the necessary types imported. ```typescript // In your application import { createBlizzardApiClient } from '@blizzard-api/client'; const client = await createBlizzardApiClient({ key: process.env.BLIZZARD_CLIENT_ID, secret: process.env.BLIZZARD_CLIENT_SECRET, origin: process.env.BLIZZARD_REGION as Origins, locale: process.env.BLIZZARD_LOCALE as Locales, }); ``` -------------------------------- ### Default Export for WoW Module Source: https://github.com/pewtro/blizzard-api/blob/main/_autodocs/architecture.md An alternative method is to import the WoW module as a default export. This can be useful for simpler setups. ```typescript // Alternative: import as default import wow from '@blizzard-api/wow'; wow.item(123); ``` -------------------------------- ### Get Character Profile Summary Source: https://github.com/pewtro/blizzard-api/blob/main/_autodocs/api-reference/wow-endpoints.md Fetches a complete character profile summary, including gear, stats, and talents. Requires realm slug and character name. No token required. ```typescript characterProfileSummary(realmSlug: string, characterName: string): Resource ``` -------------------------------- ### Get Character Pets Collection Summary Source: https://github.com/pewtro/blizzard-api/blob/main/_autodocs/api-reference/wow-endpoints.md Retrieves a summary of battle pets collected by a character. Requires realm slug and character name. ```typescript characterPetsCollectionSummary(realmSlug: string, characterName: string): Resource ``` -------------------------------- ### Protected Character Profile Summary Endpoint Example Source: https://github.com/pewtro/blizzard-api/blob/main/_autodocs/api-reference/wow-endpoints.md Demonstrates accessing a protected character endpoint that requires an OAuth token for authentication. This is used for endpoints that expose private user data. ```APIDOC ## GET /profile/wow/protected/character/{realmId}/{characterId}/summary ### Description Retrieves a summary of a protected character profile. This endpoint requires an OAuth token for authentication. ### Method GET ### Endpoint /profile/wow/protected/character/{realmId}/{characterId}/summary ### Parameters #### Path Parameters - **realmId** (number) - Required - The ID of the realm the character belongs to. - **characterId** (number) - Required - The ID of the character. #### Request Body (No request body, authentication is via OAuth token) ### Request Example ```typescript import { wow } from '@blizzard-api/wow'; // Assume 'token' is a valid OAuth access token const resource = wow.protectedCharacterProfileSummary(realmId, characterId, token); // Resource object with token field set ``` ### Response #### Success Response (200) - **id** (number) - The character's ID. - **name** (string) - The character's name. - **realm** (object) - Information about the character's realm. - **level** (number) - The character's level. - **class** (object) - Information about the character's class. #### Response Example ```json { "id": 123456, "name": "ExampleChar", "realm": {"key": {"href": "/data/wow/realm/123?namespace=dynamic-us"}, "name": "Area 52", "id": 123}, "level": 70, "class": {"key": {"href": "/data/wow/character-class/7?namespace=static-us"}, "name": "Demon Hunter", "id": 7} } ``` ``` -------------------------------- ### Create and Use Blizzard API Client Source: https://github.com/pewtro/blizzard-api/blob/main/README.md Create an API client instance using your credentials and origin. Then, use the client to send requests to the API, with responses automatically typed. ```ts import { createBlizzardApiClient } from '@blizzard-api/client'; import { wow } from '@blizzard-api/wow'; const client = await createBlizzardApiClient({ key: 'environment.blizzardClientId', secret: 'environment.blizzardClientSecret', origin: 'eu', }); //Response will automatically be typed with the appropriate values const response = await client.sendRequest(wow.commodities()); console.log(response); ^ typeof AuctionHouseCommoditiesResponse ``` -------------------------------- ### Get Blizzard API Endpoint Details Source: https://github.com/pewtro/blizzard-api/blob/main/packages/core/README.md Use the helper function to get the origin, hostname, and locale based on a provided origin string. Supported origins include 'kr', 'tw', 'us'. ```ts import type { getBlizzardApi } from '@blizzard-api/core'; const { origin, hostname, locale } = getBlizzardApi('eu'); // "kr" | "tw" | "us" ``` -------------------------------- ### Environment Variables for Credentials Source: https://github.com/pewtro/blizzard-api/blob/main/_autodocs/configuration.md Set up your .env file with essential Blizzard API credentials. These variables are used during client initialization. ```bash # .env file BLIZZARD_CLIENT_ID=your_client_id_here BLIZZARD_CLIENT_SECRET=your_client_secret_here BLIZZARD_REGION=us BLIZZARD_LOCALE=en_US ``` -------------------------------- ### Get Guild Roster Source: https://github.com/pewtro/blizzard-api/blob/main/_autodocs/api-reference/wow-endpoints.md Retrieve the member list for a specific guild. ```typescript guildRoster(realmSlug: string, guildName: string): Resource ``` -------------------------------- ### Create and Use Blizzard API Client Source: https://github.com/pewtro/blizzard-api/blob/main/packages/client/README.md Import and initialize the client with credentials and origin. Send requests to game-specific endpoints, with responses automatically typed. ```ts import { createBlizzardApiClient } from '@blizzard-api/client'; //or import createBlizzardApiClient from '@blizzard-api/client'; import { wow } from '@blizzard-api/wow'; const client = await createBlizzardApiClient({ key: 'environment.blizzardClientId', secret: 'environment.blizzardClientSecret', origin: 'eu', }); //Response will automatically be typed with the appropriate values const response = await client.sendRequest(wow.commodities()); console.log(response); ^ typeof AuctionHouseCommoditiesResponse ``` -------------------------------- ### Create Blizzard API Client and Send Request Source: https://github.com/pewtro/blizzard-api/blob/main/packages/classic-wow/README.md Initialize the client with credentials and send a request to a Classic WoW endpoint. The response is automatically typed. ```ts import { createBlizzardApiClient } from '@blizzard-api/client'; import { classicWow } from '@blizzard-api/classic-wow'; const client = await createBlizzardApiClient({ key: 'environment.blizzardClientId', secret: 'environment.blizzardClientSecret', origin: 'eu', }); //Response will automatically be typed with the appropriate values const response = await client.sendRequest(classicWow.commodities()); console.log(response); ^ typeof AuctionHouseCommoditiesResponse ``` -------------------------------- ### Get Connected Realm Index Source: https://github.com/pewtro/blizzard-api/blob/main/_autodocs/api-reference/wow-endpoints.md Fetch a list of all connected realms. ```typescript connectedRealmIndex(): Resource ``` -------------------------------- ### Get Guild Activity Source: https://github.com/pewtro/blizzard-api/blob/main/_autodocs/api-reference/wow-endpoints.md Fetch recent activity logs for a specific guild. ```typescript guildActivity(realmSlug: string, guildName: string): Resource ``` -------------------------------- ### Import and Use WoW Endpoint Functions Source: https://github.com/pewtro/blizzard-api/blob/main/_autodocs/api-reference/wow-endpoints.md Demonstrates how to import WoW endpoint functions and use them to create Resource objects, which can then be sent via a Blizzard API client. ```typescript import { wow } from '@blizzard-api/wow'; // Endpoint functions return Resource objects const itemResource = wow.item(12345); // { path: '/data/wow/item/12345', namespace: 'static' } // Use with client const client = await createBlizzardApiClient({...}); const item = await client.sendRequest(itemResource); ``` -------------------------------- ### Get Guild Achievements Source: https://github.com/pewtro/blizzard-api/blob/main/_autodocs/api-reference/wow-endpoints.md Retrieve the achievement completion data for a specific guild. ```typescript guildAchievements(realmSlug: string, guildName: string): Resource ``` -------------------------------- ### Initialize Hearthstone API Client Source: https://github.com/pewtro/blizzard-api/blob/main/_autodocs/api-reference/other-games.md Import and initialize the Hearthstone API client. This is typically done once at the application's entry point. ```typescript import { hs } from '@blizzard-api/hs'; const cards = hs.cardSearch({ q: 'fireball', locale: 'en_US' }); const response = await client.sendRequest(cards); ``` -------------------------------- ### Initialize Blizzard API Client Source: https://github.com/pewtro/blizzard-api/blob/main/_autodocs/quick-start.md Create an instance of the Blizzard API client using your credentials and desired region/locale. Ensure environment variables for client ID and secret are set before running. ```typescript import { createBlizzardApiClient } from '@blizzard-api/client'; const client = await createBlizzardApiClient({ key: process.env.BLIZZARD_CLIENT_ID, secret: process.env.BLIZZARD_CLIENT_SECRET, origin: 'us', // Region: 'us', 'eu', 'kr', 'cn', 'tw' locale: 'en_US', // Optional, defaults to region's default }); ``` -------------------------------- ### Get Creature Type Index Source: https://github.com/pewtro/blizzard-api/blob/main/_autodocs/api-reference/wow-endpoints.md Retrieve a list of all available creature types. ```typescript creatureTypeIndex(): Resource ``` -------------------------------- ### Get Creature Family Index Source: https://github.com/pewtro/blizzard-api/blob/main/_autodocs/api-reference/wow-endpoints.md Retrieve a list of all available creature families. ```typescript creatureFamilyIndex(): Resource ``` -------------------------------- ### Get Item Set Index Source: https://github.com/pewtro/blizzard-api/blob/main/_autodocs/api-reference/wow-endpoints.md Retrieves an index of all available item sets. ```typescript itemSetIndex(): Resource ``` -------------------------------- ### Instantiate BlizzardApiClient Source: https://github.com/pewtro/blizzard-api/blob/main/_autodocs/api-reference/client.md Create a new client instance using your API key, secret, and origin. Credentials are validated on the first API call, not during instantiation. ```typescript import { BlizzardApiClient } from '@blizzard-api/client'; const client = new BlizzardApiClient({ key: 'my-client-id', secret: 'my-client-secret', origin: 'us', }); ``` -------------------------------- ### Get Item Class Index Source: https://github.com/pewtro/blizzard-api/blob/main/_autodocs/api-reference/wow-endpoints.md Retrieves an index of all available item classes. ```typescript itemClassIndex(): Resource ``` -------------------------------- ### Get Achievement Category Source: https://github.com/pewtro/blizzard-api/blob/main/_autodocs/api-reference/wow-endpoints.md Retrieves an achievement category by its ID. No token required. ```typescript achievementCategory(achievementCategoryId: number): Resource ``` -------------------------------- ### Create Blizzard API Client with Options Source: https://github.com/pewtro/blizzard-api/blob/main/_autodocs/api-reference/client.md Configure and create a Blizzard API client instance. Use this when you need to specify custom options like region, locale, or HTTP client settings. ```typescript interface ClientOptions { key: string; secret: string; origin: Origins; locale?: Locales; token?: string; kyOptions?: KyOptions; } ``` ```typescript const options: ClientOptions = { key: process.env.CLIENT_ID, secret: process.env.CLIENT_SECRET, origin: 'eu', locale: 'en_GB', kyOptions: { timeout: 30_000, retry: { limit: 3, methods: ['get'], }, }, }; const client = await createBlizzardApiClient(options); ``` -------------------------------- ### Get Single Achievement Source: https://github.com/pewtro/blizzard-api/blob/main/_autodocs/api-reference/wow-endpoints.md Retrieves a single achievement by its ID. No token required. ```typescript achievement(achievementId: number): Resource ``` -------------------------------- ### Get Achievement Index Source: https://github.com/pewtro/blizzard-api/blob/main/_autodocs/api-reference/wow-endpoints.md Retrieves an index of all achievements in the game. No token required. ```typescript achievementIndex(): Resource ``` -------------------------------- ### Get Connected Realm by ID Source: https://github.com/pewtro/blizzard-api/blob/main/_autodocs/api-reference/wow-endpoints.md Retrieve information about a connected realm using its ID. ```typescript connectedRealm(connectedRealmId: number): Resource ``` -------------------------------- ### Wow Package Module Structure Source: https://github.com/pewtro/blizzard-api/blob/main/_autodocs/architecture.md Illustrates the directory structure of the @blizzard-api/wow package, showing the organization of modules for different endpoint categories. ```tree packages/wow/src/ ├── index.ts (main entry, re-exports all) │ ├── character-profile/ (characterProfileSummary, characterProfileStatus) ├── character-equipment/ (characterEquipmentSummary) ├── character-media/ (characterMediaSummary) ├── character-achievements/ (characterAchievementsSummary, etc.) ├── character-collections/ (characterMountsCollectionSummary, etc.) ├── character-encounters/ (characterDungeons, characterRaids, etc.) ├── character-professions/ (characterProfessionsSummary) ├── character-pvp/ (characterPvpSummary, characterPvpBracketStatistics) ├── character-quests/ (characterQuests, characterCompletedQuests) ├── character-reputations/ (characterReputationsSummary) ├── character-specializations/ (characterSpecializationsSummary) ├── character-statistics/ (characterStatisticsSummary) ├── character-hunter-pets/ (characterHunterPetsSummary) ├── character-titles/ (characterTitlesSummary) ├── character-soulbinds/ (characterSoulbinds) ├── character-mythic-keystone-profile/ (characterMythicKeystoneProfileIndex, etc.) │ ├── account-profile/ (accountProfileSummary, accountMountsCollectionSummary, etc.) │ ├── achievements/ (achievement, achievementIndex, achievementCategory, etc.) ├── auction-house/ (auctions, commodities) ├── azerite-essence/ (azeriteEssence, azeriteEssenceIndex, etc.) ├── covenant/ (covenant, conduit, soulbind, etc.) ├── creature/ (creature, creatureFamily, creatureType, etc.) ├── d3/ (d3 package - not in wow) ├── guild/ (guild, guildAchievements, guildRoster, etc.) ├── guild-crest/ (guildCrestBorder, guildCrestEmblem, etc.) ├── heirloom/ (heirloom, heirloomIndex) ├── housing-decor/ (decor, fixture, room, etc.) ├── item/ (item, itemClass, itemSet, itemSearch, etc.) ├── journal/ (journalEncounter, journalInstance, etc.) ├── media-search/ (mediaSearch) ├── modified-crafting/ (modifiedCraftingCategory, etc.) ├── mount/ (mount, mountIndex, mountSearch) ├── mythic-keystone-affix/ (mythicKeystoneAffix, etc.) ├── mythic-keystone-dungeon/ (mythicKeystoneDungeon, etc.) ├── mythic-keystone-leaderboard/ (mythicKeystoneLeaderboard, etc.) ├── mythic-raid-leaderboard/ (mythicRaidLeaderboard) ├── pet/ (pet, petAbility, petMedia, etc.) ├── playable-class/ (playableClass, playableClassIndex, etc.) ├── playable-race/ (playableRace, playableRaceIndex) ├── playable-specialization/ (playableSpecialization, etc.) ├── power-type/ (powerType, powerTypeIndex) ├── profession/ (profession, professionIndex, recipe, etc.) ├── pvp-season/ (pvpSeason, pvpLeaderboard, etc.) ├── pvp-tier/ (pvpTier, pvpTierIndex, etc.) ├── quest/ (quest, questArea, questCategory, etc.) ├── realm/ (realm, realmIndex, realmSearch) ├── region/ (region, regionIndex) ├── reputations/ (reputationFaction, reputationTiers, etc.) ├── spell/ (spell, spellMedia, spellSearch) ├── talent/ (talentTree, pvpTalent, etc.) ├── tech-talent/ (techTalent, techTalentTree, etc.) ├── title/ (title, titleIndex) ├── toy/ (toy, toyIndex) ├── connected-realm/ (connectedRealm, connectedRealmIndex, etc.) └── wow-token/ (wowToken) Each module has: ├── index.ts (endpoint functions) └── types.ts (Response types) ``` -------------------------------- ### Get Creature Family Media Source: https://github.com/pewtro/blizzard-api/blob/main/_autodocs/api-reference/wow-endpoints.md Obtain the icon for a creature family using its ID. ```typescript creatureFamilyMedia(creatureFamilyId: number): Resource ``` -------------------------------- ### Get Creature Family by ID Source: https://github.com/pewtro/blizzard-api/blob/main/_autodocs/api-reference/wow-endpoints.md Fetch details about a creature family using its ID. ```typescript creatureFamily(creatureFamilyId: number): Resource ``` -------------------------------- ### Export Pattern for Wow Package Source: https://github.com/pewtro/blizzard-api/blob/main/_autodocs/architecture.md Demonstrates how to import and use functions from the @blizzard-api/wow package. All functions can be accessed via the main 'wow' object, or imported directly. ```typescript // packages/wow/src/index.ts import { wow } from '@blizzard-api/wow'; // All functions are available on the wow object wow.item(123) wow.characterProfileSummary('realm', 'name') wow.auctions(1) // ... 100+ functions // Direct imports also work import { item, characterProfileSummary } from '@blizzard-api/wow'; import type { ItemResponse, CharacterProfileSummaryResponse } from '@blizzard-api/wow'; ``` -------------------------------- ### Get Spell Media Source: https://github.com/pewtro/blizzard-api/blob/main/_autodocs/api-reference/wow-endpoints.md Retrieves the icon or media for a specific spell using its ID. ```typescript spellMedia(spellId: number): Resource ``` -------------------------------- ### Project File Structure Source: https://github.com/pewtro/blizzard-api/blob/main/_autodocs/INDEX.md This outlines the directory structure of the blizzard-api project, showing the organization of core utilities, API clients, and game-specific modules. ```tree output/ ├── INDEX.md (this file) ├── overview.md ├── quick-start.md ├── configuration.md ├── types.md └── api-reference/ ├── core.md ├── client.md ├── wow-endpoints.md └── other-games.md ``` -------------------------------- ### Get Spell by ID Source: https://github.com/pewtro/blizzard-api/blob/main/_autodocs/api-reference/wow-endpoints.md Retrieves data for a single spell using its unique ID. ```typescript spell(spellId: number): Resource ``` -------------------------------- ### Create Blizzard API Client Source: https://github.com/pewtro/blizzard-api/blob/main/_autodocs/configuration.md The minimum required configuration to create a client. Ensure you replace placeholder values with your actual client ID and secret. ```typescript import { createBlizzardApiClient } from '@blizzard-api/client'; const client = await createBlizzardApiClient({ key: 'YOUR_CLIENT_ID', secret: 'YOUR_CLIENT_SECRET', origin: 'us', }); ``` -------------------------------- ### Get Item Class by ID Source: https://github.com/pewtro/blizzard-api/blob/main/_autodocs/api-reference/wow-endpoints.md Retrieves information about an item class using its ID. ```typescript itemClass(itemClassId: number): Resource ``` -------------------------------- ### Import and Basic Profile Fetch Source: https://github.com/pewtro/blizzard-api/blob/main/_autodocs/api-reference/other-games.md Import the sc2 module and fetch a player's profile using their region, realm, and profile ID. The response is then sent via the client. ```typescript import { sc2 } from '@blizzard-api/sc2'; const profile = sc2.profile(1, 1, 12345); // region, realm, profile ID const response = await client.sendRequest(profile); ``` -------------------------------- ### BlizzardApiClient Constructor Source: https://github.com/pewtro/blizzard-api/blob/main/_autodocs/api-reference/client.md Creates a new BlizzardApiClient instance. Configuration options like client ID, secret, and origin are provided during instantiation. Credentials are not validated until `getAccessToken` is called. ```APIDOC ## BlizzardApiClient Constructor ### Description Creates a new client instance. Credentials are NOT validated at construction time—they are validated when `getAccessToken()` is first called. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **options** (`ClientOptions`) - Required - Configuration object with key, secret, origin, and optional locale ### Request Example ```typescript import { BlizzardApiClient } from '@blizzard-api/client'; const client = new BlizzardApiClient({ key: 'my-client-id', secret: 'my-client-secret', origin: 'us', }); ``` ### Response None ### Throws None ``` -------------------------------- ### Get Item by ID Source: https://github.com/pewtro/blizzard-api/blob/main/_autodocs/api-reference/wow-endpoints.md Retrieves data for a single item using its unique ID. ```typescript item(itemId: number): Resource ``` -------------------------------- ### Classic WoW API Namespaces Source: https://github.com/pewtro/blizzard-api/blob/main/_autodocs/architecture.md Illustrates the different namespaces available for Classic World of Warcraft data, categorized by data type and scope. ```markdown ┌────────────────┬──────────────────────────────────────────┐ │ Namespace │ Purpose │ ├────────────────┼──────────────────────────────────────────┤ │ static │ Unchanging game data (items, spells) │ │ dynamic │ Time-sensitive data (auctions, raids) │ │ profile │ User/character data │ │ static-classic │ Classic WoW static data │ │ dynamic-classic│ Classic WoW dynamic data │ │ profile-classic│ Classic character data │ └────────────────┴──────────────────────────────────────────┘ ``` -------------------------------- ### Get Achievement Media Source: https://github.com/pewtro/blizzard-api/blob/main/_autodocs/api-reference/wow-endpoints.md Retrieves the media (icon) for a specific achievement. No token required. ```typescript achievementMedia(achievementId: number): Resource ``` -------------------------------- ### ClientOptions Interface Source: https://github.com/pewtro/blizzard-api/blob/main/_autodocs/types.md Configuration options for initializing the Blizzard API client. This includes essential credentials, region, locale, and optional existing tokens or custom HTTP client options. ```typescript interface ClientOptions { key: string; secret: string; origin: Origins; locale?: Locales; token?: string; kyOptions?: KyOptions; } ``` -------------------------------- ### Get Achievement Category Index Source: https://github.com/pewtro/blizzard-api/blob/main/_autodocs/api-reference/wow-endpoints.md Retrieves an index of all achievement categories. No token required. ```typescript achievementCategoryIndex(): Resource ``` -------------------------------- ### ClientOptions Source: https://github.com/pewtro/blizzard-api/blob/main/_autodocs/api-reference/client.md Configuration object for client creation and request overrides. This object is used when initializing the Blizzard API client to set up authentication, region, locale, and other request-specific options. ```APIDOC ## ClientOptions ### Description Configuration object for client creation and request overrides. This object is used when initializing the Blizzard API client to set up authentication, region, locale, and other request-specific options. ### Properties #### Properties - **key** (string) - Required - OAuth2 Client ID - **secret** (string) - Required - OAuth2 Client Secret - **origin** (Origins) - Required - API region (us, eu, kr, cn, tw) - **locale** (Locales) - Optional - Language/locale for responses. Defaults to region default. - **token** (string) - Optional - Existing access token to reuse. Defaults to None. - **kyOptions** (KyOptions) - Optional - [ky HTTP client options](https://github.com/sindresorhus/ky#options) (headers, timeout, retry, etc.). Defaults to None. ### Example ```typescript const options: ClientOptions = { key: process.env.CLIENT_ID, secret: process.env.CLIENT_SECRET, origin: 'eu', locale: 'en_GB', kyOptions: { timeout: 30_000, retry: { limit: 3, methods: ['get'], }, }, }; const client = await createBlizzardApiClient(options); ``` ``` -------------------------------- ### Get Creature Type by ID Source: https://github.com/pewtro/blizzard-api/blob/main/_autodocs/api-reference/wow-endpoints.md Fetch information about a specific creature type using its ID. ```typescript creatureType(creatureTypeId: number): Resource ``` -------------------------------- ### Client Package Exports Source: https://github.com/pewtro/blizzard-api/blob/main/_autodocs/architecture.md Factory function and main class for creating and managing the Blizzard API client. ```typescript import { createBlizzardApiClient, BlizzardApiClient } from "@blizzard-api/client"; import { ClientOptions, AccessToken, ValidateAccessTokenResponse } from "@blizzard-api/client"; ``` -------------------------------- ### Get Creature by ID Source: https://github.com/pewtro/blizzard-api/blob/main/_autodocs/api-reference/wow-endpoints.md Fetch detailed information about a specific creature using its unique ID. ```typescript creature(creatureId: number): Resource ``` -------------------------------- ### characterEquipmentSummary Source: https://github.com/pewtro/blizzard-api/blob/main/_autodocs/api-reference/wow-endpoints.md Retrieves a list of currently equipped items on a specific character. Requires realm slug and character name. ```APIDOC ## GET /profile/wow/character/{realmSlug}/{characterName}/equipment ### Description List of currently equipped items on the character. ### Method GET ### Endpoint /profile/wow/character/{realmSlug}/{characterName}/equipment ### Parameters #### Path Parameters - **realmSlug** (string) - Required - The slug of the realm. - **characterName** (string) - Required - The name of the character. ### Response #### Success Response (200) - **equipment** (array) - A list of equipped items. ``` -------------------------------- ### Get Item Set by ID Source: https://github.com/pewtro/blizzard-api/blob/main/_autodocs/api-reference/wow-endpoints.md Retrieves data for a specific item set using its ID. ```typescript itemSet(itemSetId: number): Resource ``` -------------------------------- ### Get Request Configuration Source: https://github.com/pewtro/blizzard-api/blob/main/_autodocs/INDEX.md Generates the configuration object for an HTTP request, including headers and parameters. ```typescript client.getRequestConfig(resource, options?, headers?): RequestConfig ``` -------------------------------- ### Import Classic WoW Response Types Source: https://github.com/pewtro/blizzard-api/blob/main/packages/classic-wow/README.md Import specific response types by appending 'Response' to the type name. ```ts import type { PowerTypeResponse } from '@blizzard-api/classic-wow'; ``` -------------------------------- ### Get Blizzard API Instance Source: https://github.com/pewtro/blizzard-api/blob/main/_autodocs/INDEX.md Retrieves an instance of the Blizzard API for a specified origin and locale. ```typescript getBlizzardApi(origin, locale?): BlizzardApi ``` -------------------------------- ### Create Blizzard API Client and Send Request Source: https://github.com/pewtro/blizzard-api/blob/main/packages/hs/README.md Integrate with '@blizzard-api/client' to create a client and send requests to Hearthstone endpoints, automatically typing the response. ```ts import { createBlizzardApiClient } from '@blizzard-api/client'; import { hs } from '@blizzard-api/hs'; const client = await createBlizzardApiClient({ key: 'environment.blizzardClientId', secret: 'environment.blizzardClientSecret', origin: 'eu', }); //Response will automatically be typed with the appropriate values const response = await client.sendRequest(hs.allMetadata()); console.log(response); ^ typeof AllMetadataResponse ``` -------------------------------- ### Get Creature Display Media Source: https://github.com/pewtro/blizzard-api/blob/main/_autodocs/api-reference/wow-endpoints.md Retrieve the display media information for a creature, identified by its display ID. ```typescript creatureDisplayMedia(creatureDisplayId: number): Resource ```