レンダー
POST /v1/renders はテンプレートを画像またはPDFにレンダリングします。
# リクエスト
curl https://api.mostlyrender.com/v1/renders \
-H "Authorization: Bearer mr_live_…" \
-H "Content-Type: application/json" \
-d '{
"template": "tpl_abc",
"modifications": { "title": "Hello" },
"output": "png"
}'
| フィールド | 型 | 注記 |
|---|---|---|
template |
string | 必須。 テンプレートID。(templateId も使用可能) |
modifications |
object | レイヤーオーバーライド、レイヤー名でキー付け。テンプレートをパラメータとして参照。 |
output |
string | png (デフォルト)、jpeg、webp、または pdf。 |
async |
boolean | ジョブをキューイングして、インラインレンダリングの代わりに 202 を返します。 |
webhookUrl |
string | 完了時の署名付きコールバック(async を意味します)。非同期とウェブフック参照。 |
notifyEmail |
string | ジョブが完了したときにこのメールアドレスに通知します(async を意味します)。 |
# レスポンス
{
"id": "rnd_abc123",
"url": "https://img.mostlyrender.com/mostlyrender/renders/rnd_abc123.png",
"output": "png"
}
url はパブリックでCDNキャッシュされています。レンダーはアプリの 使用状況 にも記録されます。
# 出力形式
png— ロスレス、透明度対応。デフォルト。jpeg/webp— より小さい。写真に適しています。pdf— ベクトル、印刷用アセットに最適。
# SDK
out = mr.render("tpl_abc", modifications={"title": "Hello"}, output="pdf")
print(out["url"])
1回の呼び出しで多数の画像をレンダリングする場合は、バッチ参照。APIキーなしで <img>/OGに埋め込む場合は、署名付きレンダーURL参照。