MATLAB client for the TofuPilot REST API. Struct-based, with retries and request lifecycle hooks.
Search for TofuPilot in the MATLAB Add-On Explorer and click Install.
git clone https://github.com/tofupilot/matlab.gitThen add to your MATLAB path:
addpath('/path/to/matlab');
savepath; % persist across sessionssdk = tofupilot.TofuPilot('your-api-key');
% Create a test run
req.procedure_id = '550e8400-e29b-41d4-a716-446655440000';
req.serial_number = 'SN-001234';
req.part_number = 'PCB-V1.2';
req.outcome = 'PASS';
req.started_at = '2026-04-07T10:00:00Z';
req.ended_at = '2026-04-07T10:05:00Z';
run = sdk.Runs.create(req);
fprintf('Created run: %s\n', run.id);| Resource | Methods | Docs |
|---|---|---|
| Procedures | list, create, get, delete, update | docs/sdks/procedures |
| Runs | list, create, delete, get, update | docs/sdks/runs |
| Attachments | initialize, delete, finalize | docs/sdks/attachments |
| Units | list, create, delete, get, update, addChild, removeChild | docs/sdks/units |
| Parts | list, create, get, delete, update | docs/sdks/parts |
| Batches | get, delete, update, list, create | docs/sdks/batches |
| Stations | list, create, getCurrent, get, remove, update | docs/sdks/stations |
| User | list | docs/sdks/user |
| Versions | get, delete, create | docs/sdks/versions |
| Revisions | get, delete, update, create | docs/sdks/revisions |
| AttachmentHelpers | upload, download | docs/sdks/attachments |
The SDK provides helpers that handle the three-step upload flow (initialize → PUT → finalize) in a single call:
% Upload from disk
attachId = tofupilot.AttachmentHelpers.upload(sdk.Attachments, 'report.pdf');
% Link to a run
sdk.Runs.update(run.id, struct('attachments', {{attachId}}));
% Download a file
tofupilot.AttachmentHelpers.download(downloadUrl, 'local-report.pdf');now = char(datetime('now', 'TimeZone', 'UTC', 'Format', 'yyyy-MM-dd''T''HH:mm:ss''Z'''));
measurement = struct( ...
'name', 'output_voltage', ...
'outcome', 'PASS', ...
'measured_value', 3.3, ...
'unit', 'V');
phase = struct( ...
'name', 'voltage_check', ...
'outcome', 'PASS', ...
'started_at', now, ...
'ended_at', now, ...
'measurements', {{measurement}});
req.procedure_id = 'your-procedure-id';
req.serial_number = 'SN-001';
req.part_number = 'PCB-V1';
req.outcome = 'PASS';
req.started_at = now;
req.ended_at = now;
req.phases = {{phase}};
run = sdk.Runs.create(req);The client automatically retries on 429 (rate limit) and 5xx errors with exponential backoff (1s, 2s, 4s, ...). Default: 3 retries.
% Custom retry count
sdk = tofupilot.TofuPilot('your-api-key', 'MaxRetries', 5);
% Disable retries
sdk = tofupilot.TofuPilot('your-api-key', 'MaxRetries', 0);Inspect requests and responses with lifecycle hooks:
sdk = tofupilot.TofuPilot('your-api-key', ...
'BeforeRequest', {@(ctx) fprintf('-> %s %s\n', ctx.method, ctx.path)}, ...
'AfterSuccess', {@(ctx, resp) fprintf('OK\n')}, ...
'AfterError', {@(ctx, err) fprintf('Error: %s\n', err.message)});Point the client at your own TofuPilot instance:
sdk = tofupilot.TofuPilot('your-api-key', 'BaseUrl', 'https://your-instance.example.com/api');sdk = tofupilot.TofuPilot('your-api-key', ...
'BaseUrl', 'https://your-server.com/api', ...
'Timeout', 60, ...
'MaxRetries', 5);- MATLAB R2019b or later
- No additional toolboxes required
This SDK is distributed under the MIT License. See LICENSE for details.