Closed Kouzukii closed 1 month ago
Might be missing something - how does this differ from calling the existing current data endpoint with &entries=0
?
The current endpoint only includes information for a single world OR the entire datacenter OR the entire region. That would require 3 separate requests if the user would want to know the price of an item for both their homeworld and a potential server hop destination. Also setting entries=0 and listing=0 does not tell you which world has the cheapest price or most recent purchase.
Which is why currently I make a request to the largest scope, e.g. their Datacenter and then find their homeworld within the response to display both the cheapest listing on their homeworld and the datacenter.
Makes sense, I can see the argument from an API consumer perspective; this makes it a lot more intuitive to do stats efficiently for clients - but if you're able to request a large scope and filter on the result already, how would this improve things for e.g. PriceInsight?
Also setting entries=0 and listings=0 causes averagePrice and saleVelocity to be 0
This sounds like a bug actually, statsWithin
should take precedence for the DB fetch
Also setting entries=0 and listings=0 causes averagePrice and saleVelocity to be 0
This was my mistake, strike that 😅
Wait it's working fine, yeah - it's just because I removed sales from the current data endpoint to debug load issues...
The optimization aim here is not to improve PriceInsight, but rather optimize performance of the Universalis API. Since when only requesting these minimal datapoints you could use more optimized Database queries for aggregation, rather than aggregating the Data within the Universalis Application Server (at least that was the state when I made my last PR which was 2 years ago, things might be different now)
Oh, you'd push the aggregation down to the DB itself - that makes much more sense. Alright, that makes sense to me, no objections from an implementation standpoint either, then.
one thing that might also be worth considering could be adding median
prices (hq, nq)
I've got a few requests that I could replace entirely with the above if all of those values were present
Any ideas for a good name for the API? I'd suggest something like CurrentPrice or AggregatedMarketBoardData
It might be a good idea to make a single api call that can showcase all item stats in a single call instead of requiring multiple calls.
I have something similar in saddlebag:
Any ideas for a good name for the API? I'd suggest something like CurrentPrice or AggregatedMarketBoardData
AggregatedMarketBoardData sounds good, CurrentPrice seems too similar to CurrentlyShown
I believe we can also use fields
for this with some changes in how it's handled.
It can be used to exclude listings
and recentHistory
arrays. It will not require an entirely new API and can still have an optimized query/caching internally.
Here's an example with fields=items.itemID,items.worldID,items.currentAveragePrice,items.regularSaleVelocity,items.stackSizeHistogram
(request URL)
and the response:
{
"items": {
"7": {
"itemID": 7,
"worldID": 39,
"currentAveragePrice": 70.81579,
"regularSaleVelocity": 142.85715,
"stackSizeHistogram": {
"5": 1,
"241": 1,
"400": 1,
"407": 1,
"700": 2,
"1000": 11,
"2000": 6,
"2040": 1,
"2500": 1,
"3550": 4,
"4000": 1,
"4400": 1,
"4440": 1,
"5000": 1,
"5060": 1,
"5950": 1,
"5999": 1,
"6240": 1,
"9480": 1
}
},
"8": {
"itemID": 8,
"worldID": 39,
"currentAveragePrice": 153038.14,
"regularSaleVelocity": 571.4286,
"stackSizeHistogram": {
"1": 7,
"100": 4,
"112": 1,
"311": 1,
"400": 1,
"500": 3,
"621": 1,
"1000": 4,
"1440": 1,
"1500": 1,
"2000": 7,
"2500": 1,
"2865": 1,
"2880": 1,
"3000": 4,
"3018": 1,
"3600": 1,
"4000": 1,
"4380": 1,
"4669": 1,
"5000": 1,
"5210": 1,
"9000": 3
}
}
}
}
We can make this more client-friendly with macro expansion, e.g. instead of the above fields=...
the client would requests fields=@stats
and the API would automatically expand it into the proper fields depending on the context.
In order to alleviate universalis server congestion we could employ a more optimized API for tools that are simply interested in the current price rather than a history of recorded prices, which is what is currently provided by the "Market board current data" API.
An example request and response could looks like:
29685,33673
40
orchaos
oreurope
world
,datacenter
,region
worldDcRegion
contains info on it.recentPurchase
,minListing
,medianListing
,averageSalePrice
,dailySaleVelocity
Response:
Fields and Scopes are only included when requested by the client.