Skip to main content

Get User Profile

Retrieve the full user profile for the authenticated user.
curl -X GET https://api.cryptoshop.com/api/users/profile \
  -H "Authorization: Bearer YOUR_TOKEN"

Response

success
boolean
required
Indicates if the request was successful
user
object
required
Complete user profile object
{
  "success": true,
  "user": {
    "_id": "648a1234567890abcdef5678",
    "email": "[email protected]",
    "username": "john_doe",
    "role": "user",
    "wallet": {
      "address": "TGzz8gjYiYRqpfmDwnLxfgPuLVNmpCswVp"
    },
    "phone": "+1234567890",
    "country": "US",
    "twoFactorEnabled": false,
    "isActive": true,
    "lastLogin": "2024-03-15T10:30:00.000Z",
    "createdAt": "2024-01-01T00:00:00.000Z",
    "updatedAt": "2024-03-15T10:30:00.000Z"
  }
}
The response includes all user fields except the password and wallet private key for security.

Update User Profile

Update profile information such as username, phone, or country.
curl -X PUT https://api.cryptoshop.com/api/users/profile \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "username": "new_username",
    "phone": "+1234567890",
    "country": "US"
  }'

Request Body

username
string
New username (must be unique, min 3 characters)
phone
string
User’s phone number
country
string
User’s country code

Response

success
boolean
required
Indicates if the request was successful
message
string
required
Success message
user
object
required
Updated user object (see structure above)
{
  "success": true,
  "message": "Profile updated successfully",
  "user": {
    "_id": "648a1234567890abcdef5678",
    "email": "[email protected]",
    "username": "new_username",
    "phone": "+1234567890",
    "country": "US",
    "role": "user",
    "wallet": {
      "address": "TGzz8gjYiYRqpfmDwnLxfgPuLVNmpCswVp"
    },
    "createdAt": "2024-01-01T00:00:00.000Z",
    "updatedAt": "2024-03-15T11:00:00.000Z"
  }
}

Error Responses

{
  "success": false,
  "error": "Username already exists"
}
Changing the username requires it to be unique across the system. If the username is already taken, the request will fail.

Update Password

Change the user’s password. Requires the current password for verification.
curl -X PUT https://api.cryptoshop.com/api/users/password \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "currentPassword": "old_password",
    "newPassword": "new_secure_password"
  }'

Request Body

currentPassword
string
required
Current password for verification
newPassword
string
required
New password (minimum 8 characters)

Response

success
boolean
required
Indicates if the request was successful
message
string
required
Success message
{
  "success": true,
  "message": "Password updated successfully"
}

Error Responses

{
  "success": false,
  "error": "Current and new password are required"
}
Password changes are immediate. The user will need to log in again with the new password on other devices.

Connect External Wallet

Connect an external TRON wallet to the user’s account.
curl -X POST https://api.cryptoshop.com/api/users/wallet/connect \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "walletAddress": "TXyza9876543210zyxwvutsrqponmlkjih"
  }'

Request Body

walletAddress
string
required
The TRON wallet address to connect

Response

success
boolean
required
Indicates if the request was successful
message
string
required
Success message
{
  "success": true,
  "message": "Wallet connected successfully"
}
This endpoint allows users to connect external wallets for additional payment options or verification purposes.

Authentication

All user profile management endpoints require authentication via JWT Bearer token in the Authorization header.
Authorization: Bearer YOUR_ACCESS_TOKEN

Source Code References

  • User routes: src/api/users/index.js
  • Get profile: src/api/users/getProfile.js
  • Update profile: src/api/users/updateProfile.js
  • Update password: src/api/users/updatePassword.js
  • Connect wallet: src/api/users/connectWallet.js

Build docs developers (and LLMs) love