تخطَّ إلى المحتوى
Gurdx

التوثيق / البدء

رموز الأخطاء

كل الأخطاء التي قد تعيدها Gurdx برمزها ونوعها ومعناها، مع طريقة التعامل معها في شيفرتك.

غلاف الخطأ#

تُسلَّم الأخطاء برمز HTTP 200 وبمحتوى بهذا الشكل:

{
  "status": "error",
  "code": 101,
  "type": "invalid_key",
  "description": "The API Key is missing or invalid."
}
الحقل المعنى
status دائماً error.
code رمز رقمي ثابت عبر الإصدارات. اعتمد عليه في التفرّع.
type اسم مختصر مقروء آلياً.
description شرح مقروء للبشر. قد تُعاد صياغته، فلا تحلّله برمجياً.

الرموز 101 إلى 127 هي المجموعة الأساسية، والرموز 128 إلى 132 إضافات لاحقة.

كل الرموز#

CodeTypeDescription
101invalid_keyThe API Key is missing or invalid.
102inactive_userThe API Key owner (the account) is inactive right now. Please contact the support team for more information.
103limit_reachedYou reached the usage limit of your account. Please upgrade your subscription or pay any unpaid invoices.
104invalid_paramsPlease check out the params parameter's value.
105plan_expiredYour plan has expired. Renew the subscription to enable using the API.
106flood_detectedOur system has detected too many requests at the same time. Kindly please try to slow down.
107invalid_callback_nameThe value of the callback parameter cannot be a function name.
108invalid_formatThe value of the format parameter is not a valid format. Use JSON, XML, CSV or Newline.
109callback_not_allowedYou can use the callback feature only with the JSON format.
110invalid_languageThe value of the lang parameter is not a valid format. Use EN, AR, FR, DE, ES, JA, ZH or RU.
111invalid_modeThe value of the mode parameter is not a valid format. Use test or live.
112invalid_ipThe IP Address is not valid or empty.
113domain_not_whitelistedYou are sending the request from a host that is not in the authorized hosts of your account.
114security_module_not_allowedYou cannot use the security module in your plan. Please upgrade your API plan to unlock this feature.
115generic_errorAn error occurred while processing your request. Please try again later.
116invalid_country_codeThe Country Code is invalid or not found.
117feature_not_availableThis feature is not available for your plan, please upgrade your plan first.
118invalid_phone_numberThe Phone Number is invalid or missing.
119invalid_email_addressThe Email Address is invalid or missing.
120invalid_bin_numberThe BIN number is invalid or missing.
121invalid_asnThe AS Number you provided is empty or invalid.
122invalid_ibanThe IBAN is invalid or missing.
123invalid_useridThe user identifier is invalid or too long.
124invalid_user_typeThe user type is invalid or missing. Use email, phone or user_id.
125invalid_user_valueThe user value is invalid or missing (value parameter).
126too_many_deletionsYou have reached the limit of deletions for this day. Please wait until the next day to delete more user data.
127subscription_requiredA paid subscription or an active trial is required to use this API. Subscribe from your dashboard.
128invalid_domainThe domain name is invalid or missing.
129invalid_textThe text is missing or too long (max 10,000 characters).
130invalid_payment_dataThe data object is missing or invalid.
131invalid_feedbackThe feedback is missing or invalid.
132too_many_feedback_itemsSend at most 1,000 feedback items per request.

التعامل مع الأخطاء#

بما أن رمز HTTP يكون 200 حتى في الأخطاء، افحص الحقل status في المحتوى.

PHP#

$res = Http::withToken(env('GURDX_KEY'))->get('https://gurdx.cretip.com/api/lookup/ip', ['ip' => $ip])->json();

if (($res['status'] ?? null) === 'error') {
    match ($res['code']) {
        106 => usleep(500_000),            // خفّف السرعة وأعد المحاولة لاحقاً
        103, 105, 127 => notifyBilling(),  // الحصة أو الاشتراك
        101, 113 => alertOps($res),        // مشكلة في المفتاح أو المضيف
        default => logger()->warning('Gurdx error', $res),
    };
    return fallbackDecision();
}

$data = $res['data'];

JavaScript#

const res = await fetch("https://gurdx.cretip.com/api/lookup/ip?ip=1.1.1.1", {
  headers: { Authorization: "Bearer " + process.env.GURDX_KEY },
}).then((r) => r.json());

if (res.status === "error") {
  if (res.code === 106) await new Promise((r) => setTimeout(r, 500));
  throw new Error(`Gurdx ${res.code} ${res.type}: ${res.description}`);
}
console.log(res.data);

Python#

import requests

res = requests.get(
    "https://gurdx.cretip.com/api/lookup/ip",
    params={"ip": "1.1.1.1"},
    headers={"Authorization": "Bearer YOUR_API_KEY"},
    timeout=5,
).json()

if res.get("status") == "error":
    raise RuntimeError(f"Gurdx {res['code']} {res['type']}: {res['description']}")
data = res["data"]

أي الأخطاء تستحق إعادة المحاولة#

المجموعة الرموز المطلوب
مؤقتة 106 و115 أعد المحاولة مع تأخير تصاعدي.
مشكلة في المدخلات 104 و107 إلى 112 و116 و118 إلى 125 و128 إلى 132 صحّح الطلب؛ إعادة المحاولة لن تفيد.
الحساب أو الخطة 101 إلى 103 و105 و113 و114 و117 و127 صحّح المفتاح أو قيد المضيفين أو الخطة أو الفوترة.

Tip: سجّل code وtype مع الدالة التي استدعيتها، فهذا يسهّل تشخيص الحوادث كثيراً.

الصيغة والأخطاء#

تحترم الأخطاء خيار format إذا كان صالحاً، فيتلقى عميل XML خطأً بصيغة XML. أما إذا كانت قيمة format نفسها غير صالحة (108) أو تعارضت مع callback (109) فيُعاد الخطأ بصيغة JSON.

وجدت خطأ؟ أخبرنا عبر صفحة التواصل. تواصل معنا