Is it possible to know when someone hops online | API Developm…

Is it possible to know when someone hops online

    • Ixw [3143585]
    • Role: Civilian
    • Level: 19
    • Posts: 33
    • Karma: 3
    • Last Action: 3 months
      • 0
    • Reason:
      Are you sure you want to report this post to staff?
      Cancel
    Thread created on 03:46:44 - 30/01/24 (7 months ago)
    |
    Last replied 08:16:48 - 29/02/24 (6 months ago)
    so i am wondering if it is possible via the api to automate to see during a war when someone on the opposing faction gets on, i know you can do that for your members and when your on torn you can see if they are online via green, inactive in yellow or offline in white and i was just wondering if there would be a way to get like a warning when a big hitter comes online as far as i can tell the functionality isnt there same thing as no way to search for a user via the api
    Last edited by Ixw on 03:47:21 - 30/01/24
    • Kwack [2190604]
    • Role: Civilian
    • Level: 15
    • Posts: 1,861
    • Karma: 2,824
    • Last Action: 1 minute
      • 0
    • Reason:
      Are you sure you want to report this post to staff?
      Cancel
    Posted on 05:18:23 - 30/01/24 (7 months ago)
    Post link copied to clipboard Copy post link
    There's a whole user section? Wdym you can't search for a user via the API? https://www.torn.com/api.html

    Or see the better docs here.

    https://api.torn.com/user/3143585?selections=basic&key=


    You can also use faction --> basic with the ID of the faction to get all members in the faction at once.
    • Ixw [3143585]
    • Role: Civilian
    • Level: 19
    • Posts: 33
    • Karma: 3
    • Last Action: 3 months
      • 0
    • Reason:
      Are you sure you want to report this post to staff?
      Cancel
    Posted on 18:30:36 - 30/01/24 (7 months ago)
    Post link copied to clipboard Copy post link
    yea sorry im slowly working thru it essentailly im trying to see the status of online, inactive or offline, for an entire faction
    • Ixw [3143585]
    • Role: Civilian
    • Level: 19
    • Posts: 33
    • Karma: 3
    • Last Action: 3 months
      • 0
    • Reason:
      Are you sure you want to report this post to staff?
      Cancel
    Posted on 18:32:48 - 30/01/24 (7 months ago)
    Post link copied to clipboard Copy post link
    current idea is given the faction name sift thru the torn api using the rankedwars and then it shows all the ongoing wars i essentially want a way to see if a leader is or isnt online for a faction that isnt mine, so rn i am working on the python side to just get the faction id and then the specfic user ids needed to look at the status element in the dict
    • Ixw [3143585]
    • Role: Civilian
    • Level: 19
    • Posts: 33
    • Karma: 3
    • Last Action: 3 months
      • 0
    • Reason:
      Are you sure you want to report this post to staff?
      Cancel
    Posted on 18:36:01 - 30/01/24 (7 months ago)
    Post link copied to clipboard Copy post link
    yea i found what im looking for via the api sorry for not wording it well
    • Ixw [3143585]
    • Role: Civilian
    • Level: 19
    • Posts: 33
    • Karma: 3
    • Last Action: 3 months
      • 0
    • Reason:
      Are you sure you want to report this post to staff?
      Cancel
    Posted on 18:37:05 - 30/01/24 (7 months ago)
    Post link copied to clipboard Copy post link
    now to see if i can query the api better so i dont have a nested loop
    Last edited by Ixw on 18:48:37 - 30/01/24
    • 0xHemlock [2662912]
    • Role: Civilian
    • Level: 96
    • Posts: 1,053
    • Karma: 1,800
    • Last Action: 3 minutes
      • 0
    • Reason:
      Are you sure you want to report this post to staff?
      Cancel
    Posted on 19:19:01 - 30/01/24 (7 months ago)
    Post link copied to clipboard Copy post link
    This is probably better suited for the userscript forum, but yes I think you're on the right track. When I watch a faction I first find a way to grab the faction ID, usually through a query on the leader. Then send that ID to query for the faction and get the list of members. Then, very simply a periodic check on each member to get their information, which in this case is their status. Adding a factionmate's API key to the rotation helps avoid the API rate limits, and having all of this in a Google Sheet means other war leaders can reference the sheet and act accordingly. Of course, you can make a watchlist to send a ping/text/email if specific people come online, and that's up to you for how you want to set it up.

    Sounds like quite the useful project! Good luck!

    WestWorld

    • Omanpx [1906686]
    • Role: Civilian
    • Level: 100
    • Posts: 1,932
    • Karma: 11,338
    • Last Action: 24 minutes
      • 0
    • Reason:
      Are you sure you want to report this post to staff?
      Cancel
    Posted on 19:34:17 - 30/01/24 (7 months ago)
    Post link copied to clipboard Copy post link
    A single call to faction/basic gives you all the information you need - it has a full list of members with their online status. You can get the faction ID from the url when you are on the faction main page.
    All you need is 1 call per faction to get the status of their entire rosters.

    Toolbox - a collection of my tools and spreadsheets made for Torn.

    Guidebook - a collection of guides i made for Torn.

    • DeKleineKobini [2114440]
    • Role: Committee
    • Level: 100
    • Posts: 3,745
    • Karma: 5,371
    • Last Action: 21 minutes
      • 0
    • Reason:
      Are you sure you want to report this post to staff?
      Cancel
    Posted on 20:53:51 - 30/01/24 (7 months ago)
    Post link copied to clipboard Copy post link

    0xHemlock [2662912]

    This is probably better suited for the userscript forum, but yes I think you're on the right track. When I watch a faction I first find a way to grab the faction ID, usually through a query on the leader. Then send that ID to query for the faction and get the list of members. Then, very simply a periodic check on each member to get their information, which in this case is their status. Adding a factionmate's API key to the rotation helps avoid the API rate limits, and having all of this in a Google Sheet means other war leaders can reference the sheet and act accordingly. Of course, you can make a watchlist to send a ping/text/email if specific people come online, and that's up to you for how you want to set it up.

    Sounds like quite the useful project! Good luck!
    Why would it be? It's literally about development using the API. I'd say either this is the best place, or the one of the specialized channels in the TornAPI discord.
    • 0xHemlock [2662912]
    • Role: Civilian
    • Level: 96
    • Posts: 1,053
    • Karma: 1,800
    • Last Action: 3 minutes
      • 0
    • Reason:
      Are you sure you want to report this post to staff?
      Cancel
    Posted on 21:46:55 - 30/01/24 (7 months ago)
    Post link copied to clipboard Copy post link

    0xHemlock [2662912]

    This is probably better suited for the userscript forum, but yes I think you're on the right track. When I watch a faction I first find a way to grab the faction ID, usually through a query on the leader. Then send that ID to query for the faction and get the list of members. Then, very simply a periodic check on each member to get their information, which in this case is their status. Adding a factionmate's API key to the rotation helps avoid the API rate limits, and having all of this in a Google Sheet means other war leaders can reference the sheet and act accordingly. Of course, you can make a watchlist to send a ping/text/email if specific people come online, and that's up to you for how you want to set it up.

    Sounds like quite the useful project! Good luck!

    DeKleineKobini [2114440]

    Why would it be? It's literally about development using the API. I'd say either this is the best place, or the one of the specialized channels in the TornAPI discord.
    Okay, fair enough. Maybe I'm misinterpreting the role of this subforum. I thought it was development -of- the API, not development -using- the API. My mistake.

    WestWorld

    • Microbes [2622522]
    • Role: Civilian
    • Level: 66
    • Posts: 707
    • Karma: 148
    • Last Action: 5 minutes
      • 0
    • Reason:
      Are you sure you want to report this post to staff?
      Cancel
    Posted on 13:44:39 - 01/02/24 (7 months ago)
    Post link copied to clipboard Copy post link

    Omanpx [1906686]

    A single call to faction/basic gives you all the information you need - it has a full list of members with their online status. You can get the faction ID from the url when you are on the faction main page.
    All you need is 1 call per faction to get the status of their entire rosters.
    Is there any disadvantage to this? I remembering seeing somewhere that they says calling from faction/basic will give cached result? But couldn't find my source now. So want to confirm again, by any chance, do you know if is it cached result or not?
    Last edited by Microbes on 13:45:03 - 01/02/24
    • Omanpx [1906686]
    • Role: Civilian
    • Level: 100
    • Posts: 1,932
    • Karma: 11,338
    • Last Action: 24 minutes
      • 0
    • Reason:
      Are you sure you want to report this post to staff?
      Cancel
    Posted on 13:58:32 - 01/02/24 (7 months ago)
    Post link copied to clipboard Copy post link

    Microbes [2622522]

    Is there any disadvantage to this? I remembering seeing somewhere that they says calling from faction/basic will give cached result? But couldn't find my source now. So want to confirm again, by any chance, do you know if is it cached result or not?
    Been using it for a bot for this exact purpose for years now, doesn't feel like it's cached apart from the standard 30 sec key cache. For your application, i think it's the only reasonable way to go about it - can even use TornStats or YATA API to incorporate stats from spies.

    Toolbox - a collection of my tools and spreadsheets made for Torn.

    Guidebook - a collection of guides i made for Torn.

    • Ixw [3143585]
    • Role: Civilian
    • Level: 19
    • Posts: 33
    • Karma: 3
    • Last Action: 3 months
      • 0
    • Reason:
      Are you sure you want to report this post to staff?
      Cancel
    Posted on 23:49:48 - 01/02/24 (7 months ago)
    Post link copied to clipboard Copy post link

    0xHemlock [2662912]

    This is probably better suited for the userscript forum, but yes I think you're on the right track. When I watch a faction I first find a way to grab the faction ID, usually through a query on the leader. Then send that ID to query for the faction and get the list of members. Then, very simply a periodic check on each member to get their information, which in this case is their status. Adding a factionmate's API key to the rotation helps avoid the API rate limits, and having all of this in a Google Sheet means other war leaders can reference the sheet and act accordingly. Of course, you can make a watchlist to send a ping/text/email if specific people come online, and that's up to you for how you want to set it up.

    Sounds like quite the useful project! Good luck!
    so for that query on the faction leader, i had a way were i was using rankedwars then going thru all those to check each faction and then find the id for the leader or the faction, however its annoying to do that since its a nested loop, so i figure i could just cache the ids for factions and users to save time. tho i am curious if rankedwars shows all factions i think it just shows factions currently in a war
    • Kwack [2190604]
    • Role: Civilian
    • Level: 15
    • Posts: 1,861
    • Karma: 2,824
    • Last Action: 1 minute
      • 0
    • Reason:
      Are you sure you want to report this post to staff?
      Cancel
    Posted on 06:37:11 - 02/02/24 (7 months ago)
    Post link copied to clipboard Copy post link

    0xHemlock [2662912]

    This is probably better suited for the userscript forum, but yes I think you're on the right track. When I watch a faction I first find a way to grab the faction ID, usually through a query on the leader. Then send that ID to query for the faction and get the list of members. Then, very simply a periodic check on each member to get their information, which in this case is their status. Adding a factionmate's API key to the rotation helps avoid the API rate limits, and having all of this in a Google Sheet means other war leaders can reference the sheet and act accordingly. Of course, you can make a watchlist to send a ping/text/email if specific people come online, and that's up to you for how you want to set it up.

    Sounds like quite the useful project! Good luck!

    Ixw [3143585]

    so for that query on the faction leader, i had a way were i was using rankedwars then going thru all those to check each faction and then find the id for the leader or the faction, however its annoying to do that since its a nested loop, so i figure i could just cache the ids for factions and users to save time. tho i am curious if rankedwars shows all factions i think it just shows factions currently in a war
    It shows factions that are currently "matched".

    If you go to the faction's page and you can see the war next to the chain box, then it'll show on the war's section (from memory)

    This starts on Tuesday enlistment, and ends a little bit after the war ends (24hrs? I'm not actually sure).
    • Ixw [3143585]
    • Role: Civilian
    • Level: 19
    • Posts: 33
    • Karma: 3
    • Last Action: 3 months
      • 0
    • Reason:
      Are you sure you want to report this post to staff?
      Cancel
    Posted on 14:24:53 - 02/02/24 (7 months ago)
    Post link copied to clipboard Copy post link

    0xHemlock [2662912]

    This is probably better suited for the userscript forum, but yes I think you're on the right track. When I watch a faction I first find a way to grab the faction ID, usually through a query on the leader. Then send that ID to query for the faction and get the list of members. Then, very simply a periodic check on each member to get their information, which in this case is their status. Adding a factionmate's API key to the rotation helps avoid the API rate limits, and having all of this in a Google Sheet means other war leaders can reference the sheet and act accordingly. Of course, you can make a watchlist to send a ping/text/email if specific people come online, and that's up to you for how you want to set it up.

    Sounds like quite the useful project! Good luck!

    Ixw [3143585]

    so for that query on the faction leader, i had a way were i was using rankedwars then going thru all those to check each faction and then find the id for the leader or the faction, however its annoying to do that since its a nested loop, so i figure i could just cache the ids for factions and users to save time. tho i am curious if rankedwars shows all factions i think it just shows factions currently in a war

    Kwack [2190604]

    It shows factions that are currently "matched".

    If you go to the faction's page and you can see the war next to the chain box, then it'll show on the war's section (from memory)

    This starts on Tuesday enlistment, and ends a little bit after the war ends (24hrs? I'm not actually sure).
    Yea that is what I figured I suppose I will have a script run once a week to update some cached stuff for that in a dict, tho a dumb way would be attack a person and then just use the attacks call in user for their id and then get the faction is that way
    • Omanpx [1906686]
    • Role: Civilian
    • Level: 100
    • Posts: 1,932
    • Karma: 11,338
    • Last Action: 24 minutes
      • 0
    • Reason:
      Are you sure you want to report this post to staff?
      Cancel
    Posted on 14:35:36 - 02/02/24 (7 months ago)
    Post link copied to clipboard Copy post link

    Ixw [3143585]

    Yea that is what I figured I suppose I will have a script run once a week to update some cached stuff for that in a dict, tho a dumb way would be attack a person and then just use the attacks call in user for their id and then get the faction is that way
    If you just need the faction + leader IDs, you can grab the full list of Torn factions from the About page in chedslist, updated twice a day. It's a basic .csv format and saves you a bunch of API calls.

    Toolbox - a collection of my tools and spreadsheets made for Torn.

    Guidebook - a collection of guides i made for Torn.

    • Ixw [3143585]
    • Role: Civilian
    • Level: 19
    • Posts: 33
    • Karma: 3
    • Last Action: 3 months
      • 0
    • Reason:
      Are you sure you want to report this post to staff?
      Cancel
    Posted on 16:23:53 - 02/02/24 (7 months ago)
    Post link copied to clipboard Copy post link

    Ixw [3143585]

    Yea that is what I figured I suppose I will have a script run once a week to update some cached stuff for that in a dict, tho a dumb way would be attack a person and then just use the attacks call in user for their id and then get the faction is that way

    Omanpx [1906686]

    If you just need the faction + leader IDs, you can grab the full list of Torn factions from the About page in chedslist, updated twice a day. It's a basic .csv format and saves you a bunch of API calls.
    Oooh thanks that could definitely work
    • Ixw [3143585]
    • Role: Civilian
    • Level: 19
    • Posts: 33
    • Karma: 3
    • Last Action: 3 months
      • 0
    • Reason:
      Are you sure you want to report this post to staff?
      Cancel
    Posted on 16:34:59 - 02/02/24 (7 months ago)
    Post link copied to clipboard Copy post link

    Ixw [3143585]

    Yea that is what I figured I suppose I will have a script run once a week to update some cached stuff for that in a dict, tho a dumb way would be attack a person and then just use the attacks call in user for their id and then get the faction is that way

    Omanpx [1906686]

    If you just need the faction + leader IDs, you can grab the full list of Torn factions from the About page in chedslist, updated twice a day. It's a basic .csv format and saves you a bunch of API calls.

    Ixw [3143585]

    Oooh thanks that could definitely work
    Definitely will work lol thanks
    • Ixw [3143585]
    • Role: Civilian
    • Level: 19
    • Posts: 33
    • Karma: 3
    • Last Action: 3 months
      • 0
    • Reason:
      Are you sure you want to report this post to staff?
      Cancel
    Posted on 17:34:50 - 02/02/24 (7 months ago)
    Post link copied to clipboard Copy post link

    Ixw [3143585]

    Yea that is what I figured I suppose I will have a script run once a week to update some cached stuff for that in a dict, tho a dumb way would be attack a person and then just use the attacks call in user for their id and then get the faction is that way

    Omanpx [1906686]

    If you just need the faction + leader IDs, you can grab the full list of Torn factions from the About page in chedslist, updated twice a day. It's a basic .csv format and saves you a bunch of API calls.
    would you happen to know when the csv is updated? sorta just wanna have a quick hey grab if its out of date call
    • Omanpx [1906686]
    • Role: Civilian
    • Level: 100
    • Posts: 1,932
    • Karma: 11,338
    • Last Action: 24 minutes
      • 0
    • Reason:
      Are you sure you want to report this post to staff?
      Cancel
    Posted on 17:37:58 - 02/02/24 (7 months ago)
    Post link copied to clipboard Copy post link

    Ixw [3143585]

    would you happen to know when the csv is updated? sorta just wanna have a quick hey grab if its out of date call
    I set the job to run at 15 and 3 tct, update takes up to an hour or so, should be around that time.

    Toolbox - a collection of my tools and spreadsheets made for Torn.

    Guidebook - a collection of guides i made for Torn.

Reply
Thread Title: