Item market purchases have inconsistent shapes | API Developme…

Item market purchases have inconsistent shapes

    • Azathoth [1677351]
    • Role: Wiki Contributor
    • Level: 70
    • Posts: 166
    • Karma: 353
    • Last Action: Now
      • 0
    • Reason:
      Are you sure you want to report this post to staff?
      Cancel
    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.
    • tiksan [2383326]
    • Role: Civilian
    • Level: 100
    • Posts: 1,011
    • Karma: 1,338
    • Last Action: 14 minutes
      • 0
    • Reason:
      Are you sure you want to report this post to staff?
      Cancel
    Posted on 19:04:40 - 01/05/24 (1 year ago)
    Post link copied to clipboard Copy post link
    Welcome to the Torn API. Enjoy adding value and type checks to everything.

    https://cdn.discordapp.com/attachments/719011659561173012/1237732490513481809/Sith_Larping_Asshats.gif?ex=678f8935&is=678e37b5&hm=6d9a2ed93994782d9020538e0ec71a3d072964d584aceb09e9e6f547752d41e0&

    • DeKleineKobini [2114440]
    • Role: Committee
    • Level: 100
    • Posts: 3,943
    • Karma: 5,549
    • Last Action: 5 minutes
      • 0
    • Reason:
      Are you sure you want to report this post to staff?
      Cancel
    Posted on 19:04:45 - 01/05/24 (1 year ago)
    Post link copied to clipboard Copy post link
    You should probably have this moved or repost in B&I. Posts here get rarely checked by staff, if at all.
    • Azathoth [1677351]
    • Role: Wiki Contributor
    • Level: 70
    • Posts: 166
    • Karma: 353
    • Last Action: Now
      • 0
    • Reason:
      Are you sure you want to report this post to staff?
      Cancel
    Posted on 19:08:35 - 01/05/24 (1 year ago)
    Post link copied to clipboard Copy post link
    I'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.
    • tiksan [2383326]
    • Role: Civilian
    • Level: 100
    • Posts: 1,011
    • Karma: 1,338
    • Last Action: 14 minutes
      • 0
    • Reason:
      Are you sure you want to report this post to staff?
      Cancel
    Posted on 05:22:45 - 06/05/24 (1 year ago)
    Post link copied to clipboard Copy post link
    There 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

    https://cdn.discordapp.com/attachments/719011659561173012/1237732490513481809/Sith_Larping_Asshats.gif?ex=678f8935&is=678e37b5&hm=6d9a2ed93994782d9020538e0ec71a3d072964d584aceb09e9e6f547752d41e0&

Reply
Thread Title: