發票生成器 API
程式化 PDF 發票生成
使用我們的 RESTful API 以程式化方式生成專業 PDF 發票。完美整合到您的應用程式中的發票生成功能。
選單
API 端點
POST
https://yourdomain.com/api/generate-pdf
生成並下載 PDF 發票
功能特色
高品質 PDF 生成
使用 Puppeteer 生成像素完美格式的專業 PDF 發票
多語言支援
支援英語、中文(簡體和繁體)、日語、韓語和西班牙語
多種 PDF 格式
支援 A4 和 Letter 頁面格式,可自訂邊距
輸入驗證
全面的發票資料驗證,確保資料完整性
安全性與頻率限制
內建頻率限制和輸入消毒功能確保安全性
高可靠性
強大的錯誤處理和自動資源清理
使用範例
以下是如何使用 API 生成 PDF 發票:
JavaScript
// Using fetch API
const response = await fetch('https://yourdomain.com/api/generate-pdf', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
invoice: {
invoiceNumber: 'INV-001',
date: '2024-07-20',
dueDate: '2024-08-20',
currency: 'USD',
from: {
name: 'Your Company',
email: '[email protected]',
address1: '123 Business St',
city: 'Business City',
state: 'BC',
postalCode: '12345',
country: 'Country'
},
to: {
name: 'Client Name',
email: '[email protected]',
address1: '456 Client Ave',
city: 'Client City',
state: 'CC',
postalCode: '67890',
country: 'Country'
},
items: [{
id: '1',
description: 'Service Description',
quantity: 1,
rate: 100,
amount: 100
}],
subtotal: 100,
taxRate: 10,
tax: 10,
total: 110,
notes: 'Thank you for your business!',
terms: 'Payment due in 30 days'
},
options: {
locale: 'en',
pdfOptions: {
format: 'A4'
}
}
})
});
if (response.ok) {
const blob = await response.blob();
// Download the PDF
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = 'invoice.pdf';
a.click();
}
頻率限制
為確保公平使用和系統穩定性,適用以下頻率限制:
超出頻率限制
如果您超出頻率限制,將收到 429 狀態碼。請等待後再發送其他請求。
10
每個 IP 位址每 15 分鐘 10 個請求
100KB
最大請求大小:100KB
30s
請求逾時:30 秒
常見問題
Test API
Try the API with a sample request: