NC.js REST API Documentation

REST Endpoints

The current version of the REST API is v3, and all endpoints can currently be found grouped under the /v3/nc/ path. The main concepts are as below:

These API endpoints return JSON objects describing 3D geometry and simulation state, machining process, workpieces, tolerances, and cutting tools.

Custom Apps may need new endpoints for value-added operations. These should be placed under /v3/custom to keep them separate from the baseline endpoints.

Server Events

At startup, the client opens a websocket on the server and listens for notifications. The server emits the following notifications

Server / Client Communication

Upon inital connection to the server, the server will send the packaged client javascript to the browser. This client will then establishes a websocket connection back to the server to listen for the server events described above.

The first action of the client is to GET /v3/nc/state/key, and receive a key state object that describes the initial position of everything in the digital thread model. The client will parse the key state and executes the ApplyDelta logic described below. (Code in data_loader.js

Whenever the tool moves, the server will send an nc:delta event over the websocket, with a delta state object that describes the new dynamic shell and the positions of everything. The client will parse the delta state and executes the ApplyDelta logic described below. Code in cad_manager.js

Other events are occasionally generated, and the client responds by updating the responsive view with new feed rates, spindle speeds, speed slider position, play/pause button, etc.

Client ApplyDelta logic

On receipt of a KeyState or DeltaState, the client invokes the applyDelta function in nc.js

  1. Hide any geometry currently displayed
  2. Call the dynamicShell handler, which attempts to update the dynamic shell if necessary (if newversion > currentversion).
  3. Display any requested geometry which is in our local cache
  4. Queue geometry loads from server for geometry which is not in local cache