Best way to pull (xan use) from armorynews? | API Development …

Best way to pull (xan use) from armorynews?

    • LaZoR50 [663200]
    • Role: Civilian
    • Level: 77
    • Posts: 270
    • Karma: 36
    • Last Action: 1 hour
      • 0
    • Reason:
      Are you sure you want to report this post to staff?
      Cancel
    Thread created on 17:03:42 - 23/05/24 (11 months ago)
    |
    Last replied 12:01:25 - 19/06/24 (11 months ago)

    Hiya, unfortunately back with another question for someone who may have more experience in doing this than myself...

     

    In short, I am trying to (slowly, obviously) pull each of my members Xanax Use that was taken from the armory.

     

    I am aware that I am to use the to= and from=, but I am having some difficulty pinpointing the best way to do that.

     

    So my questions;

    • What is the best time to put inbetween to & from, I have tweaked from just a day to 3, to 7 and even to 14 days, but somehow the results come back broken, I'm not sure what the most optimal timeframe would be to use.
    • How do I prevent it from pushing me doubles? My from time is basically the last news line's timestamp +1 (or 3) seconds, but this still gave me weird results (like 300 more xans than they even ever took)
    •  

    There's probably better ways to go about this, so I'm hoping for some insight before I try again later today.

     

    Thanks in advance!

    • Ducati_Jack [2858364]
    • Role: Civilian
    • Level: 72
    • Posts: 174
    • Karma: 113
    • Last Action: 39 minutes
      • 0
    • Reason:
      Are you sure you want to report this post to staff?
      Cancel
    Posted on 00:21:44 - 04/06/24 (11 months ago)
    Post link copied to clipboard Copy post link
    API_URL = f"https://api.torn.com/faction/?selections=armorynews&key={API_KEY}&from={start_timestamp}&to={end_timestamp}"


    note that it will only pull up to 100 at a time, which means multiple calls, a for loop would work great

    sounds to me like theres some other issue with your code giving you multiple of the same log?

    Last edited by Ducati_Jack on 00:23:25 - 04/06/24 (11 months ago)

    Oh no my ....... income

    • _los_ [2962012]
    • Role: Civilian
    • Level: 30
    • Posts: 20
    • Karma: 9
    • Last Action: 37 minutes
      • 0
    • Reason:
      Are you sure you want to report this post to staff?
      Cancel
    Posted on 15:11:50 - 08/06/24 (11 months ago)
    Post link copied to clipboard Copy post link

    The multiples are likely caused by the default sort order. It defaults to descending, so if you're taking the last timestamp and adding time to it, you'll see the last timestamp again. 

     

    Either do last_timestamp -1, or &sort="asc" and it should be fixed

    • Kwack [2190604]
    • Role: Civilian
    • Level: 15
    • Posts: 2,284
    • Karma: 3,613
    • Last Action: 40 minutes
      • 0
    • Reason:
      Are you sure you want to report this post to staff?
      Cancel
    Posted on 15:30:39 - 08/06/24 (11 months ago)
    Post link copied to clipboard Copy post link

    _los_ [2962012]

    The multiples are likely caused by the default sort order. It defaults to descending, so if you're taking the last timestamp and adding time to it, you'll see the last timestamp again. 

     

    Either do last_timestamp -1, or &sort="asc" and it should be fixed

    You want there to be a slight overlap to make sure you don't miss any logs. If you go to the next second, then any logs in the same second as the last one that weren't included in the last call will get skipped

    • _los_ [2962012]
    • Role: Civilian
    • Level: 30
    • Posts: 20
    • Karma: 9
    • Last Action: 37 minutes
      • 0
    • Reason:
      Are you sure you want to report this post to staff?
      Cancel
    Posted on 23:05:46 - 08/06/24 (11 months ago)
    Post link copied to clipboard Copy post link

    Fair, I use the id's to detect multiples, myself. My answer was more pointed at the reason why he was getting 300+ xanax uses from the same user.

     

    • How do I prevent it from pushing me doubles? My from time is basically the last news line's timestamp +1 (or 3) seconds, but this still gave me weird results (like 300 more xans than they even ever took)

     

    Either the "+" instead of the "-", or the sort order, those are the likely culprits.

    Last edited by _los_ on 23:06:11 - 08/06/24 (11 months ago)
    • LaZoR50 [663200]
    • Role: Civilian
    • Level: 77
    • Posts: 270
    • Karma: 36
    • Last Action: 1 hour
      • 0
    • Reason:
      Are you sure you want to report this post to staff?
      Cancel
    Posted on 12:01:25 - 19/06/24 (11 months ago)
    Post link copied to clipboard Copy post link

    If an update was required, all has worked out great. It took a bit to get used to working with it... But mostly due to my own stupidity (don't get high and start programming).

Reply
Thread Title: