وثائق soga-client-v1 API
مقدمة
soga-client-v1 هي مجموعة من واجهات جهة المستخدم التي يستخدمها عميل soga، وبعد أن تنفّذها اللوحة وفق الوثائق التالية يستطيع العميل تسجيل الدخول وعرض الاشتراك وشراء الباقات وإرسال التذاكر وغير ذلك.
إعداد base_url
يمكن تخصيص المسار، ويدمج العميل تلقائيًا base_url مع uri الواجهة عند الوصول إلى الواجهات، مثل https://www.website.com/your/custom/uri/api/v1/me
base_url=https://www.website.com/your/custom/uri/الاصطلاحات العامة
جميع الواجهات تنقل البيانات بتنسيق json، وتوضع معاملات واجهات GET في query
يحمل كل طلب ترويسات الطلب التالية
| Key | الوصف |
|---|---|
| Authorization | Bearer <access_token>، ويجب إرسالها في الواجهات التي تتطلب تسجيل الدخول، وتُعيد واجهتا تسجيل الدخول وإنشاء الحساب قيمة access_token |
| Accept-Language | لغة العميل، مثل zh-CN en-US، وتُعيد اللوحة نصوص التنبيه بهذه اللغة |
| User-Agent | اسم العميل وإصداره، مثل soga-client/1.2.0 (windows) |
رمز حالة HTTP في الوضع الطبيعي هو 200، ويُحدَّد نجاح الطلب بقيمة success في البيانات المُعادة
عند النجاح تكون success بقيمة true، وتوضع البيانات المُعادة في data
{
"success": true,
"data": {}
}في واجهات القوائم المقسّمة إلى صفحات، معاملات الطلب هي page (تبدأ من 1، والافتراضي 1) وpage_size (الافتراضي 20، والحد الأقصى 100)، وتتضمن البيانات المُعادة حقلًا إضافيًا هو pagination
{
"success": true,
"data": [],
"pagination": {
"page": 1,
"page_size": 20,
"total": 57 // total number of items
}
}عند الفشل تكون success بقيمة false، وتوضع معلومات الخطأ في error
{
"success": false,
"error": {
"message": "Incorrect email or password" // message text shown directly to the user
}
}الأخطاء التالية تتطلب معالجة خاصة من العميل، ويجب تضمين code في error
{
"success": false,
"error": {
"code": 1001,
"message": "Login expired, please log in again"
}
}| رمز الخطأ | الوصف |
|---|---|
| 1001 | لم يُسجَّل الدخول أو انتهت صلاحية تسجيل الدخول، فيمسح العميل حالة تسجيل الدخول ويعود إلى صفحة تسجيل الدخول |
في الأخطاء الأخرى يكفي إعادة message، ويعرضها العميل مباشرة
يتعرّف العميل كذلك على رموز حالة HTTP الشائعة، ويمكن للوحة أيضًا إعادة هذه الرموز مباشرة
| رمز حالة HTTP | معالجة العميل |
|---|---|
| 200 | يُحكم وفق success |
| 401 | مثل رمز الخطأ 1001، يمسح حالة تسجيل الدخول ويعود إلى صفحة تسجيل الدخول |
| 403 | ينبّه إلى عدم وجود صلاحية الوصول |
| 404 | ينبّه إلى أن اللوحة لا تدعم هذه الميزة |
| 429 | ينبّه إلى أن الطلبات متكررة أكثر من اللازم |
| 500 502 503 504 | ينبّه إلى وجود خطأ في الخادم ويطلب إعادة المحاولة لاحقًا |
عند رمز غير 200، إذا كانت البيانات المُعادة json وتتضمن error.message، تكون الأولوية لعرض error.message
اصطلاحات تنسيق البيانات
- الوقت دائمًا طابع زمني Unix، بالثواني
- المبالغ دائمًا أعداد صحيحة، والوحدة جزء من مئة من وحدة العملة
- حركة البيانات دائمًا أعداد صحيحة، بالبايت
- القيم المنطقية دائمًا
true/false - تُعاد
nullعند عدم وجود القيمة، وتُعاد[]عندما تكون القائمة فارغة
الواجهات التي تُعيد النجاح فقط دون بيانات تُعيد
{
"success": true
}الواجهات العامة
الواجهات التالية لا تتطلب تسجيل الدخول
الحصول على إعدادات الموقع GET <base_url>/api/v1/config
البيانات المُعادة
{
"success": true,
"data": {
"site_name": "Example",
"site_url": "https://www.website.com", // web panel URL
"tos_url": "https://www.website.com/tos", // terms of service, may be null
"currency": "CNY", // currency code
"currency_symbol": "¥", // currency symbol
"register": {
"enabled": true, // registration is open
"email_verify": true, // registration requires an email verification code
"invite_required": false, // registration requires an invite code
"email_whitelist": ["gmail.com", "qq.com"] // email suffixes allowed to register, [] means no restriction
},
"telegram": {
"enabled": true, // Telegram bot is enabled
"bot_username": "example_bot", // bot username, without @
"discuss_url": "https://t.me/example_group" // discussion group, may be null
},
"commission": {
"withdraw_enabled": true, // commission withdrawal is open
"withdraw_methods": ["Alipay", "USDT"], // withdrawal methods
"withdraw_minimum": 10000, // minimum withdrawal amount
"distribution_enabled": false, // three-tier distribution is enabled
"distribution_rates": [50, 30, 20] // distribution rates for tiers one to three, in percent
},
"features": { // feature switches, missing items are treated as false
"deposit": true, // balance top-up
"gift_card": true, // gift card redemption
"gift_card_preview": true, // gift card preview before redemption, redemption history
"telegram_unbind": true, // unbind Telegram
"new_period": true, // start a new period early after traffic is used up
"sessions": true // view and remove logged-in devices
}
}
}الحصول على قائمة الباقات GET <base_url>/api/v1/plans
تُعيد الباقات المتاحة للشراء. عند إرسال الطلب مع Authorization، تُعاد باقة الاشتراك الحالي أيضًا حتى لو أُوقف بيعها، ما دام تجديدها مسموحًا
البيانات المُعادة
{
"success": true,
"data": [
{
"id": 1,
"name": "Annual Plan",
"content": "<p>100 GB traffic</p>", // plan description, HTML, may be null
"transfer_enable": 107374182400, // traffic per period, in bytes
"device_limit": 3, // device limit, null means unlimited
"speed_limit": null, // speed limit in Mbps, null means unlimited
"sold_out": false, // sold out, no new purchases
"prices": [ // purchasable periods and prices, periods that are not offered are not returned
{ "period": "month", "amount": 1500 },
{ "period": "year", "amount": 15000 },
{ "period": "reset_traffic", "amount": 500 }
]
}
]
}القيم الممكنة لـ period: month quarter half_year year two_year three_year onetime reset_traffic (حزمة إعادة ضبط حركة البيانات)
الحصول على تفاصيل الباقة GET <base_url>/api/v1/plan
معاملات الطلب
id=1البيانات المُعادة
{
"success": true,
"data": {
// same as an item in the plan list
}
}الحصول على إصدار العميل GET <base_url>/api/v1/app/version
البيانات المُعادة
{
"success": true,
"data": {
"windows": { // null for platforms that are not set
"version": "1.4.0", // latest version
"download_url": "https://www.website.com/app.exe"
},
"macos": null,
"android": {
"version": "1.4.0",
"download_url": "https://www.website.com/app.apk"
}
}
}تسجيل الدخول وإنشاء الحساب
إرسال رمز التحقق عبر البريد الإلكتروني POST <base_url>/api/v1/auth/email_code
البيانات المُرسلة
{
"email": "[email protected]",
"scene": "register" // options: register (registration), reset_password (password reset)
}البيانات المُعادة
{
"success": true
}إنشاء حساب POST <base_url>/api/v1/auth/register
البيانات المُرسلة
{
"email": "[email protected]",
"password": "password",
"email_code": "123456", // optional, required when the site enables email verification
"invite_code": "abcd" // optional, required when the site requires an invite code
}البيانات المُعادة
{
"success": true,
"data": {
"access_token": "xxxxxxxx", // login credential, sent in subsequent requests as Authorization: Bearer <access_token>
"expires_at": 1796112000, // credential expiry time
"is_admin": false
}
}تسجيل الدخول POST <base_url>/api/v1/auth/login
البيانات المُرسلة
{
"email": "[email protected]",
"password": "password"
}البيانات المُعادة
{
"success": true,
"data": {
"access_token": "xxxxxxxx",
"expires_at": 1796112000,
"is_admin": false
}
}إعادة تعيين كلمة المرور POST <base_url>/api/v1/auth/reset_password
بعد نجاح إعادة التعيين يجب على جميع أجهزة تسجيل الدخول لهذا الحساب تسجيل الدخول مجددًا
البيانات المُرسلة
{
"email": "[email protected]",
"email_code": "123456",
"password": "new_password"
}البيانات المُعادة
{
"success": true
}تسجيل الخروج POST <base_url>/api/v1/auth/logout
تُبطل access_token الحالي
البيانات المُعادة
{
"success": true
}الحساب
الواجهات التالية كلها تتطلب تسجيل الدخول
الحصول على معلومات المستخدم GET <base_url>/api/v1/me
البيانات المُعادة
{
"success": true,
"data": {
"email": "[email protected]",
"avatar_url": "https://www.website.com/avatar.png", // may be null
"balance": 1000, // balance
"commission_balance": 500, // available commission
"discount": 90, // user-specific discount percentage, null means none
"commission_rate": 10, // user-specific commission rate percentage, null means the site default is used
"remind_expire": true, // expiry reminder
"remind_traffic": true, // traffic reminder
"telegram_id": 123456, // bound Telegram id, null if not bound
"created_at": 1700000000,
"last_login_at": 1764547200
}
}تعديل إعدادات التذكير POST <base_url>/api/v1/me/update
البيانات المُرسلة
{
"remind_expire": true, // optional, omitted means unchanged
"remind_traffic": false // optional, omitted means unchanged
}البيانات المُعادة
{
"success": true
}الحصول على أعداد العناصر المعلّقة GET <base_url>/api/v1/me/stat
البيانات المُعادة
{
"success": true,
"data": {
"pending_orders": 1, // number of orders awaiting payment
"open_tickets": 0, // number of open tickets
"invited_users": 5 // number of invited users
}
}تغيير كلمة المرور POST <base_url>/api/v1/me/change_password
بعد نجاح التغيير يجب على أجهزة تسجيل الدخول الأخرى تسجيل الدخول مجددًا
البيانات المُرسلة
{
"old_password": "password",
"new_password": "new_password"
}البيانات المُعادة
{
"success": true
}الحصول على رابط دخول الويب دون تسجيل الدخول POST <base_url>/api/v1/me/web_login_url
البيانات المُرسلة
{
"redirect": "plan" // optional, web panel path to redirect to after login, defaults to the home page
}البيانات المُعادة
{
"success": true,
"data": {
"url": "https://www.website.com/#/login?verify=xxxx", // one-time link, valid for 60 seconds
"expires_at": 1764547260
}
}الحصول على أجهزة تسجيل الدخول GET <base_url>/api/v1/me/sessions
البيانات المُعادة
{
"success": true,
"data": [
{
"id": "a1b2c3", // session id
"ip": "1.2.3.4", // may be null
"user_agent": "soga-client/1.2.0 (windows)", // may be null
"login_at": 1764547200,
"last_used_at": 1764550800, // may be null
"is_current": true // is the current device
}
]
}إزالة جهاز تسجيل دخول POST <base_url>/api/v1/me/session/remove
البيانات المُرسلة
{
"id": "a1b2c3"
}البيانات المُعادة
{
"success": true
}إلغاء ربط Telegram POST <base_url>/api/v1/me/telegram/unbind
البيانات المُعادة
{
"success": true
}الاشتراك
الواجهات التالية كلها تتطلب تسجيل الدخول
الحصول على معلومات الاشتراك GET <base_url>/api/v1/subscription
البيانات المُعادة
{
"success": true,
"data": {
"plan": { // current plan, null if not purchased
"id": 1,
"name": "Annual Plan"
},
"upload": 1073741824, // upload traffic used in the current period, in bytes
"download": 5368709120, // download traffic used in the current period, in bytes
"transfer_enable": 107374182400, // traffic quota, in bytes
"expired_at": 1811808000, // expiry time, null means it never expires
"is_expired": false, // expired or never purchased
"next_reset_at": 1767225600, // next traffic reset time, null means no reset
"device_limit": 3, // device limit, null means unlimited
"speed_limit": null, // speed limit in Mbps, null means unlimited
"alive_ip": 1, // number of devices currently online, may be null
"subscribe_url": "https://sub.website.com/s/xxxx",
"can_new_period": false // a new period can be started early
}
}إعادة ضبط رابط الاشتراك POST <base_url>/api/v1/subscription/reset
تُعيد ضبط رابط الاشتراك وبيانات مصادقة العُقد، ويتوقف رابط الاشتراك القديم عن العمل فورًا
البيانات المُعادة
{
"success": true,
"data": {
"subscribe_url": "https://sub.website.com/s/yyyy" // new subscription URL
}
}بدء دورة جديدة مبكرًا POST <base_url>/api/v1/subscription/new_period
عند نفاد حركة البيانات تُصفَّر حركة البيانات المستخدمة، ويُقدَّم وقت الانتهاء بمقدار دورة واحدة من دورات إعادة ضبط حركة البيانات، وهي متاحة فقط عندما تكون can_new_period بقيمة true
البيانات المُعادة
{
"success": true
}الحصول على محتوى الاشتراك GET <subscribe_url>
مخصّصة للاستيراد في العملاء الآخرين، ولا تتطلب Authorization؛ أما عميل soga فيحصل على العُقد عبر /servers ولا يطلب رابط الاشتراك
معاملات الطلب
flag=sing-box/1.12.0 // config format, options: general clash-meta sing-box, sing-box may include the core versionالبيانات المُعادة
نص الإعدادات بالتنسيق المطلوب، ويجب أن تتضمن ترويسات الاستجابة
subscription-userinfo: upload=1073741824; download=5368709120; total=107374182400; expire=1811808000عندما يكون الاشتراك غير متاح (لم يُشترَ، أو منتهٍ، أو محظور) تُعيد
{
"success": false,
"error": {
"message": "Subscription expired"
}
}الحصول على سجلات حركة البيانات GET <base_url>/api/v1/traffic_logs
تُعيد سجلات حركة البيانات لكل يوم من الشهر الحالي، مرتبة تنازليًا حسب التاريخ
البيانات المُعادة
{
"success": true,
"data": [
{
"record_at": 1764547200, // 00:00 of that day
"upload": 10485760, // upload traffic, in bytes
"download": 524288000, // download traffic, in bytes
"rate": 1.5 // node multiplier, traffic counted against the quota = (upload + download) × rate
}
]
}الحصول على إعدادات العُقد GET <base_url>/api/v1/servers
تُعيد إعدادات اتصال العُقد وقواعد التوجيه، راجع وثائق واجهة العُقد soga-client-v1
الطلبيات
الواجهات التالية كلها تتطلب تسجيل الدخول
مسار الشراء: الحصول على قائمة الباقات ← إنشاء طلبية ← دفع الطلبية ← الاستعلام الدوري عن تفاصيل الطلبية إلى أن تصبح الحالة غير pending processing
التحقق من القسيمة POST <base_url>/api/v1/coupon/check
البيانات المُرسلة
{
"code": "NEWUSER",
"plan_id": 1,
"period": "year"
}البيانات المُعادة
{
"success": true,
"data": {
"name": "10% Off for New Users",
"type": "percent", // options: amount (fixed amount off), percent (percentage off)
"value": 10 // an amount when type is amount, a percentage when type is percent
}
}إنشاء طلبية POST <base_url>/api/v1/order/create
البيانات المُرسلة
{
"plan_id": 1,
"period": "year",
"coupon_code": "NEWUSER" // optional
}البيانات المُعادة
{
"success": true,
"data": {
"trade_no": "2026120108300012345" // order number
}
}إنشاء طلبية شحن الرصيد POST <base_url>/api/v1/order/deposit
متاحة عندما تكون features.deposit بقيمة true
البيانات المُرسلة
{
"amount": 10000 // top-up amount
}البيانات المُعادة
{
"success": true,
"data": {
"trade_no": "2026120108300012346"
}
}الحصول على قائمة الطلبيات GET <base_url>/api/v1/orders
معاملات الطلب
status=pending // optional, options: pending processing completed cancelled
page=1
page_size=20البيانات المُعادة
{
"success": true,
"data": [
// same as the order details
],
"pagination": {
"page": 1,
"page_size": 20,
"total": 3
}
}الحصول على تفاصيل الطلبية GET <base_url>/api/v1/order
معاملات الطلب
trade_no=2026120108300012345البيانات المُعادة
{
"success": true,
"data": {
"trade_no": "2026120108300012345",
"plan": { // null for top-up orders
"id": 1,
"name": "Annual Plan"
},
"period": "year", // null for top-up orders
"status": "pending", // options: pending (awaiting payment), processing (activating), completed (completed), cancelled (cancelled), discounted (credited toward a new order)
"total_amount": 13500, // amount payable
"discount_amount": 1500, // discount amount
"surplus_amount": 0, // amount credited from the old subscription
"balance_amount": 0, // amount paid from balance
"handling_amount": 0, // payment handling fee
"created_at": 1764547200,
"paid_at": null
}
}إلغاء الطلبية POST <base_url>/api/v1/order/cancel
البيانات المُرسلة
{
"trade_no": "2026120108300012345"
}البيانات المُعادة
{
"success": true
}الحصول على طرق الدفع GET <base_url>/api/v1/payment_methods
البيانات المُعادة
{
"success": true,
"data": [
{
"id": 1,
"name": "Alipay",
"icon": "https://www.website.com/alipay.png", // may be null
"handling_fee_fixed": 0, // fixed handling fee
"handling_fee_percent": 0, // percentage handling fee
"stripe_public_key": null // public key for Stripe credit card payment, null for other payment methods
}
]
}دفع الطلبية POST <base_url>/api/v1/order/checkout
البيانات المُرسلة
{
"trade_no": "2026120108300012345",
"method": 1, // payment method id, optional when the amount payable is 0
"stripe_token": "tok_xxx" // optional, required for Stripe credit card payment
}البيانات المُعادة
{
"success": true,
"data": {
"type": "redirect", // options: paid (already paid, no redirect needed), qrcode (show a QR code), redirect (open the link)
"url": "https://pay.website.com/xxxx" // null when type is paid
}
}بطاقات الهدايا
الواجهات التالية كلها تتطلب تسجيل الدخول
معاينة بطاقة الهدايا POST <base_url>/api/v1/gift_card/check
متاحة عندما تكون features.gift_card_preview بقيمة true
البيانات المُرسلة
{
"code": "GIFT-XXXX-XXXX"
}البيانات المُعادة
{
"success": true,
"data": {
"name": "30-Day Trial Card",
"description": "Adds 30 days of validity", // may be null
"can_redeem": true, // whether the current account can redeem it
"reason": null, // reason it cannot be redeemed
"balance": null, // balance reward
"transfer_enable": null, // traffic reward, in bytes
"expire_days": 30, // days of validity added
"device_limit": null, // number of devices added
"plan_name": null, // name of the plan activated
"plan_days": null, // number of days of the plan activated
"reset_traffic": false // reset used traffic to zero
}
}استبدال بطاقة الهدايا POST <base_url>/api/v1/gift_card/redeem
البيانات المُرسلة
{
"code": "GIFT-XXXX-XXXX"
}البيانات المُعادة
{
"success": true
}الحصول على سجل الاستبدال GET <base_url>/api/v1/gift_card/history
متاحة عندما تكون features.gift_card_preview بقيمة true
البيانات المُعادة
{
"success": true,
"data": [
{
"id": 1,
"code": "GIFT-****-XXXX", // partially masked redemption code
"name": "30-Day Trial Card",
"created_at": 1764547200
}
]
}الدعوة
الواجهات التالية كلها تتطلب تسجيل الدخول
الحصول على معلومات الدعوة GET <base_url>/api/v1/invite
البيانات المُعادة
{
"success": true,
"data": {
"codes": [ // unused invite codes
{
"code": "abcd",
"pv": 12, // number of visits
"created_at": 1764547200
}
],
"invited_users": 5, // number of invited users
"commission_rate": 10, // commission rate, in percent
"total_commission": 3000, // total commission earned
"pending_commission": 500, // commission pending confirmation
"available_commission": 2500 // available commission
}
}إنشاء رمز دعوة POST <base_url>/api/v1/invite/create
البيانات المُعادة
{
"success": true
}الحصول على سجل العمولات GET <base_url>/api/v1/invite/commissions
معاملات الطلب
page=1
page_size=20البيانات المُعادة
{
"success": true,
"data": [
{
"id": 1,
"trade_no": "2026120108300012345",
"order_amount": 15000, // order amount
"get_amount": 1500, // commission earned
"created_at": 1764547200
}
],
"pagination": {
"page": 1,
"page_size": 20,
"total": 1
}
}تحويل العمولة إلى الرصيد POST <base_url>/api/v1/invite/transfer
البيانات المُرسلة
{
"amount": 1000 // amount to transfer
}البيانات المُعادة
{
"success": true
}تقديم طلب سحب POST <base_url>/api/v1/invite/withdraw
تسحب كامل العمولة المتاحة، وتُنشئ اللوحة تذكرة تُعالَج يدويًا
البيانات المُرسلة
{
"method": "Alipay", // taken from commission.withdraw_methods in the site config
"account": "[email protected]" // receiving account
}البيانات المُعادة
{
"success": true
}الإعلانات وقاعدة المعرفة
الواجهات التالية كلها تتطلب تسجيل الدخول
الحصول على الإعلانات GET <base_url>/api/v1/notices
معاملات الطلب
page=1
page_size=20البيانات المُعادة
{
"success": true,
"data": [
{
"id": 1,
"title": "System Maintenance Notice",
"content": "<p>Maintenance tonight at 22:00</p>", // HTML
"img_url": null,
"created_at": 1764547200
}
],
"pagination": {
"page": 1,
"page_size": 20,
"total": 1
}
}الحصول على قاعدة المعرفة GET <base_url>/api/v1/knowledge
تُعيد فهرس المقالات باللغة الحالية، مجمّعة حسب الفئة، دون نص المقالات
معاملات الطلب
keyword=windows // optional, searches titles and body textالبيانات المُعادة
{
"success": true,
"data": [
{
"category": "Tutorials",
"articles": [
{
"id": 1,
"title": "Windows Tutorial",
"updated_at": 1764547200
}
]
}
]
}الحصول على مقال من قاعدة المعرفة GET <base_url>/api/v1/knowledge/article
معاملات الطلب
id=1البيانات المُعادة
{
"success": true,
"data": {
"id": 1,
"category": "Tutorials",
"title": "Windows Tutorial",
"body": "<p>After downloading the client...</p>", // HTML
"updated_at": 1764547200
}
}التذاكر
الواجهات التالية كلها تتطلب تسجيل الدخول
الحصول على قائمة التذاكر GET <base_url>/api/v1/tickets
معاملات الطلب
page=1
page_size=20البيانات المُعادة
{
"success": true,
"data": [
{
"id": 1,
"subject": "Cannot connect",
"level": 1, // 0 low, 1 medium, 2 high
"is_closed": false,
"is_replied": true, // support has replied
"created_at": 1764547200,
"updated_at": 1764550800
}
],
"pagination": {
"page": 1,
"page_size": 20,
"total": 1
}
}الحصول على تفاصيل التذكرة GET <base_url>/api/v1/ticket
معاملات الطلب
id=1البيانات المُعادة
{
"success": true,
"data": {
"id": 1,
"subject": "Cannot connect",
"level": 1,
"is_closed": false,
"is_replied": true,
"created_at": 1764547200,
"updated_at": 1764550800,
"messages": [ // in ascending time order
{
"id": 1,
"is_me": true, // true if sent by the user, false if sent by support
"message": "I cannot connect to any node",
"created_at": 1764547200
},
{
"id": 2,
"is_me": false,
"message": "Please update your subscription and try again",
"created_at": 1764550800
}
]
}
}إنشاء تذكرة POST <base_url>/api/v1/ticket/create
البيانات المُرسلة
{
"subject": "Cannot connect",
"level": 1, // 0 low, 1 medium, 2 high
"message": "I cannot connect to any node"
}البيانات المُعادة
{
"success": true,
"data": {
"id": 1 // ticket id
}
}الرد على التذكرة POST <base_url>/api/v1/ticket/reply
البيانات المُرسلة
{
"id": 1,
"message": "I have updated it, but it still does not work"
}البيانات المُعادة
{
"success": true
}إغلاق التذكرة POST <base_url>/api/v1/ticket/close
البيانات المُرسلة
{
"id": 1
}البيانات المُعادة
{
"success": true
}