API ドキュメント
Nordic Layers は https://app.layers.nordicbyte.co.uk で提供される HTTPS 上の REST API です。プロジェクトはレイヤーの JSON ドキュメントで、オペレーションで変更し、画像として書き出します。ブラウザのエディタも同じ API を使っています。
認証
アカウントパネルで API キーを作成し、すべての /v1 リクエストに付けて送ります。キーは nl_key_ で始まります。
Authorization: Bearer nl_key_…
基本的な流れ
- アップロード:
POST /v1/assets で各画像を、ファイルをそのままリクエストボディにして送ります(PNG、JPEG、WebP、GIF、BMP、TIFF)。応答に id が含まれます。 - 作成:
POST /v1/projects で width、height、background を指定してプロジェクトを作成します。同じ呼び出しで最初の steps を渡すこともできます。 - 編集:
POST /v1/projects/{id}/run で、オペレーション 1 つなら {"op": …}、複数なら {"steps": [...]} を送ります。無料の GET /v1/projects/{id}/preview で確認できます。 - 書き出し:
POST /v1/projects/{id}/export。応答にはファイルの URL が含まれ、"response": "image" を指定すると画像そのものが返ります。
最初のリクエスト
グラデーションとタイトルを持つ 1080×1080 のプロジェクトを作成し、WebP として書き出します。
curl -X POST https://app.layers.nordicbyte.co.uk/v1/projects \
-H "Authorization: Bearer $NL_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "First post",
"width": 1080,
"height": 1080,
"steps": [
{"op": "layer.addFill", "gradient": {"colors": ["#1E3A5F", "#64B5F6"], "angle": 135}},
{"op": "text.add", "content": "Hello, layers", "fontName": "Segoe UI", "fontSize": 110, "bold": true, "color": "#FFFFFF"},
{"op": "effects.set", "shadow": {"opacity": 0.4, "distance": 12, "size": 24}}
]
}'
# → {"project": {"id": "…", …}}
curl -X POST https://app.layers.nordicbyte.co.uk/v1/projects/$PROJECT_ID/export \
-H "Authorization: Bearer $NL_KEY" \
-H "Content-Type: application/json" \
-d '{
"format": "webp",
"quality": 90
}'
エンドポイント
| メソッド | パス | 内容 |
|---|
GET | /health | サービスの状態 |
GET | /v1/ops | すべてのオペレーションとそのパラメーターのカタログ(公開) |
POST | /v1/assets?name=photo.jpg | 画像をアップロード。ボディがそのままファイル |
GET | /v1/assets | 自分の画像と、プロジェクトで使われているかの一覧 |
DELETE | /v1/assets/{id} | 画像を削除 |
POST | /v1/projects | プロジェクトを作成(キャンバス、またはドキュメント全体と、任意のステップ) |
GET | /v1/projects | 自分のプロジェクトの一覧 |
GET | /v1/projects/{id} | ドキュメント付きの 1 つのプロジェクト |
PUT | /v1/projects/{id}/document | ドキュメント全体を置き換え |
POST | /v1/projects/{id}/run | オペレーション 1 つ、またはステップのリストを適用 |
POST | /v1/projects/{id}/undo | 直前の変更を元に戻す |
POST | /v1/projects/{id}/redo | やり直し |
GET | /v1/projects/{id}/preview?size=1024 | 無料の PNG プレビュー。長辺は size px まで |
POST | /v1/projects/{id}/export | PNG、JPEG、WebP を書き出し。このファイルだけに適用する任意のステップ付き |
POST | /v1/render | ドキュメント全体のステートレスレンダリング |
GET | /v1/exports | 自分の書き出しの一覧 |
GET | /v1/exports/{id}/file | 書き出しをダウンロード |
DELETE | /v1/projects/{id} | プロジェクトを削除 |
オペレーション
すべてのオペレーションは op とそのパラメーターを持つオブジェクトです。レイヤーは id または名前で指定し、layer を省略するとアクティブなレイヤーが使われます。名前は大文字小文字と空白を無視するため、"Linear Dodge (Add)" と "linearDodge" は同じ描画モードです。steps を使うと順番に実行され、最初のエラーで停止します("stopOnError": false の場合を除く)。それ以前のステップは適用されたままです。
レイヤー
| オペレーション | パラメーター | 内容 |
|---|
layer.add | color, name | Alias of layer.addFill (the web has no empty pixel layers). |
layer.addFill | color | gradient {colors: [..], angle, type: linear|radial}, name, above, atBottom | A colour or gradient layer the size of the canvas. |
layer.addImage | asset_id | color, name, rect | origin | center, width, height, fit (stretch|contain|cover), fitCanvas (contain|cover), above, atBottom, opacity, blendMode | Add an uploaded image (asset_id) or a solid colour (color). |
layer.clip | layer | Clip a layer to the one below it (clipping mask). |
layer.delete | layer | layers | Delete layers. |
layer.duplicate | layer, name | Copy a layer above itself. |
layer.get | layer | One layer with all its settings. |
layer.list | — | Layers from bottom to top. |
layer.move | layer, above | below (layer), toTop, atBottom, index, offset | Reorder a layer. |
layer.rename | layer, name | Rename a layer. |
layer.select | layer | Make a layer the active one. |
layer.setBlendMode | layer | layers, blendMode (normal, darken, multiply, colorBurn, linearBurn, lighten, screen, colorDodge, linearDodge, overlay, softLight, hardLight, difference, exclusion, subtract, divide, hue, saturation, color, luminosity) | Blend mode. |
layer.setFill | layer, color | gradient | Change a fill layer's colour or gradient. |
layer.setImage | layer, asset_id, fit (stretch|contain|cover) | Replace a layer's image and keep its box (templates). |
layer.setOpacity | layer | layers, opacity | Layer opacity, 0 to 1. |
layer.setVisible | layer | layers, visible | Show or hide layers. |
layer.unclip | layer | Release a clipping mask. |
テキスト
| オペレーション | パラメーター | 内容 |
|---|
text.add | content, fontName, fontSize, color, alignment, leading, bold, italic, boxWidth, origin | center, name | Add a text layer. |
text.defaults | — | Fonts on the server and whether complex scripts are shaped. |
text.set | layer, content, fontName, fontSize, color, alignment, leading, bold, italic, boxWidth | Change a text layer. |
シェイプ
| オペレーション | パラメーター | 内容 |
|---|
shape.add | shape, rect | from+to, color, cornerRadius, lineWidth, name | Add a rectangle, ellipse or line. |
shape.set | layer, color, cornerRadius, lineWidth | Change a shape layer. |
| オペレーション | パラメーター | 内容 |
|---|
transform.flip | layer | layers, axis (horizontal|vertical) | Flip horizontally or vertically. |
transform.move | layer | layers, dx, dy | to [x, y] | Move by dx/dy or to a point. |
transform.rotate | layer | layers, angle | Rotate by an angle (degrees, clockwise). |
transform.scale | layer | layers, factor | percent | width | height | Scale around each layer's centre. |
transform.set | layer | layers, x, y, width, height, rotation, flipX, flipY | Box, rotation and flips. |
レイヤーの色調補正
| オペレーション | パラメーター | 内容 |
|---|
adjust.blackWhite | layer | layers, reds, yellows, greens, cyans, blues, magentas, tint, tintHue, tintSaturation | Non-destructive blackWhite on a layer (adds it or updates it). |
adjust.brightnessContrast | layer | layers, brightness, contrast | Non-destructive brightnessContrast on a layer (adds it or updates it). |
adjust.clear | layer | layers | Remove every adjustment and filter from a layer. |
adjust.colorBalance | layer | layers, shadows, midtones, highlights, preserveLuminosity | Non-destructive colorBalance on a layer (adds it or updates it). |
adjust.curves | layer | layers, rgb, red, green, blue | Non-destructive curves on a layer (adds it or updates it). |
adjust.exposure | layer | layers, exposure, offset, gamma | Non-destructive exposure on a layer (adds it or updates it). |
adjust.gradientMap | layer | layers, shadows, highlights, reversed | Non-destructive gradientMap on a layer (adds it or updates it). |
adjust.grain | layer | layers, amount, size, seed | Non-destructive grain on a layer (adds it or updates it). |
adjust.hueSaturation | layer | layers, hue, saturation, lightness, colorize | Non-destructive hueSaturation on a layer (adds it or updates it). |
adjust.invert | layer | layers, no settings | Non-destructive invert on a layer (adds it or updates it). |
adjust.levels | layer | layers, black, white, gamma, outputBlack, outputWhite | Non-destructive levels on a layer (adds it or updates it). |
adjust.remove | layer | layers, kind | Remove one adjustment or filter from a layer. |
フィルター
| オペレーション | パラメーター | 内容 |
|---|
filter.addNoise | layer | layers, amount, gaussian, monochromatic, seed | Non-destructive addNoise on a layer (adds it or updates it). |
filter.gaussianBlur | layer | layers, radius | Non-destructive gaussianBlur on a layer (adds it or updates it). |
filter.motionBlur | layer | layers, angle, distance | Non-destructive motionBlur on a layer (adds it or updates it). |
filter.pixelate | layer | layers, size | Non-destructive pixelate on a layer (adds it or updates it). |
filter.sharpen | layer | layers, amount, radius, threshold | Non-destructive sharpen on a layer (adds it or updates it). |
filter.vignette | layer | layers, amount, midpoint, roundness, feather, color | Non-destructive vignette on a layer (adds it or updates it). |
調整レイヤー
| オペレーション | パラメーター | 内容 |
|---|
adjustmentLayer.add | kind, settings…, name, above | An adjustment layer: changes everything below it. |
adjustmentLayer.get | layer | An adjustment layer's settings. |
adjustmentLayer.set | layer, settings… | Change an adjustment layer (partial). |
レイヤーマスク
| オペレーション | パラメーター | 内容 |
|---|
mask.add | layer, reveal | hide | rect | ellipse (rect) | gradient (from, to) | asset_id (+ rect), feather, invert, cornerRadius | Add or replace a layer mask. |
mask.blur | layer, radius | Feather the layer mask. |
mask.delete | layer | Remove the layer mask. |
mask.invert | layer | Invert the layer mask. |
mask.setEnabled | layer, enabled | Turn the layer mask on or off. |
レイヤー効果
| オペレーション | パラメーター | 内容 |
|---|
effects.copy | from, layer | layers | Copy effects from one layer to others. |
effects.get | layer | A layer's effects. |
effects.remove | layer | layers, kinds | Remove effects (all, or the ones named). |
effects.set | layer | layers, shadow {…}, stroke {…}, outerGlow {…}, colorOverlay {…} | Set effects (partial): shadow, outerGlow, stroke, colorOverlay. |
effects.setEnabled | layer, kind, enabled | Turn one effect on or off. |
キャンバス
| オペレーション | パラメーター | 内容 |
|---|
canvas.crop | rect [x, y, width, height] | Crop the canvas to a rectangle. |
canvas.imageSize | width and/or height, or percent | Scale the whole document. |
canvas.setBackground | color | Background colour, or null for transparent. |
canvas.size | width, height, anchor (topLeft…bottomRight, default center) | Change the canvas without scaling layers. |
プロジェクト
| オペレーション | パラメーター | 内容 |
|---|
project.state | — | The whole document. |
描画モード
フォントファミリー
テンプレート
書き出し呼び出しに steps を渡すと、プロジェクトのコピーに適用され、そのファイルだけに反映されます。1 つのテンプレートから多数のファイルを。text.set でテキストを、layer.setImage で写真を変更でき、レイヤーのボックスは維持されます。
curl -X POST https://app.layers.nordicbyte.co.uk/v1/projects/$TEMPLATE_ID/export \
-H "Authorization: Bearer $NL_KEY" \
-H "Content-Type: application/json" \
-d '{
"format": "png",
"steps": [
{"op": "text.set", "layer": "Title", "content": "Nueva colección"},
{"op": "layer.setImage", "layer": "Photo", "asset_id": "photo_dunes"}
]
}'
ステートレスレンダリング
POST /v1/render は document 全体(project.document で返されるもの)、任意の steps、書き出しオプションを受け取り、プロジェクトは保存しません。"response": "image" を指定すると、応答は画像ファイルになります。
curl -X POST https://app.layers.nordicbyte.co.uk/v1/render \
-H "Authorization: Bearer $NL_KEY" \
-H "Content-Type: application/json" \
-d '{
"document": {"width": 1200, "height": 630, "background": "#1E3A5F", "layers": ["…"]},
"format": "png",
"response": "image"
}' \
-o card.png
エラー
エラーは、固定の code と、アカウントの言語による detail メッセージ付きの JSON で返ります。失敗したステップでは、どのパラメーターが誤っていたかが示されます。プランのレンダリング数を使い切ると、API は 402 と quota_renders を返します。
制限
- アップロードは 50 MB、1 辺 12,000 px まで。
- キャンバスは 1 辺 20,000 px まで、かつプランのメガピクセル数の範囲内。
- 1 回の呼び出しにつき最大 200 ステップ。
- プレビューは長辺 2,048 px まで。
- メガピクセル、レイヤー、プロジェクト、ストレージ、月あたりのレンダリング数はプランによって異なります。料金をご覧ください。