👤 User Profile Explorer
Complete user profile management and account information testing environment. Manage user data, sessions, and preferences.
🔍 Get User Profile
Retrieve current user information:
https://api.swapbits.co/users/mecurl -X GET 'https://api.swapbits.co/users/me' \
-H 'Authorization: Bearer YOUR_TOKEN' \
-H 'Content-Type: application/json'📱 Device Management
List User Devices
https://api.swapbits.co/users/devicescurl -X GET 'https://api.swapbits.co/users/devices' \
-H 'Authorization: Bearer YOUR_TOKEN' \
-H 'Content-Type: application/json'Delete Specific Device
https://api.swapbits.co/users/devicesRemove a specific device from account
Autenticación
Parámetros
ID of the device to remove
Comando cURL
curl -X DELETE 'https://api.swapbits.co/users/devices' \
-H 'Content-Type: application/json'Delete All Devices
https://api.swapbits.co/users/delete-all-devicecurl -X DELETE 'https://api.swapbits.co/users/delete-all-device' \
-H 'Authorization: Bearer YOUR_TOKEN' \
-H 'Content-Type: application/json'🔄 Session Management
Refresh Session Token
https://api.swapbits.co/users/refresh-sessioncurl -X POST 'https://api.swapbits.co/users/refresh-session' \
-H 'Authorization: Bearer YOUR_TOKEN' \
-H 'Content-Type: application/json'Authorize Session
https://api.swapbits.co/users/authorize-sessionAuthorize a session with additional verification
Autenticación
Parámetros
Session ID to authorize
Verification code (if required)
Comando cURL
curl -X POST 'https://api.swapbits.co/users/authorize-session' \
-H 'Content-Type: application/json'Authorize Account Unblock
https://api.swapbits.co/users/authorize-unblockAuthorize account unblock request
Autenticación
Parámetros
Reason for unblock request
Additional information
Comando cURL
curl -X POST 'https://api.swapbits.co/users/authorize-unblock' \
-H 'Content-Type: application/json'🚪 Logout
Logout from Current Session
https://api.swapbits.co/users/logoutcurl -X POST 'https://api.swapbits.co/users/logout' \
-H 'Authorization: Bearer YOUR_TOKEN' \
-H 'Content-Type: application/json'🆘 Support
Contact Support
https://api.swapbits.co/users/contact-supportSend a message to support team
Autenticación
Parámetros
Subject of the support request
Detailed message describing the issue
Support category
Comando cURL
curl -X POST 'https://api.swapbits.co/users/contact-support' \
-H 'Content-Type: application/json'Get FAQs
https://api.swapbits.co/users/faqscurl -X GET 'https://api.swapbits.co/users/faqs' \
-H 'Content-Type: application/json'Response Scenarios
User Profile
✅ Profile Retrieved (Code 1000)
User profile data returned successfully.
{
"code": 1000,
"message": "User profile retrieved",
"data": {
"user": {
"id": "user-uuid-v4",
"email": "user@example.com",
"name": "John Doe",
"verified": true,
"phone": "+1234567890",
"phoneVerified": true,
"country": "US",
"language": "en",
"twoFactorEnabled": true,
"pinEnabled": false,
"createdAt": "2024-01-01T00:00:00Z",
"lastLoginAt": "2024-01-15T10:30:00Z",
"kycStatus": "verified",
"accountStatus": "active",
"preferences": {
"notifications": true,
"newsletter": false,
"theme": "light"
}
}
}
}
Device Management
📱 Devices List (Code 1000)
Active devices for the user account.
{
"code": 1000,
"message": "Devices retrieved",
"data": {
"devices": [
{
"id": "device-uuid-1",
"name": "iPhone 15 Pro",
"type": "mobile",
"os": "iOS 17.2",
"browser": "Safari",
"ip": "192.168.1.100",
"location": "New York, US",
"lastActive": "2024-01-15T10:30:00Z",
"current": true,
"trusted": true
},
{
"id": "device-uuid-2",
"name": "MacBook Pro",
"type": "desktop",
"os": "macOS 14.2",
"browser": "Chrome",
"ip": "192.168.1.101",
"location": "New York, US",
"lastActive": "2024-01-14T15:20:00Z",
"current": false,
"trusted": true
}
],
"totalDevices": 2
}
}
✅ Device Deleted (Code 1000)
Device successfully removed from account.
{
"code": 1000,
"message": "Device deleted successfully",
"data": {
"deviceId": "device-uuid-to-delete",
"deviceName": "Old iPhone",
"deletedAt": "2024-01-15T10:30:00Z",
"remainingDevices": 1
}
}
Session Management
🔄 Session Refreshed (Code 1000)
New access token generated successfully.
{
"code": 1000,
"message": "Session refreshed",
"data": {
"accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"refreshToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"expiresIn": 3600,
"tokenType": "Bearer"
}
}
Support
📧 Support Message Sent (Code 1000)
Support request submitted successfully.
{
"code": 1000,
"message": "Support request submitted",
"data": {
"ticketId": "SUPPORT-12345",
"subject": "Account Issue",
"status": "open",
"expectedResponse": "24-48 hours",
"submittedAt": "2024-01-15T10:30:00Z"
}
}
💻 Integration Examples
JavaScript/TypeScript
interface UserProfile {
id: string;
email: string;
name: string;
verified: boolean;
phone?: string;
phoneVerified: boolean;
country: string;
language: string;
twoFactorEnabled: boolean;
pinEnabled: boolean;
kycStatus: string;
accountStatus: string;
}
interface Device {
id: string;
name: string;
type: 'mobile' | 'desktop' | 'tablet';
os: string;
browser: string;
ip: string;
location: string;
lastActive: string;
current: boolean;
trusted: boolean;
}
class SwapBitsUserManager {
private baseUrl = 'https://api.swapbits.co';
private accessToken: string;
constructor(accessToken: string) {
this.accessToken = accessToken;
}
private getAuthHeaders() {
return {
'Authorization': `Bearer ${this.accessToken}`,
'Content-Type': 'application/json',
};
}
async getProfile(): Promise<UserProfile> {
const response = await fetch(`${this.baseUrl}/users/me`, {
headers: this.getAuthHeaders(),
});
const result = await response.json();
if (result.code === 1000) {
return result.data.user;
} else {
throw new Error(`Failed to get profile: ${result.message} (Code: ${result.code})`);
}
}
async getDevices(): Promise<Device[]> {
const response = await fetch(`${this.baseUrl}/users/devices`, {
headers: this.getAuthHeaders(),
});
const result = await response.json();
if (result.code === 1000) {
return result.data.devices;
} else {
throw new Error(`Failed to get devices: ${result.message} (Code: ${result.code})`);
}
}
async deleteDevice(deviceId: string): Promise<boolean> {
const response = await fetch(`${this.baseUrl}/users/devices`, {
method: 'DELETE',
headers: this.getAuthHeaders(),
body: JSON.stringify({ deviceId }),
});
const result = await response.json();
if (result.code === 1000) {
console.log(`Device ${result.data.deviceName} deleted successfully`);
console.log(`Remaining devices: ${result.data.remainingDevices}`);
return true;
} else {
throw new Error(`Failed to delete device: ${result.message} (Code: ${result.code})`);
}
}
async deleteAllDevices(): Promise<boolean> {
const response = await fetch(`${this.baseUrl}/users/delete-all-device`, {
method: 'DELETE',
headers: this.getAuthHeaders(),
});
const result = await response.json();
if (result.code === 1000) {
console.log('All devices deleted successfully');
return true;
} else {
throw new Error(`Failed to delete all devices: ${result.message} (Code: ${result.code})`);
}
}
async refreshSession(): Promise<{ accessToken: string; refreshToken: string }> {
const response = await fetch(`${this.baseUrl}/users/refresh-session`, {
method: 'POST',
headers: this.getAuthHeaders(),
});
const result = await response.json();
if (result.code === 1000) {
// Update stored token
this.accessToken = result.data.accessToken;
return {
accessToken: result.data.accessToken,
refreshToken: result.data.refreshToken,
};
} else {
throw new Error(`Failed to refresh session: ${result.message} (Code: ${result.code})`);
}
}
async logout(): Promise<boolean> {
const response = await fetch(`${this.baseUrl}/users/logout`, {
method: 'POST',
headers: this.getAuthHeaders(),
});
const result = await response.json();
if (result.code === 1000) {
console.log('Logged out successfully');
this.accessToken = ''; // Clear token
return true;
} else {
throw new Error(`Failed to logout: ${result.message} (Code: ${result.code})`);
}
}
async contactSupport(subject: string, message: string, category?: string): Promise<string> {
const response = await fetch(`${this.baseUrl}/users/contact-support`, {
method: 'POST',
headers: this.getAuthHeaders(),
body: JSON.stringify({
subject,
message,
category: category || 'general',
}),
});
const result = await response.json();
if (result.code === 1000) {
console.log(`Support ticket created: ${result.data.ticketId}`);
console.log(`Expected response: ${result.data.expectedResponse}`);
return result.data.ticketId;
} else {
throw new Error(`Failed to contact support: ${result.message} (Code: ${result.code})`);
}
}
async getFAQs(): Promise<any[]> {
const response = await fetch(`${this.baseUrl}/users/faqs`);
const result = await response.json();
if (result.code === 1000) {
return result.data.faqs;
} else {
throw new Error(`Failed to get FAQs: ${result.message} (Code: ${result.code})`);
}
}
}
// Usage examples
const userManager = new SwapBitsUserManager('your-access-token');
// Get user profile
try {
const profile = await userManager.getProfile();
console.log('User profile:', profile);
console.log(`Welcome ${profile.name}!`);
console.log(`Account status: ${profile.accountStatus}`);
console.log(`2FA enabled: ${profile.twoFactorEnabled}`);
} catch (error) {
console.error('Failed to get profile:', error.message);
}
// Manage devices
try {
const devices = await userManager.getDevices();
console.log(`You have ${devices.length} active devices:`);
devices.forEach(device => {
console.log(`- ${device.name} (${device.type}) - ${device.current ? 'Current' : 'Other'}`);
console.log(` Last active: ${device.lastActive}`);
});
// Delete old device
const oldDevice = devices.find(d => !d.current && !d.trusted);
if (oldDevice) {
await userManager.deleteDevice(oldDevice.id);
}
} catch (error) {
console.error('Failed to manage devices:', error.message);
}
// Refresh session when token expires
try {
const tokens = await userManager.refreshSession();
localStorage.setItem('accessToken', tokens.accessToken);
localStorage.setItem('refreshToken', tokens.refreshToken);
} catch (error) {
console.error('Failed to refresh session:', error.message);
// Redirect to login
}
// Contact support
try {
const ticketId = await userManager.contactSupport(
'Account Access Issue',
'I am unable to access certain features of my account. Please help.',
'account'
);
console.log(`Support ticket created: ${ticketId}`);
} catch (error) {
console.error('Failed to contact support:', error.message);
}
Python
import requests
from typing import Dict, Any, List, Optional
class SwapBitsUserManager:
def __init__(self, access_token: str):
self.base_url = 'https://api.swapbits.co'
self.access_token = access_token
def _get_auth_headers(self) -> Dict[str, str]:
"""Get authentication headers"""
return {
'Authorization': f'Bearer {self.access_token}',
'Content-Type': 'application/json'
}
def get_profile(self) -> Dict[str, Any]:
"""Get user profile information"""
response = requests.get(
f'{self.base_url}/users/me',
headers=self._get_auth_headers()
)
result = response.json()
if result['code'] == 1000:
return result['data']['user']
else:
raise Exception(f"Failed to get profile: {result['message']} (Code: {result['code']})")
def get_devices(self) -> List[Dict[str, Any]]:
"""Get list of user devices"""
response = requests.get(
f'{self.base_url}/users/devices',
headers=self._get_auth_headers()
)
result = response.json()
if result['code'] == 1000:
return result['data']['devices']
else:
raise Exception(f"Failed to get devices: {result['message']} (Code: {result['code']})")
def delete_device(self, device_id: str) -> bool:
"""Delete a specific device"""
response = requests.delete(
f'{self.base_url}/users/devices',
headers=self._get_auth_headers(),
json={'deviceId': device_id}
)
result = response.json()
if result['code'] == 1000:
print(f"Device {result['data']['deviceName']} deleted successfully")
print(f"Remaining devices: {result['data']['remainingDevices']}")
return True
else:
raise Exception(f"Failed to delete device: {result['message']} (Code: {result['code']})")
def delete_all_devices(self) -> bool:
"""Delete all user devices"""
response = requests.delete(
f'{self.base_url}/users/delete-all-device',
headers=self._get_auth_headers()
)
result = response.json()
if result['code'] == 1000:
print("All devices deleted successfully")
return True
else:
raise Exception(f"Failed to delete all devices: {result['message']} (Code: {result['code']})")
def refresh_session(self) -> Dict[str, str]:
"""Refresh access token"""
response = requests.post(
f'{self.base_url}/users/refresh-session',
headers=self._get_auth_headers()
)
result = response.json()
if result['code'] == 1000:
# Update stored token
self.access_token = result['data']['accessToken']
return {
'access_token': result['data']['accessToken'],
'refresh_token': result['data']['refreshToken']
}
else:
raise Exception(f"Failed to refresh session: {result['message']} (Code: {result['code']})")
def logout(self) -> bool:
"""Logout from current session"""
response = requests.post(
f'{self.base_url}/users/logout',
headers=self._get_auth_headers()
)
result = response.json()
if result['code'] == 1000:
print("Logged out successfully")
self.access_token = '' # Clear token
return True
else:
raise Exception(f"Failed to logout: {result['message']} (Code: {result['code']})")
def contact_support(self, subject: str, message: str, category: str = 'general') -> str:
"""Send support request"""
response = requests.post(
f'{self.base_url}/users/contact-support',
headers=self._get_auth_headers(),
json={
'subject': subject,
'message': message,
'category': category
}
)
result = response.json()
if result['code'] == 1000:
print(f"Support ticket created: {result['data']['ticketId']}")
print(f"Expected response: {result['data']['expectedResponse']}")
return result['data']['ticketId']
else:
raise Exception(f"Failed to contact support: {result['message']} (Code: {result['code']})")
def get_faqs(self) -> List[Dict[str, Any]]:
"""Get frequently asked questions"""
response = requests.get(f'{self.base_url}/users/faqs')
result = response.json()
if result['code'] == 1000:
return result['data']['faqs']
else:
raise Exception(f"Failed to get FAQs: {result['message']} (Code: {result['code']})")
# Usage examples
user_manager = SwapBitsUserManager('your-access-token')
# Get profile
try:
profile = user_manager.get_profile()
print(f"Welcome {profile['name']}!")
print(f"Email: {profile['email']}")
print(f"Account verified: {profile['verified']}")
print(f"2FA enabled: {profile['twoFactorEnabled']}")
print(f"KYC status: {profile['kycStatus']}")
except Exception as e:
print(f"Failed to get profile: {e}")
# Manage devices
try:
devices = user_manager.get_devices()
print(f"\nYou have {len(devices)} active devices:")
for device in devices:
status = "Current" if device['current'] else "Other"
trusted = "Trusted" if device['trusted'] else "Untrusted"
print(f"- {device['name']} ({device['type']}) - {status}, {trusted}")
print(f" OS: {device['os']}, Browser: {device['browser']}")
print(f" Location: {device['location']}")
print(f" Last active: {device['lastActive']}")
# Delete untrusted devices
untrusted_devices = [d for d in devices if not d['trusted'] and not d['current']]
for device in untrusted_devices:
user_manager.delete_device(device['id'])
except Exception as e:
print(f"Failed to manage devices: {e}")
# Contact support
try:
ticket_id = user_manager.contact_support(
subject="Account Access Issue",
message="I'm having trouble accessing certain features. Please help.",
category="account"
)
print(f"\nSupport ticket created: {ticket_id}")
except Exception as e:
print(f"Failed to contact support: {e}")
🔗 Related Explorers
- 🔐 Authentication Explorer - Login and authentication flows
- 🛡️ 2FA Explorer - Two-factor authentication management
- 🔑 Password Reset Explorer - Password recovery
- 💳 Banking Explorer (Coming Soon) - Financial account management
🆘 Troubleshooting
🔧 Common User Management Issues & Solutions
Problem: "Unauthorized" errors Solution: Check access token validity, refresh session if expired
Problem: Can't delete current device Solution: Current device cannot be deleted, use another device to remove it
Problem: Session refresh fails Solution: Use refresh token, or re-authenticate if refresh token expired
Problem: Support ticket not created Solution: Ensure message is not empty, check required fields
Problem: Profile shows outdated information Solution: Information updates may take time to propagate, try refreshing
Problem: Device list not updating Solution: Clear cache, re-authenticate, or wait for sync