Developer guide
Guide on how to use AA Eveprices from your own alliance auth applications.
Application hook
When possible you should declare in your application a PricesToPreloadListHook.
This hook will be used by AA Eveprices to know a list of prices you want to have available and updated regularly.
The type ids listed in this hook will be added to the regular update cycle.
- class PricesToPreloadListHook(type_ids: Iterable[int])
A hook for your application to declare the type ids you will be working with. The price of these type ids will be updated automatically at regular intervals.
- __init__(type_ids: Iterable[int]) None
from allianceauth import hooks
from eveprices.hooks import PricesToPreloadListHook
@hooks.register("price_preload_hook")
def register_price_preload_list():
return PricesToPreloadListHook([35, 36, 37])
Note
It is prefered that you use a hook to define prices that need to be updated in order to do a single bulk price update. This ease the load of the price providers compared to doing dozens (if not thousands) of requests for a single item each.
Query prices
In order to query prices from the database you can use the methods that are linked to the TypePrice manager:
from eveprices.models import TypePrice
TRITANIUM_TYPE_ID = 34
tritanium_price = TypePrice.objects.get_type_price_immediate(TRITANIUM_TYPE_ID)
- class PriceInformation(type_id: int, buy_price: float, split_price: float | None, sell_price: float)
Returned price from a provider
Models.
- class TypePrice(*args, **kwargs)
Last known price of an eve model
- exception DoesNotExist
- exception MultipleObjectsReturned
- get_price_by_kind(price_kind: PriceKindEnum) float
Get the price associated to the correct kind
- class TypePriceManager(*args, **kwargs)
Manager for the TypePrice class
- bulk_update_from_price_info(price_info_list: list[PriceInformation])
Bulk update prices from the given price information list
- get_or_update_price(type_id: int, price_kind: PriceKindEnum | None = None, max_hours: int = 24) tuple[float, bool]
Return the price of a given type. If the type price hasn’t been updated in at least max_hours it will be updated before returning
- get_or_update_type_price(type_id: int, max_hours: int = 24) tuple[TypePrice, bool]
Return the TypePrice for the given type_id. If the TypePrice hasn’t been updated in at least max_hours it will be updated before returning Bool value in the return is set to true if an update was triggered
- get_price_immediate(type_id: int, price_kind: PriceKindEnum | None = None) float
Get the price of an item from the db. Only contacts a provider if the price isn’t in the database.
This method is the preferred method for ids that are part of your application known types.
- get_type_price_immediate(type_id: int) TypePrice
Return the TypePrice from database without checking timestamp
- update_or_create_from_price_info(price_info: PriceInformation)
Update a TypePrice with the given type information
When working on data loaded through your PricesToPreloadListHook you can use the methods with immediate in their definition.
These methods won’t check when the type price was last updated and query the database value immediatly.
If you need the price of a type not sourced through a PricesToPreloadListHook you can use other methods.
They will check when the price was last updated, and you can choose what’s the maximum time before you want them updated.