-
Notifications
You must be signed in to change notification settings - Fork 1
External API Usage
github-actions[bot] edited this page Sep 27, 2025
·
1 revision
DillaPoE2Stat integrates two external services:
- Path of Exile OAuth + Character API for authenticated inventory snapshots.
- poe.ninja economy endpoints for valuing loot.
This page documents the endpoints, required headers, and helper functions that touch the network.
All calls live in poe_api.py. Requests are made with the requests library and use the OAuth 2.0 client credentials grant.
POST https://www.pathofexile.com/oauth/token
Content-Type: application/x-www-form-urlencoded
User-Agent: DillaPoE2Stat/0.1 (+you@example.com)
grant_type=client_credentials
client_id=<CLIENT_ID>
client_secret=<CLIENT_SECRET>
scope=account:characters account:profile
- The response contains
access_tokenandexpires_infields. We print the expiry for visibility. -
Config.CLIENT_IDandConfig.CLIENT_SECRETcome from your Path of Exile developer application.
Each request includes the header Authorization: Bearer <access_token> plus the same user agent.
| Helper | HTTP call | Notes |
|---|---|---|
get_characters(access_token) |
GET https://api.pathofexile.com/character/poe2 |
Returns the character list for the account. |
get_character_details(access_token, name) |
GET https://api.pathofexile.com/character/poe2/<name> |
Uses urllib.parse.quote to safely encode character names. |
snapshot_inventory(access_token, name) |
n/a (wraps get_character_details) |
Extracts the character.inventory array from the JSON response. |
-
PoEStatsTracker.rate_limitenforces theConfig.API_RATE_LIMITgap (default 2.5 seconds) before each snapshot. - All network helpers raise
requests.HTTPErrorif the service returns a non-2xx status. Callers should wrap usage intry/exceptif they need custom error reporting.
Economy data is consumed via price_check_poe2.py. The module normalises item names, caches results, and performs multiple fallbacks to maximise hit rate.
GET https://poe.ninja/poe2/api/economy/temp/overview
Params: leagueName=<league>, overviewName=<category>
Headers: {"User-Agent": "DillaPoE2Stat/0.1 (+you@example.com)", "Accept": "application/json", "Referer": "https://poe.ninja/"}
- The tracker defaults to the league defined in
price_check_poe2.LEAGUE. - Categories are derived from the heuristics in
guess_category_from_itemor iterated viaDEFAULT_PROBEfallback list.
| Helper | Purpose |
|---|---|
_fetch_items_once(overview_name, league) |
Single HTTP call to fetch raw rows for a category. Raises on failure. |
_fetch_items_with_aliases(category_key, league) |
Tries multiple category aliases until a non-empty response is returned. |
fetch_category_prices(category_key, league) |
Cached dictionary of normalised item IDs ➜ chaos values. Seeds “Chaos Orb” with 1.0 in currency view. |
exalted_price(league) |
Convenience wrapper that pulls Exalted Orb pricing from the currency overview. |
-
Manual overrides:
get_value_for_inventory_itemimportsmanual_prices.get_manual_item_price(if present) to support hand-curated valuations. -
Category guess:
guess_category_from_iteminspects frame type, icon path, and name tokens to pick the best poe.ninja category. -
Fallback sweep: If guessing fails,
DEFAULT_PROBEcategories are tested sequentially. -
Value aggregation:
valuate_items_rawgroups items by name, multiplies stack sizes, and returns both chaos and exalt totals. Exalt conversion divides chaos totals by the cached exalted price.
- HTTP responses are cached via
functools.lru_cacheonfetch_category_pricesandexalted_priceto reduce API load. - If a lookup returns
None, caller-side logic (e.g.,DisplayManager) will show the item with-or omit it in normal mode. - Manual price lookups catch and log any import errors so the tracker keeps running even if
manual_prices.pyis absent.
When adding new networked features:
- Reuse the
rate_limitguard before callingpoe_apihelpers. - Provide a descriptive
User-Agentstring (follow Path of Exile API guidelines). - Update
Module Referenceand this page to describe new endpoints or heuristics. - Consider where caching is appropriate to avoid repeated calls mid-session.