Total Robux Spent Checker - Python Tool for Roblox Developers

Introduction

Hey developers! I’ve built a handy Python script that calculates your total Robux spent by analyzing your Roblox transaction history. Whether you’re curious about your spending habits or want to track expenses for your account, this tool fetches purchase data via the Roblox API and gives you a detailed breakdown—complete with a running total printed after every transaction check. I’d love your feedback on how to improve it or if you find it useful!

What It Does

  • Inputs: Your .ROBLOSECURITY cookie (keep it private!).
  • Process: Uses the Roblox Economy API (/v2/user-transactions) to fetch purchase transactions.
  • Output: Prints each Robux purchase amount and updates the total spent, ending with a final tally.
  • Features:
    • Handles pagination with cursors for complete history.
    • Session-based requests with X-CSRF token support for authentication.
    • Simple, lightweight, and customizable.

The Code

Here’s the script I’m sharing (tested as of March 25, 2025):

import requests
import time

total = 0
cookie = "YOUR_ROBLOSECURITY_COOKIE_HERE"  # Replace with your cookie
session = requests.Session()
session.cookies['.ROBLOSECURITY'] = cookie

def get_csrf_token():
    response = session.post('https://auth.roblox.com/v2/logout', headers={
        "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64)"
    })
    return response.headers.get("x-csrf-token")

def get_user_id():
    token = get_csrf_token()
    headers = {"X-CSRF-TOKEN": token, "User-Agent": "Mozilla/5.0"}
    response = session.get('https://users.roblox.com/v1/users/authenticated', headers=headers)
    return response.json()['id'] if response.status_code == 200 else None

def main():
    global total
    user_id = get_user_id()
    if not user_id:
        print("Failed to get user ID.")
        return
    
    cursor = ''
    token = get_csrf_token()
    headers = {"X-CSRF-TOKEN": token, "User-Agent": "Mozilla/5.0"}

    while cursor is not None:
        response = session.get(
            f'https://economy.roblox.com/v2/users/{user_id}/transactions',
            headers=headers,
            params={'transactionType': 'Purchase', 'limit': 100, 'cursor': cursor}
        )
        
        if response.status_code == 200:
            data = response.json()
            if 'data' in data:
                print(f'Found {len(data["data"])} purchases')
                for purchase in data['data']:
                    if purchase['currency']['type'] == 'Robux':
                        amount = abs(purchase['currency']['amount'])
                        total += amount
                        print(f"New purchase: {amount} Robux | Running total: {total}")
                cursor = data.get('nextPageCursor')
            else:
                break
        else:
            print(f"Error: {response.status_code} - {response.text}")
            time.sleep(30)
            break

    print(f'\nTotal Robux Spent: {total}')

if __name__ == "__main__":
    print("WARNING: Keep your cookie private!")
    main()

How to Use It

  1. Install requests: pip install requests
  2. Replace "YOUR_ROBLOSECURITY_COOKIE_HERE" with your Roblox cookie (get it from your browser’s dev tools).
  3. Run the script and watch it tally your Robux spending!

Why I Made This

I wanted a quick way to see how much Robux I’ve spent over time without manually digging through Roblox’s website. It’s also a fun project for learning Python and interacting with Roblox’s API—perfect for scripters or data nerds!

Feedback Wanted

  • Does it work for you? Any errors (e.g., 404, 403)?
  • Ideas for features—like saving totals to a file or filtering by date?
  • Should I add GUI support or keep it command-line?