Skip to main content

Overview

The Users API allows you to programmatically create, update, and delete user accounts in GamePanelX. All user operations use class=users in the API request.

Available Actions

  • create - Create a new user account
  • update - Update an existing user account
  • delete - Delete a user account

Create User

Creates a new user account in GamePanelX.

Endpoint

POST /api/api.php?class=users&action=create

Parameters

key
string
required
Your API authentication key
class
string
required
Must be users
action
string
required
Must be create
username
string
required
Username for the new account (must be unique)
password
string
required
Password for the new account
email
string
required
Email address for the new account
first_name
string
required
First name of the user
last_name
string
required
Last name of the user

Example Request

curl -X POST https://your-domain.com/api/api.php \
  -d "key=YOUR_API_KEY" \
  -d "class=users" \
  -d "action=create" \
  -d "username=john_doe" \
  -d "password=secure_password123" \
  -d "[email protected]" \
  -d "first_name=John" \
  -d "last_name=Doe"

Response

success
string
Returns success if the user was created successfully, or an error message if creation failed
Success Example:
success
Error Example:
Username already exists
The underlying method returns a numeric user ID on success, but the API endpoint returns success instead of the user ID.

Update User

Updates an existing user account’s information.

Endpoint

POST /api/api.php?class=users&action=update

Parameters

key
string
required
Your API authentication key
class
string
required
Must be users
action
string
required
Must be update
userid
integer
required
The ID of the user to update
username
string
New username for the account
password
string
New password for the account
email
string
New email address for the account
first_name
string
New first name
last_name
string
New last name
language
string
User’s preferred language (e.g., english, spanish)
theme
string
User’s preferred theme

Example Request

curl -X POST https://your-domain.com/api/api.php \
  -d "key=YOUR_API_KEY" \
  -d "class=users" \
  -d "action=update" \
  -d "userid=42" \
  -d "[email protected]" \
  -d "first_name=Jane" \
  -d "language=english" \
  -d "theme=dark"

Response

success
string
Returns a success message or error
You only need to include the parameters you want to update. Parameters not included in the request will remain unchanged.

Delete User

Deletes a user account from GamePanelX.
Deleting a user account may affect associated game servers. Ensure you handle server ownership appropriately before deleting users.

Endpoint

POST /api/api.php?class=users&action=delete

Parameters

key
string
required
Your API authentication key
class
string
required
Must be users
action
string
required
Must be delete
userid
integer
required
The ID of the user to delete

Example Request

curl -X POST https://your-domain.com/api/api.php \
  -d "key=YOUR_API_KEY" \
  -d "class=users" \
  -d "action=delete" \
  -d "userid=42"

Response

success
string
Returns a success message or error

Common Errors

Error MessageCauseSolution
Unknown API actionInvalid action specifiedUse create, update, or delete
Username already existsUsername is takenChoose a different username
User not foundInvalid user IDVerify the user ID exists

Best Practices

1. Store User IDs

When creating users, store the user ID for future update and delete operations. You can retrieve user IDs from the GamePanelX database or admin panel.

2. Use Strong Passwords

Always enforce strong password requirements when creating user accounts via the API.
import re

def validate_password(password):
    if len(password) < 8:
        return False
    if not re.search(r'[A-Z]', password):
        return False
    if not re.search(r'[a-z]', password):
        return False
    if not re.search(r'[0-9]', password):
        return False
    return True

3. Validate Email Addresses

Ensure email addresses are properly formatted before sending them to the API:
import re

def validate_email(email):
    pattern = r'^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$'
    return re.match(pattern, email) is not None

4. Handle Username Uniqueness

Check if a username exists before attempting to create a new user to avoid conflicts.

5. Partial Updates

When using the update action, you only need to include the fields you want to change:
# Only update email and language
curl -X POST https://your-domain.com/api/api.php \
  -d "key=YOUR_API_KEY" \
  -d "class=users" \
  -d "action=update" \
  -d "userid=42" \
  -d "[email protected]" \
  -d "language=spanish"

User Creation Workflow

Here’s a complete workflow for creating a user with error handling:
import requests
import re

def create_user(api_key, api_url, username, password, email, first_name, last_name):
    # Validate inputs
    if not validate_email(email):
        return {'success': False, 'error': 'Invalid email format'}
    
    if not validate_password(password):
        return {'success': False, 'error': 'Password too weak'}
    
    # Make API request
    data = {
        'key': api_key,
        'class': 'users',
        'action': 'create',
        'username': username,
        'password': password,
        'email': email,
        'first_name': first_name,
        'last_name': last_name
    }
    
    try:
        response = requests.post(api_url, data=data, timeout=30)
        
        if response.text == 'success':
            return {'success': True, 'message': 'User created successfully'}
        else:
            return {'success': False, 'error': response.text}
    
    except requests.exceptions.RequestException as e:
        return {'success': False, 'error': str(e)}

def validate_email(email):
    pattern = r'^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$'
    return re.match(pattern, email) is not None

def validate_password(password):
    return len(password) >= 8

# Usage
result = create_user(
    api_key='YOUR_API_KEY',
    api_url='https://your-domain.com/api/api.php',
    username='john_doe',
    password='SecurePass123',
    email='[email protected]',
    first_name='John',
    last_name='Doe'
)

print(result)

Server API

Manage game servers

Authentication

API authentication guide

Build docs developers (and LLMs) love