빠른 시작
첫 API 호출까지 세 단계.
- 다음에서 API 키를 생성하세요 계정 › API 키
- Authorization: Bearer 헤더와 함께 v1 엔드포인트 중 하나에 multipart/form-data POST를 전송하세요.
- JSON 응답을 확인하세요 — 성공한 호출은 15분간 유효한 서명된 다운로드 URL을 반환합니다.
기본 URL
인증
모든 요청은 Bearer 토큰으로 API 키가 포함된 Authorization 헤더를 반드시 포함해야 합니다.
Authorization: Bearer pdn_live_a1b2c3d4e5f6...키 형식
pdn_live_<32 hex>— 프로덕션 키. 플랜의 속도 제한에 포함됩니다.pdn_test_<32 hex>— 테스트 키. 동일한 속도 제한; 로그에서 환경을 구분하는 데 유용합니다.
속도 제한
속도 제한은 사용자별, 롤링 1시간 윈도우 기준으로 계산됩니다. 모든 응답에는 X-RateLimit-* 헤더가 포함되어 재시도를 계획할 수 있습니다.
| 플랜 | 시간당 요청 수 |
|---|---|
| Free | 10 |
| Premium | 1,000 |
| Business | 5,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" }
}오류 코드
| Code | HTTP | 의미 |
|---|---|---|
unauthorized | 401 | 누락되었거나 잘못된 형식이거나 취소된 API 키. |
rate_limited | 429 | 플랜의 시간당 속도 제한을 초과했습니다. |
invalid_input | 400 | 요청 본문 또는 매개변수가 검증에 실패했습니다. |
payload_too_large | 413 | 파일 또는 결합된 페이로드가 플랜의 크기 제한을 초과합니다. |
internal_error | 500 | 예기치 않은 서버 오류. 백오프와 함께 재시도해도 안전합니다. |
POST /compress
가능한 경우 Ghostscript를 사용하여 PDF를 압축하며, FPDI 대체를 사용합니다. 서명된 다운로드 URL을 반환합니다.
매개변수 (multipart/form-data)
| 이름 | 유형 | 설명 |
|---|---|---|
| file * | file | 압축할 PDF 파일. |
| level | string | 압축 사전 설정. 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를 단일 문서로 병합합니다.
매개변수
| 이름 | 유형 | 설명 |
|---|---|---|
| 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를 하나 이상의 부분으로 분할합니다. 각 부분은 자체 서명된 다운로드 URL과 함께 반환됩니다.
매개변수
| 이름 | 유형 | 설명 |
|---|---|---|
| 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개 이상의 언어를 지원합니다.
매개변수
| 이름 | 유형 | 설명 |
|---|---|---|
| image * | file | OCR할 이미지 (PNG, JPEG, TIFF, WebP 또는 BMP). |
| language | string | 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);