Autoblow JS SDK
This is a guide for the Autoblow JS SDK. This SDK is used to control the Autoblow devices in a node environment or in the browser.
Installation
Section titled “Installation”npm install @xsense/autoblow-sdkimport * as Autoblow from "@xsense/autoblow-sdk";
const { vacuglide, ultra, vacupump } = await Autoblow.deviceInit("YOUR_DEVICE_TOKEN");//deviceInit returns an object for the connected device type and throws if the device is not connected
if (vacuglide) await demoVacuglide(vacuglide);if (ultra) await demoUltra(ultra);if (vacupump) await demoVacupump(vacupump);
async function demoVacuglide(vacuglide: Autoblow.Vacuglide) { const state = await vacuglide.getState(); console.log(state);
const deviceInfo = await vacuglide.getInfo(); console.log(deviceInfo);
//We can handle the button presses events and make our app react to them vacuglide.deviceEvents.addEventListener("mode-button-pressed", event => { console.log("mode-button-pressed"); });}
async function demoUltra(ultra: Autoblow.Ultra) { const state = await ultra.getState(); console.log(state);
const deviceInfo = await ultra.getInfo(); console.log(deviceInfo);
//We can handle the button presses events and make our app react to them ultra.deviceEvents.addEventListener("pause-button-pressed", event => { console.log("pause-button-pressed"); });}
async function demoVacupump(vacupump: Autoblow.Vacupump) { const deviceInfo = await vacupump.getInfo(); console.log(deviceInfo);
//We can follow the live state: the pump streams it while state updates are enabled vacupump.onStateUpdateEvent(state => { console.log(state.operationalMode, state.currentVacuumKpa); }); await vacupump.stateUpdatesSet(true);
//Hold a gentle vacuum for 10 seconds. Vacuum is in kPa and negative (-60 to 0) await vacupump.manualSetTarget(-10); await vacupump.manualStart(); await new Promise(resolve => setTimeout(resolve, 10000));
//Stopping Manual keeps the current vacuum, so release it first by targeting 0 kPa await vacupump.manualSetTarget(0); await new Promise(resolve => setTimeout(resolve, 3000)); await vacupump.manualStop();}SDK Reference
Section titled “SDK Reference”Common Methods (Both Ultra and Vacuglide)
Section titled “Common Methods (Both Ultra and Vacuglide)”deviceInit(token: string): Promise<DeviceInitResult>
Section titled “deviceInit(token: string): Promise<DeviceInitResult>”Initialize the connection to the given device token.
Returns:
{ deviceInfo: DeviceInfo; deviceToken: string; deviceType: "autoblow-ultra" | "vacuglide" | "vacupump"; ultra?: Ultra; vacuglide?: Vacuglide; vacupump?: Vacupump;}Throws:
DeviceNotConnectedErrorif device is not connected
getInfo(): Promise<DeviceInfo>
Section titled “getInfo(): Promise<DeviceInfo>”Returns the device information.
getState(): Promise<DeviceState>
Section titled “getState(): Promise<DeviceState>”Returns the current device state.
getStateCache(): DeviceState | null
Section titled “getStateCache(): DeviceState | null”Returns the cached device state without making a network request.
getConnectedCluster(): string | null
Section titled “getConnectedCluster(): string | null”Returns the connected cluster string or null if not connected.
estimateLatency(noOfRequests?: number): Promise<number>
Section titled “estimateLatency(noOfRequests?: number): Promise<number>”Estimates the latency of the device by sending a number of requests and calculating the average latency. If no number of requests is given, the default is 10.
Local Script Methods
Section titled “Local Script Methods”localScriptList(): Promise<number[]>
Section titled “localScriptList(): Promise<number[]>”Returns the list of loaded local scripts.
localScriptReplace(replacedLocalScriptIndex: number, newLocalScriptId: number): Promise<number[]> (Ultra)
Section titled “localScriptReplace(replacedLocalScriptIndex: number, newLocalScriptId: number): Promise<number[]> (Ultra)”localScriptReplace(replacedLocalScriptIndex: number, newLocalScriptUuid: string): Promise<number[]> (Vacuglide)
Section titled “localScriptReplace(replacedLocalScriptIndex: number, newLocalScriptUuid: string): Promise<number[]> (Vacuglide)”Replaces the local script at the given index. The Ultra takes the new script’s numeric ID; the Vacuglide takes its UUID.
localScriptSwap(scriptIndexA: number, scriptIndexB: number): Promise<number[]>
Section titled “localScriptSwap(scriptIndexA: number, scriptIndexB: number): Promise<number[]>”Swaps two local scripts at the given indices.
localScriptMove(fromIndex: number, toIndex: number): Promise<number[]>
Section titled “localScriptMove(fromIndex: number, toIndex: number): Promise<number[]>”Moves a local script from one index to another.
localScriptStart(): Promise<DeviceState>
Section titled “localScriptStart(): Promise<DeviceState>”Starts the local script.
localScriptStop(): Promise<DeviceState>
Section titled “localScriptStop(): Promise<DeviceState>”Stops the local script.
Sync Script Methods
Section titled “Sync Script Methods”syncScriptLoadToken(token: string): Promise<DeviceState>
Section titled “syncScriptLoadToken(token: string): Promise<DeviceState>”Loads the sync script with the given sync token.
syncScriptUploadFunscriptUrl(funscriptUrl: string): Promise<DeviceState>
Section titled “syncScriptUploadFunscriptUrl(funscriptUrl: string): Promise<DeviceState>”Downloads the funscript from the given url, converts it to a binary script that autoblow can play and uploads it onto the device.
syncScriptUploadFunscriptFile(funscript: Funscript): Promise<DeviceState>
Section titled “syncScriptUploadFunscriptFile(funscript: Funscript): Promise<DeviceState>”Uploads the given funscript onto the device. The funscript should be a Funscript object.
syncScriptUploadCsvUrl(csvUrl: string): Promise<DeviceState>
Section titled “syncScriptUploadCsvUrl(csvUrl: string): Promise<DeviceState>”Downloads the csv file from the given url, converts it to a binary script that autoblow can play and uploads it onto the device.
syncScriptUploadCsvFile(csvContent: string): Promise<DeviceState>
Section titled “syncScriptUploadCsvFile(csvContent: string): Promise<DeviceState>”Uploads the given csv script onto the device. The csv content should be a string.
syncScriptStart(startTimeMs: number): Promise<DeviceState>
Section titled “syncScriptStart(startTimeMs: number): Promise<DeviceState>”Starts the sync script at the specified time in milliseconds.
syncScriptStop(): Promise<DeviceState>
Section titled “syncScriptStop(): Promise<DeviceState>”Stops the sync script.
syncScriptOffset(offsetTimeMs: number): Promise<DeviceState>
Section titled “syncScriptOffset(offsetTimeMs: number): Promise<DeviceState>”Sets the sync script offset time in milliseconds.
syncScriptLoop(loop: boolean): Promise<DeviceState>
Section titled “syncScriptLoop(loop: boolean): Promise<DeviceState>”Turns looping of the loaded sync script on or off.
Firmware Methods
Section titled “Firmware Methods”firmwareUpdateStart(): Promise<true>
Section titled “firmwareUpdateStart(): Promise<true>”Starts a firmware update process.
Throws:
Errorif firmware update fails
firmwareUpdateInfo(): Promise<FirmwareInfo>
Section titled “firmwareUpdateInfo(): Promise<FirmwareInfo>”Returns the newest firmware release the device would be offered. Also available on the VacuPump.
Throws:
ValidationErrorif the device is already up to date
Ultra-Specific Methods
Section titled “Ultra-Specific Methods”localScriptSet(localScriptIndex: number, speedIndex: number): Promise<UltraDeviceState>
Section titled “localScriptSet(localScriptIndex: number, speedIndex: number): Promise<UltraDeviceState>”Sets the local script to the given index and speed index.
oscillateSet(speed: number, minY: number, maxY: number): Promise<UltraDeviceState>
Section titled “oscillateSet(speed: number, minY: number, maxY: number): Promise<UltraDeviceState>”Sets the oscillation speed and the oscillation range.
oscillateStart(): Promise<UltraDeviceState>
Section titled “oscillateStart(): Promise<UltraDeviceState>”Starts the oscillation.
oscillateStop(): Promise<UltraDeviceState>
Section titled “oscillateStop(): Promise<UltraDeviceState>”Stops the oscillation.
goToPosition(position: number, speed: number): Promise<GenericResult>
Section titled “goToPosition(position: number, speed: number): Promise<GenericResult>”Moves the device to a specific position at the given speed.
This method sends PUT /autoblow/goto and resolves with { success: true } when accepted by the API.
If you need movement status, call getState() separately.
Ultra Events
Section titled “Ultra Events”speed-up-button-pressedspeed-down-button-pressedmode-button-pressedpause-button-pressed
VacuPump Video Sync Methods
Section titled “VacuPump Video Sync Methods”VacuPump firmware 1.01 and newer plays video sync scripts made of pressure exercises instead of funscripts. See the VacuPump API for the script format.
syncScriptSupported(): boolean
Section titled “syncScriptSupported(): boolean”True when the connected firmware advertised the sync_script capability. Check it before showing sync features.
syncScriptLoadToken(token: string): Promise<VacupumpDeviceState>
Section titled “syncScriptLoadToken(token: string): Promise<VacupumpDeviceState>”Loads a stored script on the device without starting playback. Resolves after the device finished downloading.
syncScriptUploadExercises(exercises: VacupumpSyncScriptExercise[]): Promise<VacupumpDeviceState>
Section titled “syncScriptUploadExercises(exercises: VacupumpSyncScriptExercise[]): Promise<VacupumpDeviceState>”Stores the exercises under a new token and loads them on the device.
syncScriptStart(startTimeMs: number): Promise<VacupumpDeviceState>
Section titled “syncScriptStart(startTimeMs: number): Promise<VacupumpDeviceState>”Starts, resumes or seeks to a video position. Re-sending the current position to correct drift is safe.
syncScriptStop(): Promise<VacupumpDeviceState>
Section titled “syncScriptStop(): Promise<VacupumpDeviceState>”Pauses playback and releases the vacuum; the script stays loaded.
syncScriptOffset(offsetTimeMs: number): Promise<VacupumpDeviceState>
Section titled “syncScriptOffset(offsetTimeMs: number): Promise<VacupumpDeviceState>”Sets the sync offset within ±10000 ms. Positive means the device runs ahead of the video.
Vacuglide-Specific Methods
Section titled “Vacuglide-Specific Methods”localScriptSet(localScriptIndex: number): Promise<VacuglideDeviceState>
Section titled “localScriptSet(localScriptIndex: number): Promise<VacuglideDeviceState>”Sets the local script to the given index.
valveStrokePlusSet(valveState: boolean): Promise<VacuglideDeviceState>
Section titled “valveStrokePlusSet(valveState: boolean): Promise<VacuglideDeviceState>”Controls the stroke plus valve state. If the valveState is true, the valve will be opened. If the valveState is false, the valve will be closed.
valveStrokeMinusSet(valveState: boolean): Promise<VacuglideDeviceState>
Section titled “valveStrokeMinusSet(valveState: boolean): Promise<VacuglideDeviceState>”Controls the stroke minus valve state. If the valveState is true, the valve will be opened. If the valveState is false, the valve will be closed.
targetSpeedSet(targetSpeed: number): Promise<VacuglideDeviceState>
Section titled “targetSpeedSet(targetSpeed: number): Promise<VacuglideDeviceState>”Sets the target speed for the device in percent. The value should be between 0 and 100.
targetSpeedStop(): Promise<VacuglideDeviceState>
Section titled “targetSpeedStop(): Promise<VacuglideDeviceState>”Stops the target speed mode.
Vacuglide Events
Section titled “Vacuglide Events”speed-plus-button-pressedspeed-minus-button-pressedmode-button-pressed
DeviceInfo
Section titled “DeviceInfo”type DeviceInfo = { firmwareVersion: number; firmwareBranch: string; hardwareVersion: string; firmwareStatus: "UP_TO_DATE" | "UPDATE_AVAILABLE" | "UPDATE_REQUIRED"; mac: string; deviceType: "autoblow-ultra" | "vacuglide" | "vacupump";};UltraDeviceState
Section titled “UltraDeviceState”type UltraDeviceState = { operationalMode: UltraOperationalMode; localScript: number; localScriptSpeed: number; motorTemperature: number; oscillatorTargetSpeed: number; oscillatorLowPoint: number; oscillatorHighPoint: number; syncScriptCurrentTime: number; syncScriptOffsetTime: number; syncScriptToken: string; syncScriptLoop: boolean;};VacuglideDeviceState
Section titled “VacuglideDeviceState”type VacuglideDeviceState = { operationalMode: VacuglideOperationalMode; localScript: number; targetSpeed: number; strokePlusValve: boolean; strokeMinusValve: boolean; syncScriptCurrentTime: number; syncScriptOffsetTime: number; syncScriptToken: string; syncScriptLoop: boolean;};Funscript
Section titled “Funscript”type Funscript = { metadata: { id: number; version: number }; actions: { at: number; pos: number }[];};FirmwareInfo
Section titled “FirmwareInfo”type FirmwareInfo = { branch: string; firmwareVersion: number; hardwareVersion: string;};Error Handling
Section titled “Error Handling”The SDK provides several custom error types:
DeviceNotConnectedError: Thrown when device is not connectedDeviceNotInitializedError: Thrown when device is not initializedDeviceTimeoutError: Thrown when device request times outValidationError: Thrown when request validation failsDeviceCommandResultError: Thrown when device command fails
- The SDK uses a task queue system to manage requests efficiently
- Device state is cached locally to improve performance
- All methods return promises and can be used with async/await
- Event listeners are available for real-time device button press events
- The SDK automatically handles device type detection and returns the appropriate device instance