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!
Get my oldest log enties
-
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
-
-
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! -
-
Posted on 15:05:08 - 30/09/24 (2 months ago)Post link copied to clipboard Copy post link
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.
-
-
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.
-
-
Posted on 20:16:09 - 30/09/24 (2 months ago)Post link copied to clipboard Copy post link
Just get the logs you care about with https://torn.report/export
-
-
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.
-
-
Posted on 23:13:40 - 30/09/24 (2 months ago)Post link copied to clipboard Copy post link
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.
-
-
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) -
-
Posted on 23:25:34 - 28/11/24 (15 days ago)Post link copied to clipboard Copy post link
That sounds like a default sorting in this case is incorrect. I’ll add it to my to-do list…
-