Skip to content

This API intends to provide a standardized local interface to any machines used for manufacturing physical things.

Notifications You must be signed in to change notification settings

tyleranton/machine-api

 
 

Repository files navigation

Machine API

This API intends to provide a standardized local interface to any machines used for manufacturing physical things.

Getting started

Config file

Here is a sample config file:

[bambulabs]
machines = [
    { id = "YOUR_ID_HERE", access_code = "YOUR_ACCESS_CODE_HERE", slicer_config = "./config/bambu/" },
    { id = "YOUR_ID_HERE", access_code = "YOUR_ACCESS_CODE_HERE", slicer_config = "./config/bambu/" },
]

[formlabs]

The cli looks by default for a file called machine-api.toml in the current directory. You can also specify a different file with the --config flag.

Running the server

You can run this server locally assuming rust is installed:

cargo run server --address 0.0.0.0:8585

The full API is described by the OpenAPI spec, but to start you can list the connected machines:

$ curl http://localhost:8585/machines
# [{"port":"/dev/ttyACM0","id":"CZPX2418X004XK68718","manufacturer":"Prusa Research (prusa3d.com)","model":"Original Prusa i3 MK3"}]

The ID is what you'll use to identify the machine. You can use that ID to start a print job.

For example, providing both an STL as file, and params as a json object with machine_id the same as above:

curl -X POST -F [email protected] -F 'params={"machine_id": "CZPX2418X004XK68718", "job_name": "my-cool-job"}' http://localhost:8585/print

Note: you may need to allow user permissions to USB devices. Alternatively, you can just run the server as root.

CLI

You can also use machine-api as a CLI. cargo run with no parameters will give the available options.

Contributing

Regenerating the OpenAPI definition file

EXPECTORATE=overwrite cargo test --all openapi

About

This API intends to provide a standardized local interface to any machines used for manufacturing physical things.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Rust 98.4%
  • Nix 1.6%