Item market purchases have inconsistent shapes
-
Thread created on 19:00:37 - 01/05/24 (1 year ago)|Last replied 05:22:45 - 06/05/24 (1 year ago)Hi,
Apologies if I have missed a discussion or notification of this I did look but I couldn't find anything.
I'm working on a utility that utilises the Torn API. I'm using the following URL to fetch all Item Market buys:
https://api.torn.com/user/?selections=log&log=1103&key=XXX
Upon parsing the response, I saw I had some missing data and on looking into it further this is due to the `.data` being an inconsistent shape. It's either an object containing a child array containing a single element OR just a single object containing the relevant data.
I can't think of or see any reason why this happens, and I'm more than happy to admit that I may've missed an announcement or post about this. I've worked around it but just wanted to see if this is intentional or not - however having a consistent shape would be the norm.
Thank you. -
-
Posted on 19:04:40 - 01/05/24 (1 year ago)Post link copied to clipboard Copy post linkWelcome to the Torn API. Enjoy adding value and type checks to everything.
-
-
Posted on 19:04:45 - 01/05/24 (1 year ago)Post link copied to clipboard Copy post linkYou should probably have this moved or repost in B&I. Posts here get rarely checked by staff, if at all.
-
-
Posted on 19:08:35 - 01/05/24 (1 year ago)Post link copied to clipboard Copy post linkI've quickly come accustomed to not taking it for granted that things will be as I'm used to, so yeah type checks are a must however I wasn't expecting to have to check if a property is an array or not.
I did think about posting this into B&I however it seemed more fitting for here. I'll leave it for today and move it tomorrow if there's still no response. -
-
Posted on 05:22:45 - 06/05/24 (1 year ago)Post link copied to clipboard Copy post linkThere was already a response from Ched. It's to be expected under the current market system but may change with the upcoming one.
https://www.torn.com/forums.php#/p=threads&f=19&t=16396720&b=0&a=0 -