Skip to content

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.

Terminal window
npm install @xsense/autoblow-sdk
import * as Autoblow from "@xsense/autoblow-sdk";
const { vacuglide, ultra } = await Autoblow.deviceInit("m3ztyf7bxgoi");
//The deviceInit function will return the device objects if the device is connected
//If the device is not connected, it will throw an error
//if the connected device is a Vacuglide, it will return a Vacuglide object
//if the connected device is a Ultra, it will return a Ultra object
if (vacuglide) await demoVacuglide(vacuglide);
if (ultra) await demoUltra(ultra);
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");
});
}

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";
ultra?: Ultra;
vacuglide?: Vacuglide;
}

Throws:

  • DeviceNotConnectedError if device is not connected

Returns the device information.

Returns the current device state.

Returns the cached device state without making a network request.

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.

Returns the list of loaded local scripts.

localScriptReplace(replacedLocalScriptIndex: number, newLocalScriptId: number): Promise<number[]>

Section titled “localScriptReplace(replacedLocalScriptIndex: number, newLocalScriptId: number): Promise<number[]>”

Replaces a local script at the given index with a new script ID.

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.

Starts the local script.

Stops the local script.

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.

Stops the sync script.

syncScriptOffset(offsetTimeMs: number): Promise<DeviceState>

Section titled “syncScriptOffset(offsetTimeMs: number): Promise<DeviceState>”

Sets the sync script offset time in milliseconds.

Starts a firmware update process.

Throws:

  • Error if firmware update fails

firmwareUpdateInfo(): Promise<FirmwareInfo>

Section titled “firmwareUpdateInfo(): Promise<FirmwareInfo>”

Returns firmware update information.

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<UltraDeviceState>

Section titled “goToPosition(position: number, speed: number): Promise<UltraDeviceState>”

Moves the device to a specific position at the given speed.

  • speed-up-button-pressed
  • speed-down-button-pressed
  • mode-button-pressed
  • pause-button-pressed

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.

  • speed-plus-button-pressed
  • speed-minus-button-pressed
  • mode-button-pressed
type DeviceInfo = {
firmwareVersion: number;
firmwareBranch: string;
hardwareVersion: string;
firmwareStatus: "UP_TO_DATE" | "UPDATE_AVAILABLE" | "UPDATE_REQUIRED";
mac: string;
deviceType: "autoblow-ultra" | "vacuglide";
};
type UltraDeviceState = {
operationalMode: UltraOperationalMode;
localScript: number;
localScriptSpeed: number;
motorTemperature: number;
oscillatorTargetSpeed: number;
oscillatorLowPoint: number;
oscillatorHighPoint: number;
syncScriptCurrentTime: number;
syncScriptOffsetTime: number;
syncScriptToken: string;
syncScriptLoop: boolean;
};
type VacuglideDeviceState = {
operationalMode: VacuglideOperationalMode;
localScript: number;
targetSpeed: number;
strokePlusValve: boolean;
strokeMinusValve: boolean;
syncScriptCurrentTime: number;
syncScriptOffsetTime: number;
syncScriptToken: string;
syncScriptLoop: boolean;
};
type Funscript = {
metadata: { id: number; version: number };
actions: { at: number; pos: number }[];
};
type FirmwareInfo = {
branch: number;
firmwareVersion: string;
hardwareVersion: string;
};

The SDK provides several custom error types:

  • DeviceNotConnectedError: Thrown when device is not connected
  • DeviceNotInitializedError: Thrown when device is not initialized
  • DeviceTimeoutError: Thrown when device request times out
  • ValidationError: Thrown when request validation fails
  • DeviceCommandResultError: 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