SAFWAN Store API
اربط موقعك أو تطبيقك أو بوتك بمتجرنا: بتجيب المنتجات بأسعار التاجر تبعك، بتتحقق من ID اللاعب، وبتعمل طلبات بتنشحن أوتوماتيك وبتندفع من رصيدك عنا.
- الـ API متاح لحسابات التجّار بس. بتعمل المفتاح من: حسابي ← API للتجّار.
- المفتاح بيطلع مرة وحدة بس. خبّيه بالسيرفر تبعك، ولا تحطّو أبداً بصفحة أو تطبيق بيوصلو للزباين.
- إذا الطلب فشل، المبلغ بيرجع لرصيدك أوتوماتيك، وحالة الطلب بتصير
cancelled. - الشرح التقني تحت بالإنكليزي لأنو للمبرمجين.
Connect your website, app or bot to our store: fetch products at your reseller prices, verify player IDs, and place orders that are fulfilled automatically and paid from your store balance.
- The API is available to reseller (dealer) accounts only. Create your key from My account → API for resellers.
- The key is shown only once. Keep it on your server; never put it in a web page or app that your customers can download.
- If an order fails, the amount is refunded to your balance automatically and the order status becomes
cancelled.
Authentication
Send your key in the X-API-Key header on every request (or Authorization: Bearer <key>). All responses are JSON. All prices are in USD.
Base URL: https://safwan-store.netlify.app/api/v1
curl https://safwan-store.netlify.app/api/v1/balance \ -H "X-API-Key: sfw_your_key_here"
Endpoints
GET/balance
Your current balance.
{ "ok": true, "balance": "48.20", "balance_cents": 4820, "currency": "USD" }
GET/products
All available products with your prices. A product is either a fixed package (custom_amount: false, has price) or a custom amount (custom_amount: true, priced per 1000 units between min_units and max_units). If requires_player_id is true, you must send player_id when ordering.
{
"ok": true, "currency": "USD",
"products": [
{ "id": "dc-107", "name": "Tokens 150000", "name_en": null, "category": "games", "group": "جواكر",
"requires_player_id": true, "custom_amount": false, "price": "17.50", "price_cents": 1750 },
{ "id": "dc-321-custom", "name": "Jawaker Unit", "category": "games", "group": "جواكر",
"requires_player_id": true, "custom_amount": true, "min_units": 10000, "max_units": 1000000,
"price_per_1000": "0.11", "price_per_1000_cents": 11 }
]
}
POST/check-player
Optional: verify a player ID before ordering. valid is null when the product doesn't support verification.
curl -X POST https://safwan-store.netlify.app/api/v1/check-player \
-H "X-API-Key: sfw_your_key_here" -H "Content-Type: application/json" \
-d '{"product_id":"dc-107","player_id":"5123456789"}'
{ "ok": true, "valid": true, "player_name": "Ali" }
POST/orders
Place an order. The total is taken from your balance immediately.
| Field | Type | |
|---|---|---|
product_id | string | Required. From /products. |
player_id | string | Required if requires_player_id. |
quantity | integer 1–20 | Fixed packages only. Default 1. |
units | integer | Custom-amount products only (e.g. 150000). |
client_order_id | string ≤ 64 | Recommended. Your own unique ID (A-Z a-z 0-9 _ -). Sending the same one twice never charges twice; you get the existing order back with "duplicate": true. |
curl -X POST https://safwan-store.netlify.app/api/v1/orders \
-H "X-API-Key: sfw_your_key_here" -H "Content-Type: application/json" \
-d '{"product_id":"dc-107","player_id":"5123456789","quantity":1,"client_order_id":"my-1001"}'
{
"ok": true, "duplicate": false,
"order": {
"id": "api_...", "order_no": "S-K3M9QZ", "client_order_id": "my-1001",
"status": "pending", "product_id": "dc-107", "product_name": "Tokens 150000",
"player_id": "5123456789", "quantity": 1, "units": null,
"total": "17.50", "total_cents": 1750, "refunded": false,
"created_at": "2026-10-08T10:15:02.000Z", "completed_at": null, "cancelled_at": null
}
}
GET/orders/{id} or /orders?client_order_id=my-1001
Order status. Poll every 30–60 seconds until it is no longer pending.
| status | Meaning |
|---|---|
pending | Being delivered (usually seconds to a few minutes). |
completed | Delivered to the player. |
cancelled | Failed. The full amount was refunded to your balance (refunded: true). |
Errors
{ "ok": false, "error": { "code": "INSUFFICIENT_BALANCE", "message": "Balance 3.00 is less than 17.50" } }
| HTTP | code | When |
|---|---|---|
| 401 | UNAUTHORIZED | Missing / wrong / revoked key, or the account is no longer a reseller. |
| 400 | BAD_REQUEST, BAD_JSON | Missing or invalid fields. |
| 400 | PLAYER_ID_REQUIRED | This product needs player_id. |
| 400 | BAD_QUANTITY, BAD_UNITS | Quantity or units out of range. |
| 402 | INSUFFICIENT_BALANCE | Top up your balance first. |
| 404 | PRODUCT_UNAVAILABLE, NOT_FOUND | Unknown or disabled product / order / endpoint. |
| 502 / 500 | TEMPORARY, SERVER_ERROR | Try again shortly. Use the same client_order_id to retry safely. |
Example (Node.js)
const BASE = "https://safwan-store.netlify.app/api/v1";
const KEY = process.env.SAFWAN_API_KEY; // keep it on your server
async function call(path, body) {
const r = await fetch(BASE + path, {
method: body ? "POST" : "GET",
headers: { "X-API-Key": KEY, "Content-Type": "application/json" },
body: body ? JSON.stringify(body) : undefined
});
return r.json();
}
const { order } = await call("/orders", {
product_id: "dc-107", player_id: "5123456789", client_order_id: "my-1001"
});
console.log(order.status); // "pending" → poll /orders/{id} until "completed" or "cancelled"
Questions or problems? WhatsApp: +961 71 196 537 · +968 9098 2025