REST API – access to full Galvo cut/sub-layer settings (Q-Pulse, interval, scan angle, etc.)?

I’m experimenting with the new LightBurn REST API in LightBurn 2.2 and am trying to retrieve the complete cut settings for a Galvo project.
I’ve successfully paired using the state and project capabilities and am querying:
GET /api/project
GET /api/layers
GET /api/cuts
GET /api/cuts/{index}
GET /api/material-library

For example, C00 is configured with two sub-layers:
C00
├─ Sub-layer 1: Line
│ Speed: 50 mm/s
│ Max Power: 20%
│ Frequency: 30 kHz
│ Q-Pulse Width: 3 ns
│ Number of Passes: 3
│
└─ Sub-layer 2: Fill
Speed: 2000 mm/s
Max Power: 0%
Frequency: 30 kHz
Q-Pulse Width: 4 ns
Bi-directional: Off
Cross Hatch: On
Line Interval: 0.073 mm
Scan Angle: 17°
Number of Passes: 1
Angle Increment: 33.6°

Global Passes: 2

GET /api/cuts/0 returns:
{
“enabled”: true,
“index”: 0,
“kind”: “normal”,
“layer_index”: 0,
“mode”: “cut”,
“name”: “C00100”,
“params”: {
“bi_directional”: true,
“cross_hatch”: false,
“frequency”: 30000,
“kerf”: 0,
“max_power”: 20,
“min_power”: 20,
“num_passes”: 3,
“speed”: 50,
“z_offset”: 0
},
“priority”: 0,
“sub_layers”: [
{
“max_power”: 20,
“speed”: 50,
“z_offset”: 0
},
{
“max_power”: 0,
“speed”: 2000,
“z_offset”: 0
}
]
}

So the API correctly returns quite a lot of the primary Line operation, including frequency and number of passes, and correctly indicates two sub-layers.
However, each entry in sub_layers appears limited to:
max_power
speed
z_offset

I therefore can’t find these settings through the REST API:
Q-Pulse Width
Global Passes

For additional sub-layers:

  • Mode (Line / Fill)
  • Frequency
  • Q-Pulse Width
  • Number of Passes
  • Bi-directional
  • Cross Hatch
  • Line Interval
  • Scan Angle
  • Angle Increment

There may be other Galvo-specific settings missing; these are the ones I’ve tested.
One potential source of confusion is that the top-level params contains:
“bi_directional”: true,
“cross_hatch”: false

but these are not the settings of my second Fill sub-layer, which is actually Bi-directional Off and Cross Hatch On. Those individual sub-layer values don’t appear in the REST response.
I also checked GET /api/material-library. It appears to use the same reduced representation: for a Material Library entry containing the same Line + Fill combination, the second sub-layer again contains only max_power, speed and z_offset.
I’ve confirmed that LightBurn itself has the missing information. Saving the project as .lbrn2 produces fields such as:

Are the complete Galvo cut/sub-layer settings exposed by another REST endpoint or API object that I’ve missed?
Ideally I’m looking for an API representation of each sub-layer containing its mode and complete settings, rather than having to separately read and parse the .lbrn2 project file.
If these fields aren’t currently exposed by the REST API, would exposing the complete sub-layer settings be something that could be added?

LightBurnCompanion_Test_2.lbrn2 (23.5 KB)

This is a Staff question and you asked on Friday night. Do not get discouraged if they do not answer before Monday morning, or later.

Agree with @MikeyH, it’s almost certain something anyone can answer. Anything involving the api information, working, broke and fixed, needs to come from the Lightburn people.

Maybe @Aaron.F can drop by and see if it needs to be looked at by the Lightburn dev staff. I haven’t used the api, so I don’t what you can can’t get at.

Hang in there… it’s only Saturday morning… they need to time to think about other things, such as the meaning of life… :man_shrugging:

:grinning_cat:

It’s ok, I wasn’t expecting an immediate answer. It’s stuff only the devs can advise on, and I’m sure they’ll review this post at some point, and let me know if/when these additional settings will be exposed by the API.

That sounds like a reasonable ask. I’ll forward the report to the dev in charge.

As the Dev in charge, I will admit to an honest omission on my part for those settings for sublayers.

I’ll see what I can do to fix that.

This is why we do RCs, and why the documentation for the api isn’t tagged as final yet :sweat_smile:

Also, I can’t see a way to retrieve which settings are applicable to a given laser, so when I’m retrieving settings for a cut layer, if my laser is a galvo but not MOPA (hence doesn’t support PWM) then that is a setting I need to obtain from the REST API (ideally).

Otherwise I’m loving the API. Thanks for your hard work so far in making it available.

I’ll try to update this to include as much detail as we can to match what you can actually set.

Out of curiosity, what use-case do you see for the parameters you want to retrieve? Not that they shouldn’t be retrievable, I’m just trying to understand what you’re aiming to do… I might find other limitations you didn’t see yet.

Hi Jon,
I’m currently building a LightBurn Companion app. The challenges I’m trying to address:

  • currently the in-use progress timer doesn’t match actual machine time (it gets to 100% before the laser has completed the job, ie the progress bar shows 100% but the laser still has buffered work to complete), and as soon as the job finishes the timer immediately resets to zero.
    So after a job is run, I cannot get an accurate account of the true run-time of the job. If I wasn’t watching exacly when the laser stopped firing, I don’t know exactly how long that job ran for.
    So one of it’s primary functions is to time exactly how long a job runs for (including pause/resume). It will keep a log of each job so once all the jobs for a given project complete, I can see at a glance:
  • total time each individual job took (if graphics between jobs differs and run times change this matters)
  • total time the laser was actually firing (good to track for maintenance planning)
  • overall time from start of first job to end of last.
    These metrics matter as they are how I price my customers jobs and I need to review them after a job is complete to determine if I’d priced it correctly or not.

That’s one function the companion app will address for me.

The 2nd one is even more important.
I’m trying to get a snapshot of every setting in use when the laser fires (speed, power, freq, Q-Pulse, Cross Hatch, angle increment etc).
I need to determine:

  • where did the settings come from (what option in the Material Library was assigned to the layer, or sub-layer)
  • what settings have changed from the job just run before, to this one.
  • If the layer settings were assigned from a stored config in the Material Library but then subsequently tweaked (eg I decided to increas power marginally), then the run parameters are slightly different to the Material Library parameters it was assigned from.

The reason for needing this is primarily as follows:

  • A customer brings me a sample item to be marked
  • I need to run test marks on it, tweaking as I progress, to find the best result possible.
  • similar to how you would use a test-grid, if you don’t have space on the item, and need to do those steps manually.
  • Sometimes I’ll make ~20-30 marks before deciding on which is the best one.
  • Once I’ve chosen one, trying to remember exactly what adjustments I’d made between passes is hard. eg lets say I decide the 24th mark is the best one out of 30. Then I’ve got to remember 6 runs back what was it I changed? My app will dump every setting applicable to the laser for every firing, to the database, and then present me a table showing:
  • a summary of the settings used for that job.
  • what is different between that one and the one before (eg speed changed from 500 to 800, or Freq from 30kHz to 45kHz etc)
    So at a glance I’ll have a quick reference table showing progressive changes made, and which run they relate to, so now I can look at, say run #24, and understand (ok these were the settings that gave the best result, and I’d adjusted freq to 35kHz, but once I went past that, then marking quality reduced, so that is the sweet spot).

So in order to get all that detail to export to the database of job run history, I need to know exactly what settings are configured (per sub-layer, or per main layer as applicable) for the laser at the time I press start.

I’m sure I’ll come across other use cases along the way, but these are the 2 immediate ones I’m trying to address. Unfortunately right now the API doesn’t surface every setting mentioned above so some come from the API but others have to come from the .lbrn2 file, which, if I haven’t saved the job before I hit Start, can be inaccurate, so ideally the API should surface every laser setting per layer, and per sub-layer.

Sorry, I just realised, some of the laser settings I’m currently having to retrieve from prefs.ini, not .lbrn2 as mentioned above.

And looking at the data structure of the prefs.ini file, it seems like you have stored config values for each device, even where some aren’t applicable to that device (eg for my Fiber laser which doesn’t support PWM, the prefs.ini file has a PWM value, even though I can’t set/adjust it on my machine), so the LightBurn App appears to retrieve ALL settings from prefs.ini but then only surface ones that apply to the device in use, and hide others as not applicable).

The API should also surface the same - either it returns all settings, and a way of tagging/flagging settable/applicable, or it should not return them if they don’t actually apply to the device. ie if I can’t set/adjust it in the GUI, then I need to be able to determine from the REST API, the same - this value is returned (so is in prefs.ini) but doesn’t apply to my device and cannot be set. Either that, or the API shouldn’t return that value, so there’s no confusion about whether a returned value is actually applicable.

Hi Ian,

Thank you for the detailed explanation of what you’re trying to do.

Regarding inaccurate time estimations from buffer runs etc., I often prefer using the preview to estimate times, assuming the accelerations and maximum speeds for the machine are correctly set in the device settings

The preview uses these values to estimate completion time, which should normally be relatively accurate if your laser is indeed moving at the speeds you tell it to.

For settings that your specific laser doesn’t use, that may have to be a future release of the REST API as a whole - for now I’ve got the beginnings of a thought on how to handle that, but it’s not yet fully baked.

I have changes to fix the sublayers and source missing information - so that will be available in a release candidate soon (we do need some internal testing/validating first).

Hi Jon,

Yes I use the preview now to estimate job times, and I’ve got it close, and it certainly aids in job costing estimations, but the data the API can give me makes that info much more precise and will allow me to export to a SQL database for historical review.

Thanks for the update. I really appreciate you making the effort to expand what the API can do. I look forward to whatever features you can include. I totally get that some may be delayed to future updates. I’m programming my companion app with the ability to retrofit other output values as they become available in the API down the road. I have a background in IT myself, so I know it’s all but impossible to work out what is required by an API until users get their hands on it and start exploring ways to make use of it. Thanks for all your efforts so far, and I’ll thank you in advance for what you can expand it to do moving forward!

Hi Ian,

I don’t know that it’s got everything you want in it, but you’re welcome to check the incoming API changes that will become the 1.0.0 spec for the LightBurn REST API here.

These changes will be folded in the main branch when we go live with LightBurn 2.2 RC4 (or its full release, whichever comes first). You obviously won’t be able to test these endpoints until then, but hopefully that should offer a lot more than what we previously had.

And it fixed a number of bugs in the original spec as well. Thanks for the report and challenging our initial set of test cases. :slight_smile:

Hi Jon,

Thanks for the updates — I’ve been looking through the new LB-2.2RC4_changes REST API spec and the additional Galvo/sub-layer fields look like they’ll cover nearly everything I was trying to retrieve.
One setting I can’t find in the updated schema is Global Passes from the Galvo Cut Settings dialog. I can see num_passes in LaserCutParams, which I assume corresponds to the Passes setting for the individual base/sub-layer, but I don’t see a separate value for Global Passes.
In an .lbrn2 file this appears to be stored separately as globalRepeat.
Is Global Passes exposed somewhere in the updated REST API that I’ve missed, or would it be possible to include it in the new cut response as well?

Hi Ian,

Damn, I missed that again. :person_facepalming:

I’ll add it in for release, sorry about the distraction-created oversight on my end.

Same as I did before, there’s a PR on the Rest API documentation’s repo so you can read through the addition first, and it’ll go live at the time a build with it becomes available.

I keep forgetting to look at galvo settings specifically, I’ve worked mostly on gantry machines, so my brain tends to focus on that aspect first.

There were quite a few additional settings I had missed on this pass as well. There’s now a differentiation between gantry and galvo settings,and that was a rather big rewrite of the way the cut settings are interacted with.

Hi Jon,

that’s no problem. I know it’s a work in progress, and some of the settings I’m chasing are definitely galvo specific because my fiber and UV are both galvo machines. I appreciate you revisiting it for me. I’ll be sure to put the API to constant use as soon as it’s released!

Did you take a look at the new changes after RC5 came out yet?

This should hopefully have everything you were looking for. Maybe too much :wink:

Hi Jon,

Just wanted to send through an interim update on my testing of the REST API in LightBurn 2.2.00 RC5.

So far, I’ve successfully tested:

  • Retrieving project, device, layer and cut information.
  • Capturing normal cut, image and sublayer settings, including nested parameters.
  • Identifying active image cuts separately from unused normal cuts.
  • Tracking the layer Output checkbox for both normal and image operations.
  • Capturing changes to settings such as speed, power, passes and layer names.
  • Saving and retrieving structured settings and raw API responses.

There were 2 issues I’ve found so far:

  1. Sub-layer 0 name not returned correctly: The REST API wasn’t exposing the name of the first operation (sub-layer 0) as expected, even though subsequent sublayer names were available.
  2. Show checkbox not reflected: Toggling Show ON/OFF doesn’t change /api/layers; the hidden property remains false.

When naming all sub-layers, all but the first one correctly return the new name.
When toggling Show ON and OFF for a layer, /api/layers continues to return “hidden”: false in both states. I’ve compared the complete JSON responses, and they’re identical.

Is the Show checkbox state intended to be exposed through the REST API? If so, is there another endpoint or property I should be using?

Thanks again for providing access to the API for testing.

Thank you for finding the bugs before the release :slight_smile:

The Show checkbox state is indeed supposed to be using the value you are parsing, but it was incorrectly setup in the backend.

I am fixing both issues now. Note that the sub-layer 0 name was not just a problem with reading, but the POST to set it would’ve also been rejected. I’m fixing that too.

Hopefully those will be the last bugs to be found :wink:

REST API for CNC and Laser on CNC