مرحبًا بعودتك

سجّل الدخول للوصول إلى مستنداتك وتوقيعاتك

أو تابع بالبريد الإلكتروني
API v1 · مستقر

WHAT A PDF! Developer API

عالج ملفات PDF على نطاق واسع من تطبيقك. اضغط وادمج وقسّم وطبّق OCR عبر واجهة REST نظيفة بمصادقة Bearer-token وحدود معدل لكل خطة.

بداية سريعة

ثلاث خطوات لأول طلب API.

  1. أنشئ مفتاح API من الحساب › مفاتيح API
  2. أرسل POST من نوع multipart/form-data إلى إحدى نقاط نهاية v1 مع ترويسة Authorization: Bearer.
  3. افحص استجابة JSON — تُعيد الطلبات الناجحة رابط تنزيل موقَّعًا صالحًا لمدة 15 دقيقة.

الرابط الأساسي

https://whatapdf.com/api/v1

المصادقة

يجب أن يتضمن كل طلب ترويسة Authorization مع مفتاح API الخاص بك كرمز Bearer.

Authorization: Bearer pdn_live_a1b2c3d4e5f6...
احتفظ بمفاتيحك الحية سرية. تعامل معها كأنها كلمات مرور. لا تُدرجها أبدًا في التحكم بالمصدر أو تكشفها في كود العميل.

صيغ المفاتيح

  • pdn_live_<32 hex> — مفتاح إنتاج. يُحتسب ضمن حد معدل خطتك.
  • pdn_test_<32 hex> — مفتاح اختبار. نفس حد المعدل؛ مفيد لتمييز البيئات في السجلات.

حدود المعدل

تُحتسب حدود المعدل لكل مستخدم لكل نافذة متجددة مدتها ساعة واحدة. تتضمن كل استجابة ترويسات X-RateLimit-* لتخطيط إعادة المحاولات.

الخطةطلبات / ساعة
Free10
Premium1,000
Business5,000
Enterpriseغير محدود

ترويسات الاستجابة

  • X-RateLimit-Limit — الحد الأقصى لخطتك في الساعة.
  • X-RateLimit-Remaining — المكالمات المتبقية في النافذة الحالية.
  • X-RateLimit-Reset — طابع زمني Unix عند إعادة تعيين النافذة.
  • Retry-After — الثواني التي يجب الانتظار قبل المحاولة، تُرسل فقط مع استجابات 429.

أخطاء

تُرجع جميع الأخطاء بصيغة JSON مع رمز ثابت ورسالة مقروءة.

{
  "error": {
    "code": "rate_limited",
    "message": "Rate limit exceeded for your plan (free: 10/hour)."
  },
  "meta": { "request_id": "8f9a2b3c1d4e5f6a" }
}

رموز الأخطاء

CodeHTTPالمعنى
unauthorized401مفتاح API مفقود أو مشوَّه أو ملغى.
rate_limited429تم تجاوز حد المعدل بالساعة لخطتك.
invalid_input400فشل التحقق من جسم الطلب أو المعلمات.
payload_too_large413الملف أو الحمولة الموحدة يتجاوز حد الحجم لخطتك.
internal_error500خطأ خادم غير متوقع. من الآمن إعادة المحاولة مع تأخير.

POST /compress

اضغط PDF باستخدام Ghostscript عند توفره، مع FPDI كخيار احتياطي. يُرجع رابط تنزيل موقَّعًا.

POSThttps://whatapdf.com/api/v1/compress

المعاملات (multipart/form-data)

الاسماكتبالوصف
file *fileملف PDF للضغط.
levelstringإعداد ضغط مسبق. low, medium, high

أمثلة على الشيفرة

curl -X POST https://whatapdf.com/api/v1/compress \
  -H "Authorization: Bearer pdn_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
  -F "[email protected]" \
  -F "level=medium"
const form = new FormData();
form.append('file', fileInput.files[0]);
form.append('level', 'medium');

const res = await fetch('https://whatapdf.com/api/v1/compress', {
  method: 'POST',
  headers: { 'Authorization': 'Bearer pdn_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' },
  body: form,
});
const json = await res.json();
console.log(json.data.download.url);
import requests

with open('input.pdf', 'rb') as f:
    r = requests.post(
        'https://whatapdf.com/api/v1/compress',
        headers={'Authorization': 'Bearer pdn_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'},
        files={'file': f},
        data={'level': 'medium'},
    )
print(r.json())
<?php
$ch = curl_init('https://whatapdf.com/api/v1/compress');
curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_POST           => true,
    CURLOPT_HTTPHEADER     => ['Authorization: Bearer pdn_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'],
    CURLOPT_POSTFIELDS     => [
        'file'  => new CURLFile('input.pdf', 'application/pdf'),
        'level' => 'medium',
    ],
]);
$res = json_decode(curl_exec($ch), true);
curl_close($ch);
print_r($res);

مثال على الاستجابة

{
  "data": {
    "filename": "report_compressed.pdf",
    "original_size": 5242880,
    "compressed_size": 2621440,
    "savings_percent": 50.0,
    "method": "ghostscript",
    "download": {
      "url": "/api/get-pdf.php?file=...&exp=...&sig=...",
      "expires_in": 900
    }
  },
  "meta": { "request_id": "8f9a2b3c1d4e5f6a" }
}

POST /merge

ادمج 2-20 ملف PDF في مستند واحد حسب ترتيب الرفع.

POSThttps://whatapdf.com/api/v1/merge

المعاملات

الاسماكتبالوصف
files[] *file[]ملفان أو أكثر من ملفات PDF (مصفوفة multipart).

أمثلة على الشيفرة

curl -X POST https://whatapdf.com/api/v1/merge \
  -H "Authorization: Bearer pdn_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
  -F "files[][email protected]" \
  -F "files[][email protected]" \
  -F "files[][email protected]"
const form = new FormData();
for (const f of fileInput.files) form.append('files[]', f);

const res = await fetch('https://whatapdf.com/api/v1/merge', {
  method: 'POST',
  headers: { 'Authorization': 'Bearer pdn_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' },
  body: form,
});
console.log(await res.json());
import requests

files = [
    ('files[]', open('a.pdf', 'rb')),
    ('files[]', open('b.pdf', 'rb')),
    ('files[]', open('c.pdf', 'rb')),
]
r = requests.post(
    'https://whatapdf.com/api/v1/merge',
    headers={'Authorization': 'Bearer pdn_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'},
    files=files,
)
print(r.json())
<?php
$ch = curl_init('https://whatapdf.com/api/v1/merge');
curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_POST           => true,
    CURLOPT_HTTPHEADER     => ['Authorization: Bearer pdn_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'],
    CURLOPT_POSTFIELDS     => [
        'files[0]' => new CURLFile('a.pdf', 'application/pdf'),
        'files[1]' => new CURLFile('b.pdf', 'application/pdf'),
        'files[2]' => new CURLFile('c.pdf', 'application/pdf'),
    ],
]);
echo curl_exec($ch);
curl_close($ch);

POST /split

قسّم PDF إلى جزء أو أكثر حسب نطاقات الصفحات. يُعاد كل جزء مع رابط تنزيل موقَّع خاص به.

POSThttps://whatapdf.com/api/v1/split

المعاملات

الاسماكتبالوصف
file *fileملف PDF المصدر.
ranges *stringنطاقات الصفحات مفصولة بفواصل. كل نطاق = جزء ناتج واحد. e.g. 1-3,5,7-9

أمثلة على الشيفرة

curl -X POST https://whatapdf.com/api/v1/split \
  -H "Authorization: Bearer pdn_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
  -F "[email protected]" \
  -F "ranges=1-3,5,7-9"
const form = new FormData();
form.append('file', fileInput.files[0]);
form.append('ranges', '1-3,5,7-9');

const res = await fetch('https://whatapdf.com/api/v1/split', {
  method: 'POST',
  headers: { 'Authorization': 'Bearer pdn_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' },
  body: form,
});
console.log(await res.json());
import requests

with open('input.pdf', 'rb') as f:
    r = requests.post(
        'https://whatapdf.com/api/v1/split',
        headers={'Authorization': 'Bearer pdn_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'},
        files={'file': f},
        data={'ranges': '1-3,5,7-9'},
    )
for part in r.json()['data']['parts']:
    print(part['pages'], part['download']['url'])
<?php
$ch = curl_init('https://whatapdf.com/api/v1/split');
curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_POST           => true,
    CURLOPT_HTTPHEADER     => ['Authorization: Bearer pdn_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'],
    CURLOPT_POSTFIELDS     => [
        'file'   => new CURLFile('input.pdf', 'application/pdf'),
        'ranges' => '1-3,5,7-9',
    ],
]);
print_r(json_decode(curl_exec($ch), true));
curl_close($ch);

POST /ocr

استخرج النص من صورة باستخدام Tesseract OCR. يدعم أكثر من 20 لغة.

POSThttps://whatapdf.com/api/v1/ocr

المعاملات

الاسماكتبالوصف
image *fileصورة لإجراء OCR (PNG أو JPEG أو TIFF أو WebP أو BMP).
languagestringرمز لغة Tesseract. الافتراضي eng

أمثلة على الشيفرة

curl -X POST https://whatapdf.com/api/v1/ocr \
  -H "Authorization: Bearer pdn_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
  -F "[email protected]" \
  -F "language=eng"
const form = new FormData();
form.append('image', imageInput.files[0]);
form.append('language', 'eng');

const res = await fetch('https://whatapdf.com/api/v1/ocr', {
  method: 'POST',
  headers: { 'Authorization': 'Bearer pdn_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' },
  body: form,
});
const { data } = await res.json();
console.log(data.text);
import requests

with open('scan.png', 'rb') as f:
    r = requests.post(
        'https://whatapdf.com/api/v1/ocr',
        headers={'Authorization': 'Bearer pdn_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'},
        files={'image': f},
        data={'language': 'eng'},
    )
print(r.json()['data']['text'])
<?php
$ch = curl_init('https://whatapdf.com/api/v1/ocr');
curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_POST           => true,
    CURLOPT_HTTPHEADER     => ['Authorization: Bearer pdn_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'],
    CURLOPT_POSTFIELDS     => [
        'image'    => new CURLFile('scan.png', 'image/png'),
        'language' => 'eng',
    ],
]);
$res = json_decode(curl_exec($ch), true);
echo $res['data']['text'];
curl_close($ch);
WHAT A PDF! لـ Gmail - إضافة Chrome

افتح مرفقات PDF من Gmail مباشرة في WHAT A PDF!. حرّر ووقّع وحوّل ملفات PDF فورًا!

ثبّت الإضافة المجانية

Wait — don't miss out!

Subscribe for free PDF tips, new tools, and feature updates delivered to your inbox.

No spam ever. Unsubscribe anytime.