Checking Account Information
Relevant source files
The following files were used as context for generating this wiki page:
The "Checking Account Information" feature provides users with a summary of their Cursor account status directly within the command-line interface. This includes their email, subscription type, trial status, and usage statistics for both fast (premium) and slow (basic) AI responses. The system retrieves this information by first locating the user's authentication token from local Cursor application files and then making API calls to Cursor's backend services.
This functionality is primarily encapsulated in cursor_acc_info.py and is invoked as an option from the main menu in main.py. It relies on path configurations defined in config.py to locate the necessary local data.
Architecture Overview
The system works by orchestrating several components: the main application entry point, a configuration module, and the core account information script. The script reads local Cursor data files to find an authentication token, then uses that token to query two separate API endpoints for subscription and usage data.
The following diagram illustrates the high-level data flow for retrieving and displaying account information.
Sources: main.py:348-352, cursor_acc_info.py
Token and Email Retrieval
To communicate with the Cursor API, the system must first retrieve the user's authentication token and email. These are stored locally by the Cursor application. The retrieval process searches multiple locations in a specific order until the information is found.
Data Sources
The system queries the following local files, with paths defined in config.ini and managed by config.py.
| Data Source | Description | OS-Specific Path (Example: Windows) |
|---|---|---|
storage.json | A JSON file containing various user settings, including the access token and cached email. | %APPDATA%\Cursor\User\globalStorage\storage.json |
state.vscdb | An SQLite database that also stores authentication tokens and user information. | %APPDATA%\Cursor\User\globalStorage\state.vscdb |
| Session Storage | Log files from the application's session that may contain the token. | %APPDATA%\Cursor\Session Storage |
Sources: config.py:100-106, cursor_acc_info.py:118-126, totally_reset_cursor.py:698-727
Retrieval Flow
The token retrieval logic follows a prioritized search pattern, as illustrated in the flowchart below. The email retrieval process follows a similar pattern.
This diagram shows the prioritized search for the authentication token across different local files.
Sources: cursor_acc_info.py:206-224
Key functions involved in this process are:
get_token(): The main orchestrator for token retrieval.get_token_from_config(): Reads paths from the configuration file.get_token_from_storage(): Extracts the token fromstorage.json.get_token_from_sqlite(): Queries thestate.vscdbSQLite database.get_token_from_session(): Searches through session log files.
A similar set of functions (get_email_from_storage, get_email_from_sqlite) exists for retrieving the user's email address.
Sources: cursor_acc_info.py:139-224, cursor_acc_info.py:298-356
API Interaction
Once a token is retrieved, the UsageManager class in cursor_acc_info.py handles all interactions with the Cursor backend API.
UsageManager Class
This class provides static methods to query two key endpoints.
Sources: cursor_acc_info.py:38-116
API Endpoints
The system queries two primary endpoints to gather all necessary account information.
| Method | Endpoint | Purpose | Authorization |
|---|---|---|---|
GET | https://www.cursor.com/api/usage | Retrieves usage statistics for different models (e.g., gpt-4, gpt-3.5-turbo). | Cookie: WorkosCursorSessionToken=... |
GET | https://api2.cursor.sh/auth/full_stripe_profile | Retrieves subscription details, including plan type and trial status. | Authorization: Bearer {token} |
Sources: cursor_acc_info.py:59-63, cursor_acc_info.py:100-104
The sequence diagram below shows the interaction between the local script and the remote API endpoints.
Sources: cursor_acc_info.py:58-116
Expected API Responses
The get_usage function expects a JSON response containing usage data for different models.
{
"gpt-4": {
"numRequestsTotal": 50,
"maxRequestUsage": 100
},
"gpt-3.5-turbo": {
"numRequestsTotal": 200
}
}
Sources: cursor_acc_info.py:67-75
The get_stripe_profile function expects a JSON response with customer and subscription details.
{
"membershipType": "pro_trial",
"subscriptionStatus": "active",
"daysRemainingOnTrial": 14,
"customer": {
"email": "user@example.com"
}
}
Sources: cursor_acc_info.py:236-269, cursor_acc_info.py:378-382
Data Processing and Display
The display_account_info function is responsible for orchestrating the data retrieval, processing, and presentation to the user.
- Data Retrieval: It calls
get_token()to get the auth token, then uses it withUsageManager.get_usage()andUsageManager.get_stripe_profile()to fetch all required data. - Email Retrieval: It attempts to find the user's email from local storage, the SQLite database, or as a fallback, from the Stripe profile API response.
- Subscription Formatting: The
format_subscription_typefunction parses the response from the Stripe profile endpoint to determine a user-friendly subscription status (e.g., "Pro Trial", "Free", "Pro"). It handles both old and new API response formats for backward compatibility. - Usage Calculation: It calculates the usage percentage for premium responses and determines the display color (green, yellow, or red) based on consumption.
- Console Output: Finally, it formats all the information into a two-column layout and prints it to the console, using text from
locales/en.jsonfor labels.
Sources: cursor_acc_info.py:358-482, locales/en.json:400-424
User Authorization Check
The check_user_authorized.py script provides a standalone utility to verify if a given authentication token is valid. This is useful for diagnostics.
The process is as follows:
- Get Token: The script can either retrieve the token automatically from the database (
get_token_from_db) or prompt the user to enter it manually. - API Call: It sends a request to the
https://www.cursor.com/api/usageendpoint using the token. - Validate Response: It checks the HTTP status code of the response. A
200 OKstatus indicates the token is valid and the user is authorized. Any other status code implies the token is invalid or expired.
The following flowchart outlines the logic of the authorization check.
Sources: check_user_authorized.py