استخراج رمز QR للربط

جلب بيانات رمز الاستجابة السريعة لمسحها عبر الهاتف.

POST
https://api.wawp.net/v2/auth/qr?access_token=YOUR_ACCESS_TOKEN&format=raw&instance_id=Your_Instance_ID&phone_number=201012345678

تسجيل الدخول مطلوب

سجل الدخول لاستبدال المعرفات (Instance ID) ورمز الوصول (Access Token) بمعلومات حسابك الحقيقي لاختبار ال API مباشرة.

تسجيل الدخول
اختبار /v2/auth/qr
POSTGET

لا توجد معاملات استعلام مطلوبة

هذه النهاية الطرفية لا تتوقع بيانات في الرابط.

توصيات

  • Use this endpoint for custom CLI dashboards or mobile app integrations.

  • Decode the Base64 'data' field before passing it to a QR generation library.

  • Implement a polling mechanism to fetch a new code upon expiry.

Deciphering the Protocol: The Raw QR Payload Guide

The /v2/auth/qr endpoint is the specialized "Engine Access" tool for developers who require surgical control over the authentication process. Unlike the image-based endpoint, which is optimized for quick rendering, this route provides the raw, Base64-encoded protocol string. This is essential for building custom QR generators, CLI-based tools, or native mobile implementations where binary data is preferred over a static image.


🏗️ Technical Breakdown: The JSON Envelope

The response from this endpoint is a JSON object containing two primary components:

  1. mimetype: Typically application/json, indicating that the payload is a structured data object.
  2. data: A Base64-encoded string. Once decoded, this string yields a JSON object containing the Protocol Signature required by the WhatsApp WebSocket.

The Decoded Payload Structure

When you decode the data field, you will find:

  • value: The actual alphanumeric string that needs to be encoded into a QR pattern.
  • expiry: A Unix timestamp representing the exact millisecond when this specific QR code will be invalidated by the WhatsApp servers.

🛡️ Strategic Best Practices

1. Implementing a CLI-Based ASCII Renderer

If you are building a headless tool (like a VPS manager or a terminal-based bot), fetching the raw QR string allows you to render the code directly in the terminal using ASCII characters.

  • Developer Action: Use a library like qrcode-terminal in Node.js or qrcode in Python. Pass the value from the decoded response to the library to display the scanable pattern directly to your server administrators.

2. Synchronization and Rate Limiting

Fetching the raw QR is a relatively resource-intensive task for the underlying engine as it involves a real-time probe of the browser state.

  • The Polling Window: We recommend a polling interval of 5-7 seconds. Polling faster than this will not yield a "fresher" code (as WhatsApp only rotates codes every 20-30 seconds) and may lead to 429 Rate Limit responses from our infrastructure.

3. Handling the Recovery Window (422 Status)

If the engine is busy resetting its internal WhatsApp bridge, you will receive a 422 Session Status Not Expected error.

  • The Fix: This is not a failure; it’s a "Please Wait" signal. Your application should implement an exponential backoff. Wait 10 seconds, then 20 seconds, before attempting to fetch the QR again. This gives the engine time to finalize its background handshake.

💡 Industry-Standard Use Cases

A. Deep-Link Mobile Integration

If you are building a native iOS or Android app, you can fetch the raw QR string and use the mobile OS's native QR generation libraries (like CoreImage on iOS). This results in a much sharper, high-contrast QR code that is easier for the user's secondary device to scan compared to a compressed PNG image.

B. Security-Hardened Dashboards

For high-security environments where you do not want to load external images from our servers, you can fetch the raw string on your backend, verify its integrity, and then generate the QR pattern locally using your own internal corporate styling.


⚠️ Common Pitfalls

  • Binary vs. String: The data field is Base64 encoded. If you try to pass the raw Base64 string directly into a QR generator without decoding it first, the scan will fail because the data will be interpreted as a literal Base64 string rather than the underlying WhatsApp protocol ID.
  • Expiry Ignorance: Always check the expiry field. If your frontend displays a QR code that has already passed its expiry timestamp, the user will scan it only to see an "Expired" error on their phone, leading to significant UX frustration.

Summary of Responsibilities:

  • Retrieve the raw cryptographic string required for a WhatsApp handshake.
  • Provide a Base64-wrapped JSON envelope for protocol compatibility.
  • Enable custom rendering in non-browser environments (CLI, Mobile).
  • Facilitate advanced monitoring of QR rotation cycles and expiration.

البارامترات

قم بتهيئة المعاملات المطلوبة للتفاعل مع نقطة النهاية هذه. جميع وسائط الاستعلام والبيانات مدرجة أدناه مع تفاصيلها.

محتوى الطلب

يرسل كـ JSON
string

The 12-character ID of the instance

مثال:
string

Your API Access Token

مثال:
string

The full international WhatsApp phone number to link (e.g., 201012345678, 447403653133)

مثال:
string—

Output format (default: raw)

مثال:

برمج بالذكاء الاصطناعي باستخدام Wawp MCP

MCP READY

قم بربط الـ API مباشرة مع Cursor أو Windsurf أو Claude Desktop، ودع الذكاء الاصطناعي يكتب لك كود الربط وينفذه تلقائياً!

طريقة الربط والإعداد

أمثلة الكود

استخدم أمثلة الكود الجاهزة لدمج واجهة برمجة التطبيقات (API) في مشروعك بسرعة وكفاءة. اختر لغة البرمجة والمكتبة التي تفضلها.

1const baseUrl = "https://api.wawp.net";
2const endpoint = "/v2/auth/qr";
3const params = new URLSearchParams({
4 "instance_id": "Your_Instance_ID",
5 "access_token": "YOUR_ACCESS_TOKEN"
6}).toString();
7const body = {
8 "phone_number": "201012345678",
9 "format": "raw"
10};
11
12fetch(`${baseUrl}${endpoint}${params ? '?' + params : ''}`, {
13 method: "POST",
14 headers: { "Content-Type": "application/json" },
15 body: JSON.stringify(body)
16})
17 .then(async (response) => {
18 if (response.ok) {
19 const data = await response.json();
20 console.log("Success:", data);
21 return data;
22 }
23
24 // Error Handling
25 if (response.status === 400) {
26 console.error("Error 400: طلب غير صالح - معاملات مطلوبة مفقودة");
27 }
28 if (response.status === 400) {
29 console.error("Error 400: طلب غير صالح (تنسيق XML)");
30 }
31 if (response.status === 400) {
32 console.error("Error 400: طلب غير صالح (نص عادي)");
33 }
34 if (response.status === 401) {
35 console.error("Error 401: غير مصرح - مفتاح الوصول غير صالح أو مفقود");
36 }
37 if (response.status === 401) {
38 console.error("Error 401: غير مصرح (تنسيق XML)");
39 }
40 if (response.status === 404) {
41 console.error("Error 404: غير موجود - الجلسة غير موجودة");
42 }
43 if (response.status === 404) {
44 console.error("Error 404: غير موجود (تنسيق XML)");
45 }
46 if (response.status === 500) {
47 console.error("Error 500: خطأ في الخادم الداخلي - فشل غير متوقع");
48 }
49 if (response.status === 500) {
50 console.error("Error 500: خطأ في الخادم الداخلي (HTML)");
51 }
52 if (response.status === 502) {
53 console.error("Error 502: بوابة غير صالحة - فشل الاتصال بالخادم الرئيسي");
54 }
55 if (response.status === 502) {
56 console.error("Error 502: بوابة غير صالحة (تنسيق XML)");
57 }
58 if (response.status === 422) {
59 console.error("Error 422: Unprocessable Entity - Session Status Mismatch");
60 }
61
62 const errorText = await response.text();
63 console.error(`Error ${response.status}: ${errorText}`);
64 })
65 .catch((error) => console.error("Network Error:", error));
عينات تفاعلية
Ln 65, Col 1javascript

الردود المتوقعة

استكشف كافة الردود والنتائج المحتملة من الخادم. قمنا بتوثيق كل كود حالة (Status Code) مع أمثلة للبيانات لتسهيل معالجة الأخطاء والنجاح.

ناجح - بيانات QR الخام
النوع:
application/json
string *
string *

Example

{
"mimetype": "application/json; charset=utf-8",
"data": "eyJ2YWx1ZSI6IjJAR0JoWWtpTkV1U0tpeXpIeVVOYy9RQi9lTnhpSkJWSE96bGhOQ1daRERvRUZyOEhDWEhxTENKdEVpZHh6WWoxWkpqRzZ4K2NOaFVlVGlZeUJHWExJQzU1Z2ppKzRHQ2VyakRvPSIsImV4cGlyeSI6MTIzNDU2Nzg5MH0="
}
طلب غير صالح - معاملات مطلوبة مفقودة
غير مصرح - مفتاح الوصول غير صالح أو مفقود
غير موجود - الجلسة غير موجودة
Unprocessable Entity - Session Status Mismatch
خطأ في الخادم الداخلي - فشل غير متوقع
بوابة غير صالحة - فشل الاتصال بالخادم الرئيسي
الموضوع السابقحول نظام المصادقة
الموضوع التالياستخراج صورة رمز QR

Command Palette

Search for a command to run...