基本功能
常見用途的範例
了解如何為社群卡片、商品橫幅、證書、發票、出貨標籤和票券等用途,製作範本和請求。
每個範例都會列出要加入範本的圖層,以及填入這些圖層的請求。每次的步驟都相同:
- 加入表格中的圖層,並依照為圖層命名的做法為每個圖層命名。
- 儲存範本,並用卡片上的 Copy Template ID 複製它的 ID。
- 傳送請求。請把
YOUR_API_KEY換成 API Keys 頁面中的金鑰,並把範本 ID 換成你自己的。
社群卡片
社群卡片會在固定大小的圖片上顯示標題和作者,很適合用於部落格文章和連結預覽。畫布請在社群預設尺寸中選擇 Open Graph(1200 × 630 像素)。
| 圖層名稱 | 圖層 | 請求欄位 |
|---|---|---|
title |
文字 | text |
author |
文字 | text |
avatar |
圖片 | src |
curl --request POST \
--url https://api.bannerify.co/v1/templates/createImage \
--header 'Content-Type: application/json' \
--output card.jpg \
--data '{
"apiKey": "YOUR_API_KEY",
"templateId": "tpl_social_card",
"format": "jpeg",
"quality": 85,
"modifications": [
{ "name": "title", "text": "How we cut render time in half" },
{ "name": "author", "text": "An Nguyen" },
{ "name": "avatar", "src": "https://example.com/an.png" }
]
}'
標題的長度各不相同,所以請把 title 的方塊拉得夠高,足以容納最長的標題。如果想要嚴格限制行數,請設定 Text fit 區段中的 Max lines。若要在 Open Graph 標籤中使用這張卡片,請為相同的範本和 modification 建立簽署網址。
商品橫幅
商品橫幅會顯示照片、名稱和價格,也可以顯示特價標章。畫布請選擇 Square(1080 × 1080 像素)。
| 圖層名稱 | 圖層 | 請求欄位 |
|---|---|---|
product-photo |
圖片 | src |
product-name |
文字 | text |
price |
文字 | text |
sale-badge |
文字 | visible |
在 sale-badge 圖層中寫上 Sale,在 Background 區段為它加上背景讓它看起來像標章,並用 Layers 清單中的眼睛圖示把這個圖層隱藏。下方的請求會顯示這個標章。對於沒有特價的商品,請不要在請求中帶入 sale-badge,或是設定 "visible": false。
curl --request POST \
--url https://api.bannerify.co/v1/templates/createStoredImage \
--header 'Content-Type: application/json' \
--data '{
"apiKey": "YOUR_API_KEY",
"templateId": "tpl_product_banner",
"modifications": [
{ "name": "product-photo", "src": "https://example.com/shoes.png" },
{ "name": "product-name", "text": "Trail runner" },
{ "name": "price", "text": "$89" },
{ "name": "sale-badge", "visible": true }
]
}'
回應中包含已儲存檔案的位址:
{
"url": "https://images.bannerify.co/files/0b3c1c1e-5d6f-4c52-9e0a-8f6a4c0f2a11.png"
}
請把 url 與商品一起保存,這樣就不必重新繪製橫幅。對於整個商品目錄,請為每項商品傳送一個請求。單一金鑰可以傳送多少請求,請見用量額度與限制。
證書
證書是一份 PDF,包含受獎人姓名、課程、簽署人,以及一個連到驗證頁面的 QR 碼。PDF 頁面的大小是以點為單位的畫布大小,所以請把 Size 設為 842 × 595,得到橫式的 A4 頁面。
| 圖層名稱 | 圖層 | 請求欄位 |
|---|---|---|
recipient |
文字 | text |
course |
文字 | text |
signature |
簽名 | text, title, date |
verify |
QR 碼 | qrcode |
curl --request POST \
--url https://api.bannerify.co/v1/templates/createPdf \
--header 'Content-Type: application/json' \
--output certificate.pdf \
--data '{
"apiKey": "YOUR_API_KEY",
"templateId": "tpl_certificate",
"modifications": [
{ "name": "recipient", "text": "Mai Tran" },
{ "name": "course", "text": "Advanced image automation" },
{ "name": "signature", "text": "An Nguyen", "title": "Director", "date": "2026-02-02" },
{ "name": "verify", "qrcode": "https://example.com/certificates/1042" }
]
}'
發票
發票是一份 PDF,包含編號、客戶、明細項目表格、總額和付款備註。請把 Size 設為 595 × 842,得到直式的 A4 頁面。
| 圖層名稱 | 圖層 | 請求欄位 |
|---|---|---|
invoice-number |
文字 | text |
customer |
文字 | text |
line-items |
表格 | columns, rows |
totals |
鍵值 | rows |
payment-note |
提醒 | title, text |
curl --request POST \
--url https://api.bannerify.co/v1/templates/createPdf \
--header 'Content-Type: application/json' \
--output invoice.pdf \
--data '{
"apiKey": "YOUR_API_KEY",
"templateId": "tpl_invoice",
"modifications": [
{ "name": "invoice-number", "text": "INV-1042" },
{ "name": "customer", "text": "Acme Studio" },
{
"name": "line-items",
"columns": ["Item", "Qty", "Total"],
"rows": [
{ "Item": "Automate plan", "Qty": 1, "Total": "$29.00" },
{ "Item": "Extra seat", "Qty": 2, "Total": "$10.00" }
]
},
{
"name": "totals",
"rows": [
{ "key": "Subtotal", "value": "$39.00" },
{ "key": "Tax", "value": "$3.90" },
{ "key": "Total", "value": "$42.90" }
]
},
{ "name": "payment-note", "title": "Payment terms", "text": "Pay before 31 Jan 2026." }
]
}'
表格會截掉超出方塊底部的列,而 PDF 只有一頁。請把表格拉得夠高,足以容納你預期最長的發票。
出貨標籤
出貨標籤會顯示地址、服務種類和追蹤編號的條碼。300 dpi 的 4 × 6 英寸標籤是 1200 × 1800 像素,所以請把 Size 設為該值,並以 300 dpi 列印 PNG。
| 圖層名稱 | 圖層 | 請求欄位 |
|---|---|---|
ship-to |
文字 | text |
service |
文字 | text |
tracking-barcode |
條碼 | barcode |
curl --request POST \
--url https://api.bannerify.co/v1/templates/createImage \
--header 'Content-Type: application/json' \
--output label.png \
--data '{
"apiKey": "YOUR_API_KEY",
"templateId": "tpl_shipping_label",
"modifications": [
{ "name": "ship-to", "text": "Mai Tran\n12 Pine Street\nHanoi 100000" },
{ "name": "service", "text": "Express" },
{ "name": "tracking-barcode", "barcode": "1Z999AA10123456784" }
]
}'
text 中的換行會在標籤上換行,所以 ship-to 可以放入整個地址。條碼會在條碼下方印出它的值,所以標籤不需要另外為編號建立文字圖層。
票券
票券會顯示參加者、活動,以及入口掃描器讀取的 QR 碼。請把掃描器預期的網址或代碼,當作 QR 碼的內容傳入。
| 圖層名稱 | 圖層 | 請求欄位 |
|---|---|---|
attendee |
文字 | text |
event |
文字 | text |
ticket-qr |
QR 碼 | qrcode |
curl --request POST \
--url https://api.bannerify.co/v1/templates/createStoredImage \
--header 'Content-Type: application/json' \
--data '{
"apiKey": "YOUR_API_KEY",
"templateId": "tpl_ticket",
"modifications": [
{ "name": "attendee", "text": "Mai Tran" },
{ "name": "event", "text": "Image automation meetup" },
{ "name": "ticket-qr", "qrcode": "https://example.com/tickets/8f3a1c" }
]
}'
回應中包含已儲存圖片的 url,你可以把它放進電子郵件。
相關頁面
- Modifications 列出了請求可以設定的所有欄位。
- 生成圖片和生成 PDF說明了每種請求的選項。
- 圖層類型說明了這裡使用的圖層。