Get my oldest log enties | API Development | TORN

Get my oldest log enties

    • Pimmetje [3286235]
    • Role: Civilian
    • Level: 40
    • Posts: 6
    • Karma: 0
    • Last Action: 4 hours
      • 0
    • Reason:
      Are you sure you want to report this post to staff?
      Cancel
    Thread created on 16:15:18 - 29/09/24 (2 months ago)
    |
    Last replied 23:25:34 - 28/11/24 (15 days ago)

    Hi all,

     

    I want to get my oldest log entries and after that iterate to the current date so i have all my logs to analyze. And later update them with new entries. 

     

    Something like this : https://api.torn.com/user/?selections=log&from=1&key= still gives the latest entries and not from the start. Also if i give a timestamp that has entries it also gives the latest entries. 

    If i add the to field i can get it to filter records. But that for me feels inefficient as i won't know if i am missing entries if i guess a date/time to fetch to without having overlap that is a waste of resources.

     

    If someone can shine some light on it i would appreciate it a lot. I think the same goes for faction logs etc.

     

    Kind regards,

     

    Pimmetje

    • splent [2088243]
    • Role: Admin
    • Level: 95
    • Posts: 736
    • Karma: 2,032
    • Last Action: 4 hours
      • 0
    • Reason:
      Are you sure you want to report this post to staff?
      Cancel
    Posted on 11:32:41 - 30/09/24 (2 months ago)
    Post link copied to clipboard Copy post link

    Hey Pimmetje, 

    So I think you will have to do this the other way around - start from the newest and make your way to the oldest. 

    Currently, the logs will always provide the newest possible results, so if you don't provide the "to" parameter these will always default to the latest logs.

    Instead, you could just reverse your approach:
    1. get the latest logs: https://api.torn.com/user/?selections=log&key=
    2. take the oldest timestamp form the response and set it as "to" parameter: https://api.torn.com/user/?selections=log&to=1727649345&key= (you can also add +1 second to the timestamp just in case if you have multiple logs at the same time)

    If you're interested in just some specific categories or log types, you can also pass "cat" & "log" parameters.

    Hopefully that helps!

    • tiksan [2383326]
    • Role: Civilian
    • Level: 100
    • Posts: 947
    • Karma: 1,257
    • Last Action: 19 minutes
      • 0
    • Reason:
      Are you sure you want to report this post to staff?
      Cancel
    Posted on 15:05:08 - 30/09/24 (2 months ago)
    Post link copied to clipboard Copy post link

    splent [2088243]

    Hey Pimmetje, 

    So I think you will have to do this the other way around - start from the newest and make your way to the oldest. 

    Currently, the logs will always provide the newest possible results, so if you don't provide the "to" parameter these will always default to the latest logs.

    Instead, you could just reverse your approach:
    1. get the latest logs: https://api.torn.com/user/?selections=log&key=
    2. take the oldest timestamp form the response and set it as "to" parameter: https://api.torn.com/user/?selections=log&to=1727649345&key= (you can also add +1 second to the timestamp just in case if you have multiple logs at the same time)

    If you're interested in just some specific categories or log types, you can also pass "cat" & "log" parameters.

    Hopefully that helps!

    Couldn't you do `from={{ signup date }}` and some `to` value that's a certain amount of time from the `from` value? And assume you won't get 100 logs or else you split the time span until you get less than 100 logs. And just increment both timestamps every API call.

     

    I explained this horribly lol.

    LnNwLrL.gif

    • Titanic_ [2968477]
    • Role: Civilian
    • Level: 72
    • Posts: 314
    • Karma: 316
    • Last Action: 10 hours
      • 0
    • Reason:
      Are you sure you want to report this post to staff?
      Cancel
    Posted on 15:16:13 - 30/09/24 (2 months ago)
    Post link copied to clipboard Copy post link

    splent [2088243]

    Hey Pimmetje, 

    So I think you will have to do this the other way around - start from the newest and make your way to the oldest. 

    Currently, the logs will always provide the newest possible results, so if you don't provide the "to" parameter these will always default to the latest logs.

    Instead, you could just reverse your approach:
    1. get the latest logs: https://api.torn.com/user/?selections=log&key=
    2. take the oldest timestamp form the response and set it as "to" parameter: https://api.torn.com/user/?selections=log&to=1727649345&key= (you can also add +1 second to the timestamp just in case if you have multiple logs at the same time)

    If you're interested in just some specific categories or log types, you can also pass "cat" & "log" parameters.

    Hopefully that helps!

    tiksan [2383326]

    Couldn't you do `from={{ signup date }}` and some `to` value that's a certain amount of time from the `from` value? And assume you won't get 100 logs or else you split the time span until you get less than 100 logs. And just increment both timestamps every API call.

     

    I explained this horribly lol.

    Your explanation is fine tbh

    • Pimmetje [3286235]
    • Role: Civilian
    • Level: 40
    • Posts: 6
    • Karma: 0
    • Last Action: 4 hours
      • 0
    • Reason:
      Are you sure you want to report this post to staff?
      Cancel
    Posted on 20:04:58 - 30/09/24 (2 months ago)
    Post link copied to clipboard Copy post link

    The goal of the exercise for me is to as little api calls as possible. Without having to worry about missing events. 

    So i like to plan my calls so they would get 100 entries per call. 

     

    So i would like to go from born to current in 100 events intervals. If that is currently not possible i would like to add it as a feature request. 

    • Titanic_ [2968477]
    • Role: Civilian
    • Level: 72
    • Posts: 314
    • Karma: 316
    • Last Action: 10 hours
      • 0
    • Reason:
      Are you sure you want to report this post to staff?
      Cancel
    Posted on 20:16:09 - 30/09/24 (2 months ago)
    Post link copied to clipboard Copy post link

    Pimmetje [3286235]

    The goal of the exercise for me is to as little api calls as possible. Without having to worry about missing events. 

    So i like to plan my calls so they would get 100 entries per call. 

     

    So i would like to go from born to current in 100 events intervals. If that is currently not possible i would like to add it as a feature request. 

    Just get the logs you care about with https://torn.report/export

    • Pimmetje [3286235]
    • Role: Civilian
    • Level: 40
    • Posts: 6
    • Karma: 0
    • Last Action: 4 hours
      • 0
    • Reason:
      Are you sure you want to report this post to staff?
      Cancel
    Posted on 21:21:54 - 30/09/24 (2 months ago)
    Post link copied to clipboard Copy post link

    That one does it like described above. I would like to do it in less API calls. 

    I think if only the from parameter is given (no to parameter) it should supply the next 100 log entries from the value of the from argument. (Or less if it is at the end).

    That would make more sense. And should not break any existing calls for as far as i can see.

    • tiksan [2383326]
    • Role: Civilian
    • Level: 100
    • Posts: 947
    • Karma: 1,257
    • Last Action: 19 minutes
      • 0
    • Reason:
      Are you sure you want to report this post to staff?
      Cancel
    Posted on 23:13:40 - 30/09/24 (2 months ago)
    Post link copied to clipboard Copy post link

    Pimmetje [3286235]

    That one does it like described above. I would like to do it in less API calls. 

    I think if only the from parameter is given (no to parameter) it should supply the next 100 log entries from the value of the from argument. (Or less if it is at the end).

    That would make more sense. And should not break any existing calls for as far as i can see.

    Do it like I said then. Also assuming that a minor change won't break anything for anyone will lead to breaking a lot of things.

    LnNwLrL.gif

    • Londo_Mollari [2658150]
    • Role: Civilian
    • Level: 99
    • Posts: 369
    • Karma: 392
    • Last Action: 3 hours
      • 0
    • Reason:
      Are you sure you want to report this post to staff?
      Cancel
    Posted on 20:53:24 - 29/10/24 (1 month ago)
    Post link copied to clipboard Copy post link

    Events endpoint now works in the same way as log, with 'from' parameter you get always newest 100 entries and must add 'to' argument to fetch anything before that. But not attacks endpoint, it returns oldest data since 'from'. 

    Well done Splent, people will get confused and end up either always fetch everything, or hammer the api in tight loop, just to be sure :)

    Last edited by Londo_Mollari on 20:54:17 - 29/10/24 (1 month ago)
    • splent [2088243]
    • Role: Admin
    • Level: 95
    • Posts: 736
    • Karma: 2,032
    • Last Action: 4 hours
      • 0
    • Reason:
      Are you sure you want to report this post to staff?
      Cancel
    Posted on 23:25:34 - 28/11/24 (15 days ago)
    Post link copied to clipboard Copy post link

    Londo_Mollari [2658150]

    Events endpoint now works in the same way as log, with 'from' parameter you get always newest 100 entries and must add 'to' argument to fetch anything before that. But not attacks endpoint, it returns oldest data since 'from'. 

    Well done Splent, people will get confused and end up either always fetch everything, or hammer the api in tight loop, just to be sure :)

    That sounds like a default sorting in this case is incorrect. I’ll add it to my to-do list…

Reply
Thread Title: