Nordic Layers · Nordic Byte

API ドキュメント

Nordic Layers は https://app.layers.nordicbyte.co.uk で提供される HTTPS 上の REST API です。プロジェクトはレイヤーの JSON ドキュメントで、オペレーションで変更し、画像として書き出します。ブラウザのエディタも同じ API を使っています。

認証

アカウントパネルで API キーを作成し、すべての /v1 リクエストに付けて送ります。キーは nl_key_ で始まります。

Authorization: Bearer nl_key_…

基本的な流れ

  1. アップロード:POST /v1/assets で各画像を、ファイルをそのままリクエストボディにして送ります(PNG、JPEG、WebP、GIF、BMP、TIFF)。応答に id が含まれます。
  2. 作成:POST /v1/projects で width、height、background を指定してプロジェクトを作成します。同じ呼び出しで最初の steps を渡すこともできます。
  3. 編集:POST /v1/projects/{id}/run で、オペレーション 1 つなら {"op": …}、複数なら {"steps": [...]} を送ります。無料の GET /v1/projects/{id}/preview で確認できます。
  4. 書き出し: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}/exportPNG、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.addcolor, nameAlias of layer.addFill (the web has no empty pixel layers).
layer.addFillcolor | gradient {colors: [..], angle, type: linear|radial}, name, above, atBottomA colour or gradient layer the size of the canvas.
layer.addImageasset_id | color, name, rect | origin | center, width, height, fit (stretch|contain|cover), fitCanvas (contain|cover), above, atBottom, opacity, blendModeAdd an uploaded image (asset_id) or a solid colour (color).
layer.cliplayerClip a layer to the one below it (clipping mask).
layer.deletelayer | layersDelete layers.
layer.duplicatelayer, nameCopy a layer above itself.
layer.getlayerOne layer with all its settings.
layer.list—Layers from bottom to top.
layer.movelayer, above | below (layer), toTop, atBottom, index, offsetReorder a layer.
layer.renamelayer, nameRename a layer.
layer.selectlayerMake a layer the active one.
layer.setBlendModelayer | 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.setFilllayer, color | gradientChange a fill layer's colour or gradient.
layer.setImagelayer, asset_id, fit (stretch|contain|cover)Replace a layer's image and keep its box (templates).
layer.setOpacitylayer | layers, opacityLayer opacity, 0 to 1.
layer.setVisiblelayer | layers, visibleShow or hide layers.
layer.uncliplayerRelease a clipping mask.

テキスト

オペレーションパラメーター内容
text.addcontent, fontName, fontSize, color, alignment, leading, bold, italic, boxWidth, origin | center, nameAdd a text layer.
text.defaults—Fonts on the server and whether complex scripts are shaped.
text.setlayer, content, fontName, fontSize, color, alignment, leading, bold, italic, boxWidthChange a text layer.

シェイプ

オペレーションパラメーター内容
shape.addshape, rect | from+to, color, cornerRadius, lineWidth, nameAdd a rectangle, ellipse or line.
shape.setlayer, color, cornerRadius, lineWidthChange a shape layer.

変形

オペレーションパラメーター内容
transform.fliplayer | layers, axis (horizontal|vertical)Flip horizontally or vertically.
transform.movelayer | layers, dx, dy | to [x, y]Move by dx/dy or to a point.
transform.rotatelayer | layers, angleRotate by an angle (degrees, clockwise).
transform.scalelayer | layers, factor | percent | width | heightScale around each layer's centre.
transform.setlayer | layers, x, y, width, height, rotation, flipX, flipYBox, rotation and flips.

レイヤーの色調補正

オペレーションパラメーター内容
adjust.blackWhitelayer | layers, reds, yellows, greens, cyans, blues, magentas, tint, tintHue, tintSaturationNon-destructive blackWhite on a layer (adds it or updates it).
adjust.brightnessContrastlayer | layers, brightness, contrastNon-destructive brightnessContrast on a layer (adds it or updates it).
adjust.clearlayer | layersRemove every adjustment and filter from a layer.
adjust.colorBalancelayer | layers, shadows, midtones, highlights, preserveLuminosityNon-destructive colorBalance on a layer (adds it or updates it).
adjust.curveslayer | layers, rgb, red, green, blueNon-destructive curves on a layer (adds it or updates it).
adjust.exposurelayer | layers, exposure, offset, gammaNon-destructive exposure on a layer (adds it or updates it).
adjust.gradientMaplayer | layers, shadows, highlights, reversedNon-destructive gradientMap on a layer (adds it or updates it).
adjust.grainlayer | layers, amount, size, seedNon-destructive grain on a layer (adds it or updates it).
adjust.hueSaturationlayer | layers, hue, saturation, lightness, colorizeNon-destructive hueSaturation on a layer (adds it or updates it).
adjust.invertlayer | layers, no settingsNon-destructive invert on a layer (adds it or updates it).
adjust.levelslayer | layers, black, white, gamma, outputBlack, outputWhiteNon-destructive levels on a layer (adds it or updates it).
adjust.removelayer | layers, kindRemove one adjustment or filter from a layer.

フィルター

オペレーションパラメーター内容
filter.addNoiselayer | layers, amount, gaussian, monochromatic, seedNon-destructive addNoise on a layer (adds it or updates it).
filter.gaussianBlurlayer | layers, radiusNon-destructive gaussianBlur on a layer (adds it or updates it).
filter.motionBlurlayer | layers, angle, distanceNon-destructive motionBlur on a layer (adds it or updates it).
filter.pixelatelayer | layers, sizeNon-destructive pixelate on a layer (adds it or updates it).
filter.sharpenlayer | layers, amount, radius, thresholdNon-destructive sharpen on a layer (adds it or updates it).
filter.vignettelayer | layers, amount, midpoint, roundness, feather, colorNon-destructive vignette on a layer (adds it or updates it).

調整レイヤー

オペレーションパラメーター内容
adjustmentLayer.addkind, settings…, name, aboveAn adjustment layer: changes everything below it.
adjustmentLayer.getlayerAn adjustment layer's settings.
adjustmentLayer.setlayer, settings…Change an adjustment layer (partial).

レイヤーマスク

オペレーションパラメーター内容
mask.addlayer, reveal | hide | rect | ellipse (rect) | gradient (from, to) | asset_id (+ rect), feather, invert, cornerRadiusAdd or replace a layer mask.
mask.blurlayer, radiusFeather the layer mask.
mask.deletelayerRemove the layer mask.
mask.invertlayerInvert the layer mask.
mask.setEnabledlayer, enabledTurn the layer mask on or off.

レイヤー効果

オペレーションパラメーター内容
effects.copyfrom, layer | layersCopy effects from one layer to others.
effects.getlayerA layer's effects.
effects.removelayer | layers, kindsRemove effects (all, or the ones named).
effects.setlayer | layers, shadow {…}, stroke {…}, outerGlow {…}, colorOverlay {…}Set effects (partial): shadow, outerGlow, stroke, colorOverlay.
effects.setEnabledlayer, kind, enabledTurn one effect on or off.

キャンバス

オペレーションパラメーター内容
canvas.croprect [x, y, width, height]Crop the canvas to a rectangle.
canvas.imageSizewidth and/or height, or percentScale the whole document.
canvas.setBackgroundcolorBackground colour, or null for transparent.
canvas.sizewidth, 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 を返します。

制限