Skip to content

User Registration API

Used to implement user registration functionality. Supports passing parameters via GET or POST methods. Required information includes application ID and user account. Optional extended information such as QQ and email can be passed. The application signature is obtained directly from the backend.

Request URL GET / POST

http
https://nobase.cn/api/user/register

Request Parameters

ParameterTypeRequiredDescription
appidstring✅ YesApplication ID, the unique identifier of the application obtained from the developer center
signaturestring✅ YesApplication signature, obtained directly from the backend (no manual generation needed, bound to appid)
userstring✅ YesUser account, unique identifier used for login (such as phone number, username)
passstring✅ YesUser password, recommended to be MD5 encrypted before passing
nicknamestring✅ YesUser nickname, name used for display (supports Chinese, special symbols)
qqstring❌ NoUser QQ number, optional, used for account association or recovery
emailstring❌ NoEmail address, optional, used for account verification or password recovery
imagstring❌ NoAvatar link, needs to be used with an image hosting service, optional (default avatar will be used if not provided)

Response Example

Success Response (Registration Successful)

json
{
  "code": 200,
  "msg": "success",
  "data": "Registration successful"
}

Failure Response (Account already exists/Application does not exist)

json
{ 
  "code": 404, 
  "msg": "fail", 
  "data": "This account has already been registered!" 
}
json
{ 
  "code": 404, 
  "msg": "Application does not exist" 
}

Response Data Structure

ParameterTypeDescription
codenumberStatus code: 200=Registration successful, 400=Parameter error/Business failure, 500=System error
msgstringStatus description: success=Success, fail=Failure
datastringResponse information: Returns "Registration successful" on success, returns specific error reason on failure (such as "Account already exists", "Signature error")

Code Example

javascript
// 1. Configure parameters (required fields need to be replaced with actual values, signature obtained from backend)
const appid = "your_app_id"; // Application ID (required)
const signature = "your_signature_from_backend"; // Application signature (obtained from backend, required)
const user = "user123456"; // User account (required)
const pass = md5("user_password123"); // User password (MD5 encrypted, required, need to import md5 library first)
const nickname = "User Nickname"; // User nickname (required)
// Optional parameters (do not pass if not available)
const qq = "123456789";
const email = "user@example.com";
const imag = "https://example.com/avatar.jpg";

// 2. Concatenate GET parameters (handle optional parameters, do not add if not available)
const params = new URLSearchParams({
  appid,
  signature,
  user,
  pass,
  nickname
});
if (qq) params.append('qq', qq);
if (email) params.append('email', email);
if (imag) params.append('imag', imag);

// 3. Initiate GET request
const requestUrl = `https://nobase.cn/api/user/register?${params.toString()}`;
fetch(requestUrl)
  .then(response => {
    if (!response.ok) throw new Error(`HTTP Error: ${response.status}`);
    return response.json();
  })
  .then(res => {
    if (res.code === 200) {
      console.log("Registration result:", res.data); // Output "Registration successful"
    } else {
      console.error("Registration failed:", res.data); // Output specific error
    }
  })
  .catch(error => console.error("Request exception:", error));
javascript
// 1. Configure parameters (same as GET, signature obtained from backend)
const appid = "your_app_id";
const signature = "your_signature_from_backend";
const user = "user123456";
const pass = md5("user_password123");
const nickname = "User Nickname";

// 2. Initiate POST request
fetch('https://nobase.cn/api/user/register', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/x-www-form-urlencoded'
  },
  body: new URLSearchParams({
    appid,
    signature,
    user,
    pass,
    nickname
  })
})
.then(response => response.json())
.then(res => {
  if (res.code === 200) {
    console.log("Registration successful:", res.data);
  } else {
    console.error("Registration failed:", res.data);
  }
});
python
import requests
import hashlib

# Configuration parameters
appid = "your_app_id"
signature = "your_signature_from_backend"
user = "user123456"
pass = hashlib.md5("user_password123".encode()).hexdigest()  # MD5 encryption
nickname = "User Nickname"

url = "https://nobase.cn/api/user/register"
params = {
    "appid": appid,
    "signature": signature,
    "user": user,
    "pass": pass,
    "nickname": nickname
}

response = requests.get(url, params=params)
res_data = response.json()

if res_data["code"] == 200:
    print(f"Registration successful: {res_data['data']}")
else:
    print(f"Registration failed: {res_data['data']}")

Precautions

  1. Password Security: Although MD5 encryption is recommended, please use HTTPS for transmission to ensure security.
  2. Account Uniqueness: The account must be unique within the same application. Duplicate registration will return an error.
  3. Signature Validity: Please ensure obtaining the correct signature from the backend. An incorrect signature will cause registration to fail.
  4. Avatar Link: The avatar needs to use a complete URL address. It is recommended to use an image hosting service to store images.