How do I get Online Status of user?

Right now I’m working on making a system for a Roblox game where I can detect if a player is online and what game they’re in and other things, the only way I’ve seen to do this would be via the presence api endpoint https://presence.roblox.com//docs/index.html and currently when I send the post request I’m not able to accurately obtain the information of a player, right now I’m doing this off roblox in a python script and this is how it goes:

This is my python code:

import tkinter as tk
from tkinter import messagebox
import requests
import json

def get_user_presence():
    user_id = user_id_entry.get()
    
    if not user_id.isdigit():
        messagebox.showerror("Invalid Input", "Please enter a valid numeric User ID.")
        return
    
    proxy_url = "roproxy.com"
    url = f"https://presence.{proxy_url}/v1/presence/users"
    headers = {
        "Content-Type": "application/json"
    }
    
    data = {
        "userIds": [int(user_id)]
    }
    
    try:
        response = requests.post(url, headers=headers, json=data)
        
        if response.status_code == 200:
            raw_json = response.json()
            print(json.dumps(raw_json, indent=4))
            
            user_presences = raw_json.get("userPresences", [])
            
            if user_presences:
                presence_info = user_presences[0]
                
                user_id = presence_info.get('userId', 'N/A')
                last_online = presence_info.get('lastOnline', 'N/A')
                invisible_mode_expiry = presence_info.get('invisibleModeExpiry', 'N/A')
                last_location = presence_info.get('lastLocation', 'N/A') or "Not in a game currently"
                game_id = presence_info.get('gameId', 'N/A') or "Not in a game currently"
                user_presence_type = presence_info.get('userPresenceType', 'N/A')
                
                if user_presence_type == 0:
                    presence_status = "Offline"
                elif user_presence_type == 1:
                    presence_status = f"Playing a game ({game_id})"
                elif user_presence_type == 2:
                    presence_status = "In Roblox Studio"
                elif user_presence_type == 3:
                    presence_status = "On Roblox Website"
                else:
                    presence_status = "Unknown Status"
                
                message = f"User ID: {user_id}\n"
                message += f"Presence: {presence_status}\n"
                message += f"Last Online: {last_online}\n"
                message += f"Invisible Mode Expiry: {invisible_mode_expiry}\n"
                message += f"Last Location: {last_location}\n"
                message += f"Game ID: {game_id}\n"
                
                messagebox.showinfo("User Presence Information", message)
            else:
                messagebox.showinfo("User Presence Information", "The user is not currently online.")
        else:
            messagebox.showerror("Error", f"Failed to retrieve presence data. Status Code: {response.status_code}")
    
    except requests.exceptions.RequestException as e:
        messagebox.showerror("Request Error", f"An error occurred: {e}")

root = tk.Tk()
root.title("Roblox User Presence Checker")

label = tk.Label(root, text="Enter User ID:")
label.pack(pady=10)

user_id_entry = tk.Entry(root, width=30)
user_id_entry.pack(pady=5)

check_button = tk.Button(root, text="Check Presence", command=get_user_presence)
check_button.pack(pady=20)

root.mainloop()

I can easily convert to lua to ping the presence api, but i explained why im doing it in python at the moment in the video, so do watch it if you need context.

1 Like

look into this ig: