Nordic Layers · Nordic Byte

Nyaraka za API

Nordic Layers ni REST API kupitia HTTPS kwenye https://app.layers.nordicbyte.co.uk. Mradi ni hati ya JSON yenye tabaka; unaibadilisha kwa operesheni na kuisafirisha kama picha. Kihariri cha kivinjari kinatumia API ile ile.

Uthibitishaji

Tengeneza ufunguo wa API kwenye paneli ya akaunti yako na uutume kwa kila ombi la /v1. Funguo huanza na nl_key_.

Authorization: Bearer nl_key_…

Mtiririko wa kawaida

  1. Pakia kila picha kwa POST /v1/assets ukiwa na faili kama mwili ghafi wa ombi (PNG, JPEG, WebP, GIF, BMP au TIFF). Jibu lina id yake.
  2. Unda mradi kwa POST /v1/projects ukiwa na width, height na background. Unaweza kupitisha steps za kwanza katika wito huo huo.
  3. Hariri kwa POST /v1/projects/{id}/run: operesheni moja kama {"op": …} au kadhaa kama {"steps": [...]}. Itazame kwa GET /v1/projects/{id}/preview, ambayo ni bure.
  4. Safirisha kwa POST /v1/projects/{id}/export. Jibu lina URL ya faili, au picha yenyewe kwa "response": "image".

Ombi la kwanza

Unda mradi wa 1080×1080 wenye gredienti na kichwa, kisha uusafirishe kama 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
  }'

Sehemu za mwisho

NjiaNjia ya URLInafanya nini
GET/healthHali ya huduma
GET/v1/opsKatalogi ya kila operesheni na vigezo vyake (wazi)
POST/v1/assets?name=photo.jpgPakia picha; mwili ni faili
GET/v1/assetsOrodhesha picha zako na kama mradi unazitumia
DELETE/v1/assets/{id}Futa picha
POST/v1/projectsUnda mradi (turubai, au hati nzima, pamoja na hatua za hiari)
GET/v1/projectsOrodhesha miradi yako
GET/v1/projects/{id}Mradi mmoja pamoja na hati yake
PUT/v1/projects/{id}/documentBadilisha hati nzima
POST/v1/projects/{id}/runTumia operesheni moja au orodha ya hatua
POST/v1/projects/{id}/undoTendua badiliko la mwisho
POST/v1/projects/{id}/redoRudisha
GET/v1/projects/{id}/preview?size=1024Uhakiki wa PNG wa bure, upande mrefu hadi size px
POST/v1/projects/{id}/exportSafirisha PNG, JPEG au WebP; hatua za hiari kwa faili hili pekee
POST/v1/renderRender isiyo na hali ya hati nzima
GET/v1/exportsOrodhesha usafirishaji wako
GET/v1/exports/{id}/filePakua usafirishaji
DELETE/v1/projects/{id}Futa mradi

Operesheni

Kila operesheni ni kitu chenye op na vigezo vyake. Tabaka hurejelewa kwa id au kwa jina; bila layer, tabaka linalotumika hutumiwa. Majina hayajali herufi kubwa au ndogo wala nafasi, kwa hiyo "Linear Dodge (Add)" na "linearDodge" ni modi ile ile ya kuchanganya. Kwa steps, hutekelezwa kwa mpangilio na kusimama kwenye kosa la kwanza (isipokuwa "stopOnError": false); hatua zilizotangulia hubaki zimetumika.

Tabaka

OperesheniVigezoInafanya nini
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.

Maandishi

OperesheniVigezoInafanya nini
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.

Maumbo

OperesheniVigezoInafanya nini
shape.addshape, rect | from+to, color, cornerRadius, lineWidth, nameAdd a rectangle, ellipse or line.
shape.setlayer, color, cornerRadius, lineWidthChange a shape layer.

Kubadilisha umbo

OperesheniVigezoInafanya nini
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.

Marekebisho kwenye tabaka

OperesheniVigezoInafanya nini
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.

Vichujio

OperesheniVigezoInafanya nini
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).

Tabaka za marekebisho

OperesheniVigezoInafanya nini
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).

Barakoa za tabaka

OperesheniVigezoInafanya nini
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.

Athari za tabaka

OperesheniVigezoInafanya nini
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.

Turubai

OperesheniVigezoInafanya nini
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.

Mradi

OperesheniVigezoInafanya nini
project.state—The whole document.

Modi za kuchanganya

Familia za fonti

Violezo

Pitisha steps kwenye wito wa kusafirisha na zitatumika kwenye nakala ya mradi kwa faili hilo pekee. Kiolezo kimoja, faili nyingi: badilisha maandishi kwa text.set na picha kwa layer.setImage, ambayo huhifadhi kisanduku cha tabaka.

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"}
    ]
  }'

Render isiyo na hali

POST /v1/render inapokea document nzima (kama inavyorejeshwa katika project.document), steps za hiari na chaguo za usafirishaji, na haihifadhi mradi. Kwa "response": "image" jibu ni faili la picha.

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

Makosa

Makosa hurudi kama JSON yenye code thabiti na ujumbe wa detail katika lugha ya akaunti yako. Hatua inayoshindwa huripoti ni kigezo gani kilikuwa kibaya. Render za mpango zikiisha, API hujibu 402 pamoja na quota_renders.

Vikomo