π Your API Key
Base URL: https://wanice.xyz/api/v1
π‘οΈ API Key bhejne ke 3 tareeke
Teenon chalte hain. Header sabse behtar hai (URL/log me key nahi jaati).
1. Header me (Recommended)
Authorization: Bearer YOUR_API_KEY2. X-API-Key header me
X-API-Key: YOUR_API_KEY3. Body / URL me
{
"api_key": "YOUR_API_KEY",
"to": "9876543210",
"message": "Namaste!"
}Har jawab ka roop
{ "status": "success", "data": { ... }, "message": "..." }
{ "status": "error", "message": "...", "error_code": "..." }π Endpoints
π¬ Message bhejna
POST https://wanice.xyz/api/v1/send.php Β· haq: message
| Parameter | Zaroori | Matlab |
|---|---|---|
to | haan* | 10-digit mobile. Us number se 1:1 chat khud ban jaata hai. |
conversation_id | haan* | Pehle se maujood chat/group ka id (aap usme member hon). |
message | haan | Text, 4000 characters tak. |
* to ya conversation_id β koi ek zaroori hai.
cURL
curl -X POST "https://wanice.xyz/api/v1/send.php" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"to":"9876543210","message":"Aapka order taiyar hai β
"}'Jawab
{
"status": "success",
"data": {
"message_id": 42,
"conversation_id": 17,
"from": "9199998860",
"to": "9876543210",
"sent_at": "2026-07-26 11:23:12"
},
"message": "Message bhej diya gaya"
}π OTP bhejna aur jaanchna
Haq: otp. OTP isi server par banta hai β aapko kabhi nahi bheja jaata (warna OTP ka matlab hi khatam).
1. Bhejo β POST /otp_send.php
| Parameter | Zaroori | Matlab |
|---|---|---|
mobile | haan | 10-digit number |
purpose | nahi | Sirf log ke liye label (jaise signup) |
curl -X POST "https://wanice.xyz/api/v1/otp_send.php" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"mobile":"9876543210","purpose":"signup"}'{ "status":"success", "data":{ "mobile":"9876543210", "channel":"whatsapp", "expires_in":600, "otp_length":6 } }channel batata hai OTP kis raaste gaya β sms ya whatsapp.
Ye admin ki setting se apne aap tay hota hai (SMS na pahunche to WhatsApp).
2. Jaancho β POST /otp_verify.php
curl -X POST "https://wanice.xyz/api/v1/otp_verify.php" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"mobile":"9876543210","otp":"123456"}'{ "status":"success", "data":{ "verified":true, "has_account":true, "user":{...} } }Haddein: ek number par 45 second me ek OTP, ek ghante me 5, aur 5 galat koshish ke baad OTP band.
π€ Account banana aur Login (SSO)
Haq: account
POST /register.php
| Parameter | Zaroori | Matlab |
|---|---|---|
mobile | haan | 10-digit number (yahi username banta hai) |
name | haan | Dikhne wala naam, 1-50 characters |
password | nahi | Diya to user password se bhi login kar sakega (min 4) |
curl -X POST "https://wanice.xyz/api/v1/register.php" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"mobile":"9876543210","name":"Ramesh Kumar","password":"secret123"}'Number pehle se ho to 409 + ALREADY_EXISTS aata hai (uske saath wahi user bhi).
POST /login.php β ek-click login link
mobile + (password ya otp) bhejein. Jawab me
login_url milta hai β user ko us link par bhej dein, wo seedha
logged-in chat me pahunch jaata hai. Aapki website par password rakhne ki
zarurat nahi.
curl -X POST "https://wanice.xyz/api/v1/login.php" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"mobile":"9876543210","password":"secret123"}'{
"status": "success",
"data": {
"user": { "id": 57, "mobile": "9876543210", "display_name": "Ramesh Kumar" },
"login_url": "https://wanice.xyz/api/v1/sso.php?t=β¦",
"expires_in": 300,
"one_time": true
}
}login_url 5 minute chalta hai aur sirf ek baar.
Isliye usay pehle se bana kar rakhna bekaar hai β jab user button dabaye tabhi banayein.
π± Mobile App ke liye (API key ke BINA)
In do endpoints par key nahi chahiye β user ka OTP hi uski pehchan hai.
1. POST /app_otp.php
curl -X POST "https://wanice.xyz/api/v1/app_otp.php" \
-H "Content-Type: application/json" \
-d '{"mobile":"9876543210"}'{ "status":"success", "data":{ "mobile":"9876543210", "channel":"whatsapp",
"is_new":true, "otp_length":6, "expires_in":600 } }is_new true ho to app naam bhi poochhta hai (naya account banega).
2. POST /app_login.php
| Parameter | Zaroori | Matlab |
|---|---|---|
mobile | haan | Wahi number jispar OTP gaya |
otp | haan | User ne jo daala |
name | naye user ke liye | Naam (is_new = true par) |
device | nahi | Label β ek device ka ek token |
curl -X POST "https://wanice.xyz/api/v1/app_login.php" \
-H "Content-Type: application/json" \
-d '{"mobile":"9876543210","otp":"123456","name":"Ramesh","device":"android"}'{ "status":"success", "data":{
"token":"nc_β¦",
"user":{ "id":59, "mobile":"9876543210", "display_name":"Ramesh" }
} }token ko phone me sambhal kar rakhein aur aage har call me
Authorization: Bearer <token> bhejein. Token ke paas sirf
message + read ka haq hota hai β us se naya account banana ya
kisi aur ka OTP bhejna mumkin nahi. Token expire nahi hota; user "Logout" dabaye to app
usay bhula deta hai, aur admin panel se key OFF bhi ki ja sakti hai.
Hamara apna WA NICE Chats Android app bilkul yahi raasta use karta hai β poora native app, koi WebView nahi.
π₯ Chat padhna
Haq: read. Sirf unhi chats ka data milta hai jinka key wala account member hai.
GET /chats.php
curl "https://wanice.xyz/api/v1/chats.php?limit=30" -H "Authorization: Bearer YOUR_API_KEY"{ "status":"success", "data":{ "chats":[
{ "conversation_id":17, "type":"direct", "title":"Ramesh Kumar",
"unread":1, "last_message":"Aapka order taiyar hai", "last_message_at":"2026-07-26 11:23:12" }
], "count":1 } }GET /messages.php
| Parameter | Zaroori | Matlab |
|---|---|---|
conversation_id | haan | Kis chat ke message |
after | nahi | Is id ke BAAD wale β polling ke liye (default 0) |
limit | nahi | 1-200 (default 50) |
curl "https://wanice.xyz/api/v1/messages.php?conversation_id=17&after=0" \
-H "Authorization: Bearer YOUR_API_KEY"last_id yaad
rakhein aur agli baar after=last_id bhejein.
β οΈ Error Codes
| error_code | HTTP | Matlab |
|---|---|---|
MISSING_API_KEY | 401 | Key bheji nahi gayi |
INVALID_API_KEY | 401 | Key galat hai |
INACTIVE_KEY | 403 | Key band kar di gayi |
SCOPE_DENIED | 403 | Is key ko is kaam ka haq nahi |
INACTIVE_USER / USER_BLOCKED | 403 | Account block hai |
FORBIDDEN | 403 | Us conversation ka member nahi |
USER_NOT_FOUND | 404 | Is number ka account nahi hai |
ALREADY_EXISTS | 409 | Account pehle se hai |
INVALID_PARAMETERS | 422 | Koi parameter galat/khali |
INVALID_CREDENTIALS | 401 | Galat mobile/password/OTP |
OTP_NOT_FOUND / OTP_EXPIRED / OTP_INVALID | 410 / 401 | OTP ka masla |
COOLDOWN / RATE_LIMITED / TOO_MANY_ATTEMPTS | 429 | Bahut zyada koshish β ruk kar try karein |
GATEWAY_ERROR | 503 | SMS/WhatsApp gateway ne mana kar diya |
METHOD_NOT_ALLOWED | 405 | GET ki jagah POST chahiye |
SERVER_ERROR | 500 | Hamari taraf se dikkat |
π Ready Script β apni website me 2 minute me lagayein
Ye poori file apni PHP website par rakh dein. Key upar badal lein, bas.
<?php
// nicechat.php β Nice Chat API v1 ka ready helper
// Kisi bhi PHP website par chalega. Sirf API_KEY apni rakhein.
define('NICECHAT_KEY', 'YOUR_API_KEY');
define('NICECHAT_API', 'https://wanice.xyz/api/v1');
/**
* Ek call, saare endpoints ke liye.
* @return array ['ok'=>bool, 'data'=>array, 'message'=>string, 'code'=>string]
*/
function nicechat(string $endpoint, array $params = [], string $method = 'POST'): array
{
$url = rtrim(NICECHAT_API, '/') . '/' . ltrim($endpoint, '/');
$ch = curl_init();
$opts = [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 45,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . NICECHAT_KEY,
'Content-Type: application/json',
'Accept: application/json',
],
];
if (strtoupper($method) === 'POST') {
$opts[CURLOPT_POST] = true;
$opts[CURLOPT_POSTFIELDS] = json_encode($params);
} else {
$url .= (str_contains($url, '?') ? '&' : '?') . http_build_query($params);
}
curl_setopt_array($ch, $opts + [CURLOPT_URL => $url]);
$raw = curl_exec($ch);
curl_close($ch);
$j = json_decode((string) $raw, true) ?: [];
return [
'ok' => ($j['status'] ?? '') === 'success',
'data' => $j['data'] ?? [],
'message' => $j['message'] ?? 'Koi jawab nahi mila',
'code' => $j['error_code'] ?? '',
];
}
/* ---------------- istemal ke udaharan ---------------- */
// 1) Message bhejo
$r = nicechat('send.php', ['to' => '9876543210', 'message' => 'Aapka order taiyar hai']);
echo $r['ok'] ? "bheja gaya\n" : "fail: {$r['message']}\n";
// 2) OTP bhejo aur jaancho
nicechat('otp_send.php', ['mobile' => '9876543210', 'purpose' => 'signup']);
$v = nicechat('otp_verify.php', ['mobile' => '9876543210', 'otp' => $_POST['otp'] ?? '']);
if ($v['ok']) { /* number verify ho gaya */ }
// 3) Account banao, phir user ko seedha chat me bhejo
nicechat('register.php', ['mobile' => '9876543210', 'name' => 'Ramesh Kumar', 'password' => 'secret123']);
$l = nicechat('login.php', ['mobile' => '9876543210', 'password' => 'secret123']);
if ($l['ok']) { header('Location: ' . $l['data']['login_url']); exit; }
// 4) Chat padho
$c = nicechat('chats.php', ['limit' => 20], 'GET');
$m = nicechat('messages.php', ['conversation_id' => 17, 'after' => 0], 'GET');
Nice Chat API v1 · Home