おかえりなさい

ログインしてドキュメントと署名にアクセス

またはメールで続行
パスワードをお忘れですか?
API v1 · 安定版

WHAT A PDF! 開発者向けAPI

アプリケーションから大規模にPDFを処理しましょう。Bearerトークン認証とプランごとのレート制限を備えた、洗練されたRESTインターフェースで、圧縮・結合・分割・OCRが行えます。

クイックスタート

最初のAPI呼び出しまで3ステップ。

  1. 次の場所からAPIキーを作成します: アカウント › APIキー
  2. multipart/form-data POSTを、Authorization: Bearer ヘッダー付きでv1エンドポイントのいずれかに送信します。
  3. JSONレスポンスを確認します — 成功した呼び出しでは、15分間有効な署名付きダウンロードURLが返されます。

ベースURL

https://whatapdf.com/api/v1

認証

すべてのリクエストには、APIキーをBearerトークンとして含むAuthorizationヘッダーが必要です。

Authorization: Bearer pdn_live_a1b2c3d4e5f6...
本番キーは秘密にしてください。パスワードと同じように扱いましょう。決してソース管理にコミットしたり、クライアント側のコードに公開したりしないでください。

キーの形式

  • pdn_live_<32 hex> — 本番用キー。プランのレート制限にカウントされます。
  • pdn_test_<32 hex> — テスト用キー。同じレート制限。ログ上で環境を区別するのに便利です。

レート制限

レート制限は、ユーザーごとに1時間のローリングウィンドウで計算されます。各レスポンスには再試行を計画できるようX-RateLimit-*ヘッダーが含まれます。

プランリクエスト数 / 時間
Free10
Premium1,000
Business5,000
Enterprise無制限

レスポンスヘッダー

  • X-RateLimit-Limit — ご利用プランの1時間あたりの上限です。
  • 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意味
unauthorized401APIキーが欠落しているか、不正、または失効しています。
rate_limited429プランの1時間あたりのレート制限を超えました。
invalid_input400リクエストボディまたはパラメータの検証に失敗しました。
payload_too_large413ファイルまたは合計ペイロードがプランのサイズ上限を超えています。
internal_error500予期しないサーバーエラーです。バックオフで安全に再試行できます。

POST /compress

利用可能な場合はGhostscriptを使用し、FPDIをフォールバックとしてPDFを圧縮します。署名付きダウンロードURLを返します。

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を、アップロード順で1つのドキュメントに結合します。

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

パラメータ

名前説明
files[] *file[]2つ以上の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を1つ以上のパートに分割します。各パートにはそれぞれ独自の署名付きダウンロードURLが返されます。

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

パラメータ

名前説明
file *file元のPDF。
ranges *stringカンマ区切りのページ範囲。1範囲=1出力パート。 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 *fileOCRする画像(PNG、JPEG、TIFF、WebP、BMP)。
languagestringTesseractの言語コード。デフォルト 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! for Gmail - Chrome拡張機能

GmailのPDF添付ファイルを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.