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 से: एक ऑपरेशन {"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}एक प्रोजेक्ट उसके दस्तावेज़ के साथ
PUT/v1/projects/{id}/documentपूरा दस्तावेज़ बदलें
POST/v1/projects/{id}/runएक ऑपरेशन या स्टेप्स की सूची लागू करें
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 दें और वे प्रोजेक्ट की एक कॉपी पर सिर्फ़ उस फ़ाइल के लिए लागू होते हैं। एक टेम्पलेट, कई फ़ाइलें: 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

त्रुटियाँ

त्रुटियाँ JSON में स्थिर code और आपके अकाउंट की भाषा में detail संदेश के साथ आती हैं। विफल स्टेप बताता है कि कौन-सा पैरामीटर ग़लत था। प्लान के रेंडर खत्म होने पर API 402 और quota_renders के साथ जवाब देती है।

सीमाएँ