blizzardapi3 3.0.2__tar.gz → 3.0.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {blizzardapi3-3.0.2 → blizzardapi3-3.0.3}/PKG-INFO +150 -6
- {blizzardapi3-3.0.2 → blizzardapi3-3.0.3}/README.md +149 -5
- {blizzardapi3-3.0.2 → blizzardapi3-3.0.3}/blizzardapi3/__init__.py +2 -0
- blizzardapi3-3.0.3/blizzardapi3/api/__init__.py +8 -0
- blizzardapi3-3.0.3/blizzardapi3/api/d3.py +76 -0
- blizzardapi3-3.0.3/blizzardapi3/api/d3.pyi +542 -0
- blizzardapi3-3.0.3/blizzardapi3/api/hs.py +49 -0
- blizzardapi3-3.0.3/blizzardapi3/api/hs.pyi +170 -0
- blizzardapi3-3.0.3/blizzardapi3/api/sc2.py +76 -0
- blizzardapi3-3.0.3/blizzardapi3/api/sc2.pyi +354 -0
- blizzardapi3-3.0.3/blizzardapi3/api/wow.pyi +4242 -0
- {blizzardapi3-3.0.2 → blizzardapi3-3.0.3}/blizzardapi3/blizzard_api.py +4 -1
- blizzardapi3-3.0.3/blizzardapi3/blizzard_api.pyi +29 -0
- {blizzardapi3-3.0.2 → blizzardapi3-3.0.3}/blizzardapi3/core/executor.py +40 -6
- {blizzardapi3-3.0.2 → blizzardapi3-3.0.3}/blizzardapi3/core/factory.py +3 -3
- {blizzardapi3-3.0.2 → blizzardapi3-3.0.3}/blizzardapi3.egg-info/PKG-INFO +150 -6
- {blizzardapi3-3.0.2 → blizzardapi3-3.0.3}/blizzardapi3.egg-info/SOURCES.txt +8 -0
- {blizzardapi3-3.0.2 → blizzardapi3-3.0.3}/pyproject.toml +1 -1
- blizzardapi3-3.0.2/blizzardapi3/api/__init__.py +0 -5
- {blizzardapi3-3.0.2 → blizzardapi3-3.0.3}/blizzardapi3/api/wow.py +0 -0
- {blizzardapi3-3.0.2 → blizzardapi3-3.0.3}/blizzardapi3/config/endpoints/d3_community.yaml +0 -0
- {blizzardapi3-3.0.2 → blizzardapi3-3.0.3}/blizzardapi3/config/endpoints/d3_game_data.yaml +0 -0
- {blizzardapi3-3.0.2 → blizzardapi3-3.0.3}/blizzardapi3/config/endpoints/hs_game_data.yaml +0 -0
- {blizzardapi3-3.0.2 → blizzardapi3-3.0.3}/blizzardapi3/config/endpoints/sc2_community.yaml +0 -0
- {blizzardapi3-3.0.2 → blizzardapi3-3.0.3}/blizzardapi3/config/endpoints/sc2_game_data.yaml +0 -0
- {blizzardapi3-3.0.2 → blizzardapi3-3.0.3}/blizzardapi3/config/endpoints/wow_game_data.yaml +0 -0
- {blizzardapi3-3.0.2 → blizzardapi3-3.0.3}/blizzardapi3/config/endpoints/wow_profile.yaml +0 -0
- {blizzardapi3-3.0.2 → blizzardapi3-3.0.3}/blizzardapi3/core/__init__.py +0 -0
- {blizzardapi3-3.0.2 → blizzardapi3-3.0.3}/blizzardapi3/core/auth.py +0 -0
- {blizzardapi3-3.0.2 → blizzardapi3-3.0.3}/blizzardapi3/core/client.py +0 -0
- {blizzardapi3-3.0.2 → blizzardapi3-3.0.3}/blizzardapi3/core/context.py +0 -0
- {blizzardapi3-3.0.2 → blizzardapi3-3.0.3}/blizzardapi3/core/registry.py +0 -0
- {blizzardapi3-3.0.2 → blizzardapi3-3.0.3}/blizzardapi3/exceptions/__init__.py +0 -0
- {blizzardapi3-3.0.2 → blizzardapi3-3.0.3}/blizzardapi3/exceptions/auth.py +0 -0
- {blizzardapi3-3.0.2 → blizzardapi3-3.0.3}/blizzardapi3/exceptions/base.py +0 -0
- {blizzardapi3-3.0.2 → blizzardapi3-3.0.3}/blizzardapi3/exceptions/request.py +0 -0
- {blizzardapi3-3.0.2 → blizzardapi3-3.0.3}/blizzardapi3/exceptions/validation.py +0 -0
- {blizzardapi3-3.0.2 → blizzardapi3-3.0.3}/blizzardapi3/types.py +0 -0
- {blizzardapi3-3.0.2 → blizzardapi3-3.0.3}/blizzardapi3.egg-info/dependency_links.txt +0 -0
- {blizzardapi3-3.0.2 → blizzardapi3-3.0.3}/blizzardapi3.egg-info/requires.txt +0 -0
- {blizzardapi3-3.0.2 → blizzardapi3-3.0.3}/blizzardapi3.egg-info/top_level.txt +0 -0
- {blizzardapi3-3.0.2 → blizzardapi3-3.0.3}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: blizzardapi3
|
|
3
|
-
Version: 3.0.
|
|
3
|
+
Version: 3.0.3
|
|
4
4
|
Summary: A modern, config-driven Python wrapper for the Blizzard API with async support
|
|
5
5
|
Author-email: lostcol0ny <c098os0k@4wrd.cc>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -40,6 +40,7 @@ A modern, config-driven Python wrapper for the Blizzard API with full async supp
|
|
|
40
40
|
- [Features](#features)
|
|
41
41
|
- [Installation](#installation)
|
|
42
42
|
- [Quick Start](#quick-start)
|
|
43
|
+
- [Accessing Response Headers](#accessing-response-headers)
|
|
43
44
|
- [Using Search Endpoints](#using-search-endpoints)
|
|
44
45
|
- [Error Handling](#error-handling)
|
|
45
46
|
- [Comprehensive Examples](#comprehensive-examples)
|
|
@@ -55,6 +56,7 @@ A modern, config-driven Python wrapper for the Blizzard API with full async supp
|
|
|
55
56
|
- 📝 **Config-Driven** - YAML-defined endpoints, easy to extend
|
|
56
57
|
- 🎯 **Better Errors** - Specific exception types with detailed context
|
|
57
58
|
- ⚡ **Efficient** - Single session management, proper resource cleanup
|
|
59
|
+
- 📊 **Response Headers** - Access HTTP headers for caching, rate limits, and metadata
|
|
58
60
|
- 🎮 **Complete Coverage** - Supports WoW, Diablo 3, Hearthstone, and StarCraft 2
|
|
59
61
|
|
|
60
62
|
## Installation
|
|
@@ -100,6 +102,43 @@ async def main():
|
|
|
100
102
|
asyncio.run(main())
|
|
101
103
|
```
|
|
102
104
|
|
|
105
|
+
## Accessing Response Headers
|
|
106
|
+
|
|
107
|
+
All API responses include HTTP headers that provide useful metadata. The response object behaves like a dict for data access while also exposing headers:
|
|
108
|
+
|
|
109
|
+
```python
|
|
110
|
+
from blizzardapi3 import BlizzardAPI
|
|
111
|
+
|
|
112
|
+
with BlizzardAPI(client_id, client_secret) as api:
|
|
113
|
+
result = api.wow.game_data.get_achievement(
|
|
114
|
+
region="us",
|
|
115
|
+
locale="en_US",
|
|
116
|
+
achievement_id=6
|
|
117
|
+
)
|
|
118
|
+
|
|
119
|
+
# Access data (unchanged - full backwards compatibility)
|
|
120
|
+
print(result["name"])
|
|
121
|
+
print(result.get("points"))
|
|
122
|
+
|
|
123
|
+
# Access response headers
|
|
124
|
+
print(result.headers.get("Last-Modified"))
|
|
125
|
+
print(result.headers.get("Cache-Control"))
|
|
126
|
+
print(result.status_code)
|
|
127
|
+
|
|
128
|
+
# List all headers
|
|
129
|
+
for name, value in result.headers.items():
|
|
130
|
+
print(f"{name}: {value}")
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### Useful Headers
|
|
134
|
+
|
|
135
|
+
| Header | Description |
|
|
136
|
+
|--------|-------------|
|
|
137
|
+
| `Last-Modified` | When the data was last updated by Blizzard |
|
|
138
|
+
| `Cache-Control` | Caching policy (e.g., `max-age=86400` = 24 hours) |
|
|
139
|
+
| `Battlenet-Namespace` | The namespace/version of the data |
|
|
140
|
+
| `blizzard-token-expires` | When the OAuth token expires |
|
|
141
|
+
|
|
103
142
|
## Using Search Endpoints
|
|
104
143
|
|
|
105
144
|
BlizzardAPI v3 provides powerful search functionality for various game resources. Search methods accept flexible keyword arguments for filtering and pagination.
|
|
@@ -363,16 +402,108 @@ with BlizzardAPI(client_id, client_secret) as api:
|
|
|
363
402
|
print(f"{char['name']} - Level {char['level']} {char.get('playable_class', {}).get('name', 'Unknown')}")
|
|
364
403
|
```
|
|
365
404
|
|
|
405
|
+
### Diablo 3 Examples
|
|
406
|
+
|
|
407
|
+
```python
|
|
408
|
+
from blizzardapi3 import BlizzardAPI, Region, Locale
|
|
409
|
+
|
|
410
|
+
with BlizzardAPI(client_id, client_secret) as api:
|
|
411
|
+
# Get D3 season index
|
|
412
|
+
seasons = api.d3.game_data.get_season_index(
|
|
413
|
+
region=Region.US,
|
|
414
|
+
locale=Locale.EN_US
|
|
415
|
+
)
|
|
416
|
+
print(f"Current season: {seasons['current_season']}")
|
|
417
|
+
|
|
418
|
+
# Get a player's career profile
|
|
419
|
+
profile = api.d3.community.get_career(
|
|
420
|
+
region=Region.US,
|
|
421
|
+
locale=Locale.EN_US,
|
|
422
|
+
battle_tag="BattleTag-1234"
|
|
423
|
+
)
|
|
424
|
+
print(f"Paragon level: {profile['paragonLevel']}")
|
|
425
|
+
|
|
426
|
+
# Get item type index
|
|
427
|
+
item_types = api.d3.game_data.get_item_type_index(
|
|
428
|
+
region=Region.US,
|
|
429
|
+
locale=Locale.EN_US
|
|
430
|
+
)
|
|
431
|
+
```
|
|
432
|
+
|
|
433
|
+
### Hearthstone Examples
|
|
434
|
+
|
|
435
|
+
```python
|
|
436
|
+
from blizzardapi3 import BlizzardAPI, Region, Locale
|
|
437
|
+
|
|
438
|
+
with BlizzardAPI(client_id, client_secret) as api:
|
|
439
|
+
# Search for cards
|
|
440
|
+
cards = api.hearthstone.game_data.search_cards(
|
|
441
|
+
region=Region.US,
|
|
442
|
+
locale=Locale.EN_US,
|
|
443
|
+
**{"class": "mage", "manaCost": 3}
|
|
444
|
+
)
|
|
445
|
+
for card in cards['cards'][:5]:
|
|
446
|
+
print(f"{card['name']} - {card['manaCost']} mana")
|
|
447
|
+
|
|
448
|
+
# Get card backs
|
|
449
|
+
card_backs = api.hearthstone.game_data.search_card_backs(
|
|
450
|
+
region=Region.US,
|
|
451
|
+
locale=Locale.EN_US
|
|
452
|
+
)
|
|
453
|
+
|
|
454
|
+
# Get metadata
|
|
455
|
+
metadata = api.hearthstone.game_data.get_metadata(
|
|
456
|
+
region=Region.US,
|
|
457
|
+
locale=Locale.EN_US
|
|
458
|
+
)
|
|
459
|
+
```
|
|
460
|
+
|
|
461
|
+
### StarCraft 2 Examples
|
|
462
|
+
|
|
463
|
+
```python
|
|
464
|
+
from blizzardapi3 import BlizzardAPI, Region, Locale
|
|
465
|
+
|
|
466
|
+
with BlizzardAPI(client_id, client_secret) as api:
|
|
467
|
+
# Get league data
|
|
468
|
+
league = api.sc2.game_data.get_league_data(
|
|
469
|
+
region=Region.US,
|
|
470
|
+
locale=Locale.EN_US,
|
|
471
|
+
season_id=44,
|
|
472
|
+
queue_id=201,
|
|
473
|
+
team_type="0",
|
|
474
|
+
league_id=6
|
|
475
|
+
)
|
|
476
|
+
|
|
477
|
+
# Get static profile data
|
|
478
|
+
static = api.sc2.community.get_static_profile(
|
|
479
|
+
region=Region.US,
|
|
480
|
+
locale=Locale.EN_US,
|
|
481
|
+
region_id=1
|
|
482
|
+
)
|
|
483
|
+
|
|
484
|
+
# Get grandmaster leaderboard
|
|
485
|
+
gm_ladder = api.sc2.community.get_grandmaster_leaderboard(
|
|
486
|
+
region=Region.US,
|
|
487
|
+
locale=Locale.EN_US,
|
|
488
|
+
region_id=1
|
|
489
|
+
)
|
|
490
|
+
```
|
|
491
|
+
|
|
366
492
|
## Supported Games
|
|
367
493
|
|
|
368
|
-
- **World of Warcraft** - Game Data & Profile APIs (
|
|
494
|
+
- **World of Warcraft** - Game Data & Profile APIs (~290 endpoints)
|
|
369
495
|
- Game Data: Achievements, Items, Mounts, Pets, Auctions, Housing/Decor, and more
|
|
370
496
|
- Profile: Characters, Guilds, Mythic+, PvP, Collections, Equipment
|
|
371
|
-
- **Diablo 3** - Community & Game Data APIs (
|
|
372
|
-
-
|
|
373
|
-
-
|
|
497
|
+
- **Diablo 3** - Community & Game Data APIs (39 endpoints)
|
|
498
|
+
- Game Data: Items, item types, seasons, eras
|
|
499
|
+
- Community: Career profiles, heroes, items, followers
|
|
500
|
+
- **Hearthstone** - Game Data API (12 endpoints)
|
|
501
|
+
- Cards, card backs, decks, metadata search
|
|
502
|
+
- **StarCraft 2** - Community & Game Data APIs (22 endpoints)
|
|
503
|
+
- Game Data: League data
|
|
504
|
+
- Community: Profiles, ladders, grandmaster leaderboards
|
|
374
505
|
|
|
375
|
-
**Total:
|
|
506
|
+
**Total: 363 endpoints** (726 methods including async variants)
|
|
376
507
|
|
|
377
508
|
## Documentation
|
|
378
509
|
|
|
@@ -404,8 +535,21 @@ pytest
|
|
|
404
535
|
# Format code
|
|
405
536
|
black .
|
|
406
537
|
ruff check .
|
|
538
|
+
|
|
539
|
+
# Regenerate stub files for IDE autocomplete (after modifying YAML configs)
|
|
540
|
+
python scripts/generate_stubs.py
|
|
407
541
|
```
|
|
408
542
|
|
|
543
|
+
### IDE Autocomplete
|
|
544
|
+
|
|
545
|
+
BlizzardAPI uses `.pyi` stub files to provide full IDE autocomplete for all dynamically generated API methods. If you modify the YAML endpoint configurations, run the stub generator to update the type hints:
|
|
546
|
+
|
|
547
|
+
```bash
|
|
548
|
+
python scripts/generate_stubs.py
|
|
549
|
+
```
|
|
550
|
+
|
|
551
|
+
This generates stub files in `blizzardapi3/api/` for each game API.
|
|
552
|
+
|
|
409
553
|
## Architecture
|
|
410
554
|
|
|
411
555
|
BlizzardAPI v3 uses a config-driven architecture:
|
|
@@ -7,6 +7,7 @@ A modern, config-driven Python wrapper for the Blizzard API with full async supp
|
|
|
7
7
|
- [Features](#features)
|
|
8
8
|
- [Installation](#installation)
|
|
9
9
|
- [Quick Start](#quick-start)
|
|
10
|
+
- [Accessing Response Headers](#accessing-response-headers)
|
|
10
11
|
- [Using Search Endpoints](#using-search-endpoints)
|
|
11
12
|
- [Error Handling](#error-handling)
|
|
12
13
|
- [Comprehensive Examples](#comprehensive-examples)
|
|
@@ -22,6 +23,7 @@ A modern, config-driven Python wrapper for the Blizzard API with full async supp
|
|
|
22
23
|
- 📝 **Config-Driven** - YAML-defined endpoints, easy to extend
|
|
23
24
|
- 🎯 **Better Errors** - Specific exception types with detailed context
|
|
24
25
|
- ⚡ **Efficient** - Single session management, proper resource cleanup
|
|
26
|
+
- 📊 **Response Headers** - Access HTTP headers for caching, rate limits, and metadata
|
|
25
27
|
- 🎮 **Complete Coverage** - Supports WoW, Diablo 3, Hearthstone, and StarCraft 2
|
|
26
28
|
|
|
27
29
|
## Installation
|
|
@@ -67,6 +69,43 @@ async def main():
|
|
|
67
69
|
asyncio.run(main())
|
|
68
70
|
```
|
|
69
71
|
|
|
72
|
+
## Accessing Response Headers
|
|
73
|
+
|
|
74
|
+
All API responses include HTTP headers that provide useful metadata. The response object behaves like a dict for data access while also exposing headers:
|
|
75
|
+
|
|
76
|
+
```python
|
|
77
|
+
from blizzardapi3 import BlizzardAPI
|
|
78
|
+
|
|
79
|
+
with BlizzardAPI(client_id, client_secret) as api:
|
|
80
|
+
result = api.wow.game_data.get_achievement(
|
|
81
|
+
region="us",
|
|
82
|
+
locale="en_US",
|
|
83
|
+
achievement_id=6
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
# Access data (unchanged - full backwards compatibility)
|
|
87
|
+
print(result["name"])
|
|
88
|
+
print(result.get("points"))
|
|
89
|
+
|
|
90
|
+
# Access response headers
|
|
91
|
+
print(result.headers.get("Last-Modified"))
|
|
92
|
+
print(result.headers.get("Cache-Control"))
|
|
93
|
+
print(result.status_code)
|
|
94
|
+
|
|
95
|
+
# List all headers
|
|
96
|
+
for name, value in result.headers.items():
|
|
97
|
+
print(f"{name}: {value}")
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### Useful Headers
|
|
101
|
+
|
|
102
|
+
| Header | Description |
|
|
103
|
+
|--------|-------------|
|
|
104
|
+
| `Last-Modified` | When the data was last updated by Blizzard |
|
|
105
|
+
| `Cache-Control` | Caching policy (e.g., `max-age=86400` = 24 hours) |
|
|
106
|
+
| `Battlenet-Namespace` | The namespace/version of the data |
|
|
107
|
+
| `blizzard-token-expires` | When the OAuth token expires |
|
|
108
|
+
|
|
70
109
|
## Using Search Endpoints
|
|
71
110
|
|
|
72
111
|
BlizzardAPI v3 provides powerful search functionality for various game resources. Search methods accept flexible keyword arguments for filtering and pagination.
|
|
@@ -330,16 +369,108 @@ with BlizzardAPI(client_id, client_secret) as api:
|
|
|
330
369
|
print(f"{char['name']} - Level {char['level']} {char.get('playable_class', {}).get('name', 'Unknown')}")
|
|
331
370
|
```
|
|
332
371
|
|
|
372
|
+
### Diablo 3 Examples
|
|
373
|
+
|
|
374
|
+
```python
|
|
375
|
+
from blizzardapi3 import BlizzardAPI, Region, Locale
|
|
376
|
+
|
|
377
|
+
with BlizzardAPI(client_id, client_secret) as api:
|
|
378
|
+
# Get D3 season index
|
|
379
|
+
seasons = api.d3.game_data.get_season_index(
|
|
380
|
+
region=Region.US,
|
|
381
|
+
locale=Locale.EN_US
|
|
382
|
+
)
|
|
383
|
+
print(f"Current season: {seasons['current_season']}")
|
|
384
|
+
|
|
385
|
+
# Get a player's career profile
|
|
386
|
+
profile = api.d3.community.get_career(
|
|
387
|
+
region=Region.US,
|
|
388
|
+
locale=Locale.EN_US,
|
|
389
|
+
battle_tag="BattleTag-1234"
|
|
390
|
+
)
|
|
391
|
+
print(f"Paragon level: {profile['paragonLevel']}")
|
|
392
|
+
|
|
393
|
+
# Get item type index
|
|
394
|
+
item_types = api.d3.game_data.get_item_type_index(
|
|
395
|
+
region=Region.US,
|
|
396
|
+
locale=Locale.EN_US
|
|
397
|
+
)
|
|
398
|
+
```
|
|
399
|
+
|
|
400
|
+
### Hearthstone Examples
|
|
401
|
+
|
|
402
|
+
```python
|
|
403
|
+
from blizzardapi3 import BlizzardAPI, Region, Locale
|
|
404
|
+
|
|
405
|
+
with BlizzardAPI(client_id, client_secret) as api:
|
|
406
|
+
# Search for cards
|
|
407
|
+
cards = api.hearthstone.game_data.search_cards(
|
|
408
|
+
region=Region.US,
|
|
409
|
+
locale=Locale.EN_US,
|
|
410
|
+
**{"class": "mage", "manaCost": 3}
|
|
411
|
+
)
|
|
412
|
+
for card in cards['cards'][:5]:
|
|
413
|
+
print(f"{card['name']} - {card['manaCost']} mana")
|
|
414
|
+
|
|
415
|
+
# Get card backs
|
|
416
|
+
card_backs = api.hearthstone.game_data.search_card_backs(
|
|
417
|
+
region=Region.US,
|
|
418
|
+
locale=Locale.EN_US
|
|
419
|
+
)
|
|
420
|
+
|
|
421
|
+
# Get metadata
|
|
422
|
+
metadata = api.hearthstone.game_data.get_metadata(
|
|
423
|
+
region=Region.US,
|
|
424
|
+
locale=Locale.EN_US
|
|
425
|
+
)
|
|
426
|
+
```
|
|
427
|
+
|
|
428
|
+
### StarCraft 2 Examples
|
|
429
|
+
|
|
430
|
+
```python
|
|
431
|
+
from blizzardapi3 import BlizzardAPI, Region, Locale
|
|
432
|
+
|
|
433
|
+
with BlizzardAPI(client_id, client_secret) as api:
|
|
434
|
+
# Get league data
|
|
435
|
+
league = api.sc2.game_data.get_league_data(
|
|
436
|
+
region=Region.US,
|
|
437
|
+
locale=Locale.EN_US,
|
|
438
|
+
season_id=44,
|
|
439
|
+
queue_id=201,
|
|
440
|
+
team_type="0",
|
|
441
|
+
league_id=6
|
|
442
|
+
)
|
|
443
|
+
|
|
444
|
+
# Get static profile data
|
|
445
|
+
static = api.sc2.community.get_static_profile(
|
|
446
|
+
region=Region.US,
|
|
447
|
+
locale=Locale.EN_US,
|
|
448
|
+
region_id=1
|
|
449
|
+
)
|
|
450
|
+
|
|
451
|
+
# Get grandmaster leaderboard
|
|
452
|
+
gm_ladder = api.sc2.community.get_grandmaster_leaderboard(
|
|
453
|
+
region=Region.US,
|
|
454
|
+
locale=Locale.EN_US,
|
|
455
|
+
region_id=1
|
|
456
|
+
)
|
|
457
|
+
```
|
|
458
|
+
|
|
333
459
|
## Supported Games
|
|
334
460
|
|
|
335
|
-
- **World of Warcraft** - Game Data & Profile APIs (
|
|
461
|
+
- **World of Warcraft** - Game Data & Profile APIs (~290 endpoints)
|
|
336
462
|
- Game Data: Achievements, Items, Mounts, Pets, Auctions, Housing/Decor, and more
|
|
337
463
|
- Profile: Characters, Guilds, Mythic+, PvP, Collections, Equipment
|
|
338
|
-
- **Diablo 3** - Community & Game Data APIs (
|
|
339
|
-
-
|
|
340
|
-
-
|
|
464
|
+
- **Diablo 3** - Community & Game Data APIs (39 endpoints)
|
|
465
|
+
- Game Data: Items, item types, seasons, eras
|
|
466
|
+
- Community: Career profiles, heroes, items, followers
|
|
467
|
+
- **Hearthstone** - Game Data API (12 endpoints)
|
|
468
|
+
- Cards, card backs, decks, metadata search
|
|
469
|
+
- **StarCraft 2** - Community & Game Data APIs (22 endpoints)
|
|
470
|
+
- Game Data: League data
|
|
471
|
+
- Community: Profiles, ladders, grandmaster leaderboards
|
|
341
472
|
|
|
342
|
-
**Total:
|
|
473
|
+
**Total: 363 endpoints** (726 methods including async variants)
|
|
343
474
|
|
|
344
475
|
## Documentation
|
|
345
476
|
|
|
@@ -371,8 +502,21 @@ pytest
|
|
|
371
502
|
# Format code
|
|
372
503
|
black .
|
|
373
504
|
ruff check .
|
|
505
|
+
|
|
506
|
+
# Regenerate stub files for IDE autocomplete (after modifying YAML configs)
|
|
507
|
+
python scripts/generate_stubs.py
|
|
374
508
|
```
|
|
375
509
|
|
|
510
|
+
### IDE Autocomplete
|
|
511
|
+
|
|
512
|
+
BlizzardAPI uses `.pyi` stub files to provide full IDE autocomplete for all dynamically generated API methods. If you modify the YAML endpoint configurations, run the stub generator to update the type hints:
|
|
513
|
+
|
|
514
|
+
```bash
|
|
515
|
+
python scripts/generate_stubs.py
|
|
516
|
+
```
|
|
517
|
+
|
|
518
|
+
This generates stub files in `blizzardapi3/api/` for each game API.
|
|
519
|
+
|
|
376
520
|
## Architecture
|
|
377
521
|
|
|
378
522
|
BlizzardAPI v3 uses a config-driven architecture:
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"""Diablo 3 API facade."""
|
|
2
|
+
|
|
3
|
+
from ..core import BaseClient, EndpointRegistry, MethodFactory, RequestExecutor
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class D3GameDataAPI:
|
|
7
|
+
"""Diablo 3 Game Data API with dynamically generated methods."""
|
|
8
|
+
|
|
9
|
+
def __init__(self, client: BaseClient, executor: RequestExecutor, registry: EndpointRegistry):
|
|
10
|
+
"""Initialize Diablo 3 Game Data API.
|
|
11
|
+
|
|
12
|
+
Args:
|
|
13
|
+
client: Base client for session management
|
|
14
|
+
executor: Request executor
|
|
15
|
+
registry: Endpoint registry
|
|
16
|
+
"""
|
|
17
|
+
self.client = client
|
|
18
|
+
self.executor = executor
|
|
19
|
+
self.registry = registry
|
|
20
|
+
|
|
21
|
+
# Generate and attach all methods
|
|
22
|
+
factory = MethodFactory(executor, registry)
|
|
23
|
+
methods = factory.generate_all_methods("d3", "game_data")
|
|
24
|
+
|
|
25
|
+
for method_name, (sync_method, async_method) in methods.items():
|
|
26
|
+
# Bind methods to this instance
|
|
27
|
+
setattr(self, method_name, sync_method.__get__(self, type(self)))
|
|
28
|
+
setattr(self, f"{method_name}_async", async_method.__get__(self, type(self)))
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class D3CommunityAPI:
|
|
32
|
+
"""Diablo 3 Community API with dynamically generated methods."""
|
|
33
|
+
|
|
34
|
+
def __init__(self, client: BaseClient, executor: RequestExecutor, registry: EndpointRegistry):
|
|
35
|
+
"""Initialize Diablo 3 Community API.
|
|
36
|
+
|
|
37
|
+
Args:
|
|
38
|
+
client: Base client for session management
|
|
39
|
+
executor: Request executor
|
|
40
|
+
registry: Endpoint registry
|
|
41
|
+
"""
|
|
42
|
+
self.client = client
|
|
43
|
+
self.executor = executor
|
|
44
|
+
self.registry = registry
|
|
45
|
+
|
|
46
|
+
# Generate and attach all methods
|
|
47
|
+
factory = MethodFactory(executor, registry)
|
|
48
|
+
methods = factory.generate_all_methods("d3", "community")
|
|
49
|
+
|
|
50
|
+
for method_name, (sync_method, async_method) in methods.items():
|
|
51
|
+
# Bind methods to this instance
|
|
52
|
+
setattr(self, method_name, sync_method.__get__(self, type(self)))
|
|
53
|
+
setattr(self, f"{method_name}_async", async_method.__get__(self, type(self)))
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
class D3API:
|
|
57
|
+
"""Diablo 3 API facade.
|
|
58
|
+
|
|
59
|
+
Provides access to:
|
|
60
|
+
- game_data: Diablo 3 Game Data API (items, item types, recipes, etc.)
|
|
61
|
+
- community: Diablo 3 Community API (profiles, heroes, etc.)
|
|
62
|
+
"""
|
|
63
|
+
|
|
64
|
+
def __init__(self, client: BaseClient, registry: EndpointRegistry):
|
|
65
|
+
"""Initialize Diablo 3 API.
|
|
66
|
+
|
|
67
|
+
Args:
|
|
68
|
+
client: Base client for session management
|
|
69
|
+
registry: Endpoint registry
|
|
70
|
+
"""
|
|
71
|
+
self.client = client
|
|
72
|
+
executor = RequestExecutor(client.token_manager)
|
|
73
|
+
|
|
74
|
+
# Initialize sub-APIs
|
|
75
|
+
self.game_data = D3GameDataAPI(client, executor, registry)
|
|
76
|
+
self.community = D3CommunityAPI(client, executor, registry)
|