توثيق API

دليل الاستخدام

المحتويات

نظرة عامة

الـ API ده بيسمحلك تبعت رسائل SMS برمجيًا من أي تطبيق (PHP, Python, Node.js, etc.).

💡 Base URL: https://dark.x-esm.com/api.php

المميزات

المصادقة

كل طلب لازم يبعت API Key في الـ header:

X-API-Key: sk_live_xxxxxxxxxxxxxxxxxxxxxxxxxx
⚠️ تحذير: الـ API Key بتاعك حساس — متشاركهوش مع حد. لو اتكشف، اعمل Regenerate من لوحة API.

إرسال SMS

POST https://dark.x-esm.com/api.php

Parameters (Body - JSON)

Parameter Type Required Description
numbers array ✅ قائمة الأرقام (1-100 رقم). مثال: ["201012345678"]
message string ✅ نص الرسالة
sender_id string ❌ اسم المرسل. لو مش محدد، هيستخدم الافتراضي
provider string ❌ السيرفر (server1, rund2). لو مش محدد، هيستخدم أول سيرفر متاح
country_code string ❌ كود الدولة (افتراضي: +20)

أمثلة

curl -X POST https://dark.x-esm.com/api.php \ -H "X-API-Key: YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "numbers": ["201012345678", "201112223333"], "message": "Hello from API!", "sender_id": "MyBrand", "provider": "rund2" }'
<?php $api_key = 'YOUR_API_KEY'; $data = [ 'numbers' => ['201012345678', '201112223333'], 'message' => 'Hello from API!', 'sender_id' => 'MyBrand', 'provider' => 'rund2' ]; $ch = curl_init(); curl_setopt_array($ch, [ CURLOPT_URL => 'https://dark.x-esm.com/api.php', CURLOPT_HTTPHEADER => [ 'X-API-Key: ' . $api_key, 'Content-Type: application/json' ], CURLOPT_RETURNTRANSFER => true, CURLOPT_POST => true, CURLOPT_POSTFIELDS => json_encode($data), CURLOPT_SSL_VERIFYPEER => false, CURLOPT_TIMEOUT => 60 ]); $response = curl_exec($ch); $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); $result = json_decode($response, true); if ($result['success']) { echo "✅ تم الإرسال: {$result['sent']} رسالة\n"; echo "💰 التكلفة: \${$result['cost']}\n"; echo "💳 الرصيد: \${$result['balance']}\n"; } else { echo "❌ فشل: {$result['error']} — {$result['message']}\n"; } ?>
import requests API_KEY = 'YOUR_API_KEY' URL = 'https://dark.x-esm.com/api.php' data = { 'numbers': ['201012345678', '201112223333'], 'message': 'Hello from API!', 'sender_id': 'MyBrand', 'provider': 'rund2' } headers = { 'X-API-Key': API_KEY, 'Content-Type': 'application/json' } response = requests.post(URL, json=data, headers=headers) result = response.json() if result.get('success'): print(f"✅ تم الإرسال: {result['sent']} رسالة") print(f"💰 التكلفة: ${result['cost']}") print(f"💳 الرصيد: ${result['balance']}") else: print(f"❌ فشل: {result.get('error')} — {result.get('message')}")
const API_KEY = 'YOUR_API_KEY'; const URL = 'https://dark.x-esm.com/api.php'; const data = { numbers: ['201012345678', '201112223333'], message: 'Hello from API!', sender_id: 'MyBrand', provider: 'rund2' }; fetch(URL, { method: 'POST', headers: { 'X-API-Key': API_KEY, 'Content-Type': 'application/json' }, body: JSON.stringify(data) }) .then(res => res.json()) .then(result => { if (result.success) { console.log(`✅ تم الإرسال: ${result.sent} رسالة`); console.log(`💰 التكلفة: $${result.cost}`); console.log(`💳 الرصيد: $${result.balance}`); } else { console.error(`❌ فشل: ${result.error} — ${result.message}`); } }) .catch(err => console.error('❌ خطأ:', err));

الرد (Response)

✅ نجاح (HTTP 200)

{ "success": true, "sent": 2, "failed": 0, "total": 2, "cost": 0.10, "balance": 9.90, "price_per_sms": 0.05, "provider": "rund2", "sender_id": "MyBrand", "message_id": "abc123...", "delivery_status": "pending", "duration_ms": 1234 }

❌ فشل

{ "success": false, "error": "insufficient_balance", "message": "Insufficient API balance", "required": 0.10, "available": 0.05, "price_per_sms": 0.05, "duration_ms": 50 }

شرح الحقول

Field Type Description
successbooleanهل العملية نجحت
sentintegerعدد الرسايل اللي اتبعتت
failedintegerعدد الرسايل اللي فشلت
totalintegerإجمالي الأرقام المرسلة
costfloatالتكلفة بالدولار
balancefloatالرصيد بعد الإرسال
price_per_smsfloatسعر الرسالة المستخدم في العملية
providerstringالسيرفر المستخدم
sender_idstringاسم المرسل
message_idstring|nullمعرّف الرسالة (لو متاح)
delivery_statusstringحالة التسليم (pending, delivered, undelivered)
duration_msintegerمدة الطلب بالمللي ثانية

الأخطاء

Error Code HTTP Description
missing_api_key 401 الـ X-API-Key header مش موجود
invalid_api_key 401 الـ API Key غلط أو معطل
account_suspended 403 الحساب محظور
api_disabled 403 API مش مفعّل للحساب
no_servers 403 مفيش سيرفرات متاحة
sender_not_allowed 403 Sender ID مش مسموح
insufficient_balance 402 الرصيد مش كافي
rate_limit_exceeded 429 تجاوزت Rate Limit (60/دقيقة)
invalid_json 400 Body مش JSON صالح
missing_numbers 400 حقل numbers ناقص
missing_message 400 حقل message ناقص
too_many_numbers 400 أكتر من 100 رقم
invalid_numbers 400 مفيش أرقام صالحة
method_not_allowed 405 Method مش POST

Rate Limits

الميزة الحد
عدد الطلبات60 طلب/دقيقة
أقصى أرقام في الطلب100 رقم
أقصى طول للرسالة60 حرف (رسالة واحدة) — أكتر بيتقسم لأجزاء
💡 نصيحة: لو عايز تبعت أرقام كتير، قسّمهم على طلبات (كل طلب 100 رقم).

التسعير

الميزة السعر
رسالة SMS واحدة (حتى 60 حرف) $0.5000
رسالة طويلة (أكتر من 60 حرف) $0.5000 × عدد الأجزاء
💰 نظام الرصيد:
  • الرصيد بالدولار
  • بيتخصم بعد الإرسال الناجح بس
  • لو الرسالة فشلت (undelivered)، التكلفة بترجع تلقائيًا (قريبًا)

للمساعدة، تواصل مع الإدارة أو راجع لوحة API.