Skip to content
TORNLIFE More

Online status

Started by tonyuh [2093883] on in API Development.

9 replies · 931 views · thread synced · 4 days ago · View on torn.com
About this thread

Posts archived: 10 / 10 posts (100%) · the total is Torn's reply count + the opening post at the last fetch

Counted by TornLife from the archived posts.

Archived posts
10
Discussion span
→
People posting
5
Likes on archived posts
2
Posts by staff, officers and moderators
1
Authority score
73 / 100
Historical score
28 / 100
Story score
35 / 100
Engagement score
61 / 100
tonyuh [2093883]
Hi guys, I just can't figure out where to get the online status (online/idle/offline, green/yellow/grey dot thingy) for each player from the API, it doesn't seem to be some kind of calculation regarding your last action timestamp because some people I checked had timestamp of less than a minute but already offline.

What am I missing here?
SVD_NL [2363978]
Going through the different API calls it seems like you can't get it directly. (Tried profile, basic, icons, and some faction calls).

I don't think you can calculate it from the last action either, maybe the green icon does, but the idle icon seems to take into account wether you still have the tab or app open (just my hypothesis).

Maybe a workaround would be storing the last_action timestamp from the previous call and comparing it with the new one, and if it has changed you mark it as online. This would require a high frequency of calls though, and isn't sustainable for a large amount of users, neither is it useful for a real-time application.

Another way would be for you to make your own systems where less than 1 minute ago will be marked as online, less than 5 or 10 will be idle for example.

Maybe the API isn't the right way to get this. I could imagine being able to get this info by a script that loads the profile page and looks for the three icons there, but I'm not familiar with scripting like that so I can't help you any further than the vague idea about that.

Hope this has helped you.
DeKleineKobini [2114440] Committee Committee
This gives the 'x minutes ago', which was already mentioned that it isn't the same as online status
One could be 'idle' (the orange dot) but be offline for 6 hours or longer.
One could be 'offline' but only be offline for 10 minutes.

The idle / offine / online is the target.
Xradiation [2254540]
this is the legal way to do it.
Icon1(online/offline/idle) should be under profile => basicicons but it isn't.

should be suggested
xedx [2100735]
It is possible.

Try this, entering your key at the end:

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

Response:
{	"level": 70,	
"gender": "Male",
"player_id": 2100735,
"name": "xedx",
"status":
{ "description": "Okay",
"details": "",
"state": "Okay", // <-- Isn't this what you want?
"color": "green",
"until": 0
}
}


Edit: Turns out this does NOT display the user's state (online, idle, offline - green, yellow, gray), this returns a status such as Okay, Jailed, Hospitalized, etc.

Hosp, Jail: Red
Travelling: Blue
Okay: Green