Hierarchy

Constructors

Methods

  • Parameters

    Returns Promise<string>

    Description

    Restores data to a device from a CSV file in TagoIO Files.

    See

    https://help.tago.io/portal/en/kb/articles/device-data#Importing Importing

    Example

    If receive an error "Authorization Denied", check policy Device / Import Data in Access Management.

    const result = await Resources.devices.dataRestore({
    deviceID: "device-id-123",
    file_address: "/backups/backup.csv"
    });
    console.log(result); // Data import added to the queue successfully!
  • Parameters

    • deviceID: string

    Returns Promise<string>

    Description

    Deletes a device from your application.

    See

    https://help.tago.io/portal/en/kb/articles/3-devices Devices

    Example

    If receive an error "Authorization Denied", check policy Device / Delete in Access Management.

    const result = await Resources.devices.delete("device-id-123");
    console.log(result); // Successfully Removed
  • Experimental

    Parameters

    • deviceID: string
    • chunkID: string

    Returns Promise<string>

    Description

    Deletes a chunk from a immutable device.

    See

    https://help.tago.io/portal/en/kb/articles/chunk-management#Delete_chunks Delete chunks

    Example

    If receive an error "Authorization Denied", check policy Device / Manage chunks in Access Management.

    const result = await Resources.devices.deleteChunk("device-id-123", "chunk-id-123");
    console.log(result); // Chunk chunk-id-123 deleted
  • Parameters

    • deviceId: string
    • Optional queryParams: DataQuery

    Returns Promise<string>

    Description

    Delete data records in a mutable device using the profile token and device ID.

    See the example to understand how to use this method properly to have full control on what to delete.

    ! If query parameters are empty, last 15 data for the device will be deleted.

    See

    https://help.tago.io/portal/en/kb/articles/device-data#Editing_and_deleting_variables_individually Editing and deleting variables individually

    Example

    If receive an error "Authorization Denied", check policy Device / Delete data in Access Management.

    const result = await Resources.devices.deleteDeviceData("device-id-123", {
    ids: ["record-id-1", "record-id-2"]
    });
    console.log(result); // 1 Data Removed
  • Parameters

    Returns Promise<string>

    Description

    Edit data records in a mutable device using the profile token and device ID.

    The updatedData can be a single data record or an array of records to be updated, each of the records must have the id of the record and the fields to be updated.

    See

    https://help.tago.io/portal/en/kb/articles/device-data#Editing_and_deleting_variables_individually Editing and deleting variables individually

    Example

    If receive an error "Authorization Denied", check policy Device / Edit data in Access Management.

    const result = await Resources.devices.editDeviceData("myDeviceId", {
    id: "idOfTheRecord",
    value: "new value",
    unit: "new unit"
    });
    console.log(result); // 1 item(s) updated
  • Parameters

    • deviceId: string
    • Optional queryParams: DataQuery

    Returns Promise<Data[]>

    Description

    Retrieves data from all variables in the device.

    See

    https://help.tago.io/portal/en/kb/articles/device-data Device data management

    Example

    If receive an error "Authorization Denied", check policy Device / Get data in Access Management.

    const data = await Resources.devices.getDeviceData("device-id-123", {
    qty: 10,
    variables: ["temperature"]
    });
    console.log(data); // [ { id: 'data-id-123', value: 55, variable: 'temperature' ... } ]
  • Experimental

    Parameters

    Returns AsyncGenerator<Data[], void, unknown>

    Description

    Retrieves data from device using streaming approach.

    See

    https://help.tago.io/portal/en/kb/articles/device-data Device data management

    Example

    If receive an error "Authorization Denied", check policy Device / Get data in Access Management.

    for await (const data of await Resources.devices.getDeviceDataStreaming("device-id-123")) {
    console.log(data);
    }
  • Parameters

    • deviceID: string

    Returns Promise<DeviceInfo>

    Description

    Retrieves detailed information about a specific device.

    See

    https://help.tago.io/portal/en/kb/articles/3-devices Devices

    Example

    If receive an error "Authorization Denied", check policy Device / Access in Access Management.

    const deviceInfo = await Resources.devices.info("device-id-123");
    console.log(deviceInfo); // { active: true, bucket: { id: 'device-id-123', name: 'My Device' } ... }
  • Type Parameters

    Parameters

    • Optional queryObj: T

    Returns Promise<DeviceListItem<T["fields"] extends ("type" | "id" | "active" | "network" | "name" | "visible" | "description" | "updated_at" | "profile" | "connector" | "created_at" | "bucket" | "tags" | "last_input" | "payload_decoder" | "rpm")[]
        ? any[any][number]
        : "id" | "name">[]>

    Description

    Lists all devices from your application with pagination support.

    See

    https://help.tago.io/portal/en/kb/articles/3-devices Devices

    Example

    If receive an error "Authorization Denied", check policy Device / Access in Access Management.

    const list = await Resources.devices.list({
    page: 1,
    fields: ["id", "name"],
    amount: 10,
    orderBy: ["name", "asc"]
    });
    console.log(list); // [ { id: '123', name: 'Device #1' ...}, { id: '456', name: 'Device #2' ...} ]
  • Parameters

    Returns AsyncGenerator<DeviceListItem<"type" | "id" | "active" | "network" | "name" | "visible" | "description" | "updated_at" | "profile" | "connector" | "created_at" | "bucket" | "tags" | "last_input" | "payload_decoder" | "rpm">[], void, unknown>

    Description

    Gets a streaming list of devices from the application.

    See

    https://help.tago.io/portal/en/kb/articles/3-devices Devices

    Example

    If receive an error "Authorization Denied", check policy Device / Access in Access Management.

    for await (const items of await Resources.devices.listStreaming({ name: "*sensor*" })) {
    console.log(items);
    }
  • Parameters

    Returns Promise<string>

    Description

    Sends data to a device.

    See

    https://help.tago.io/portal/en/kb/articles/95-device-emulator Device Emulator

    Example

    If receive an error "Authorization Denied", check policy Device / Send data in Access Management.

    const result = await Resources.devices.sendDeviceData("device-id-123", {
    variable: "temperature",
    unit: "F",
    value: 55,
    location: { lat: 42.2974279, lng: -85.628292 }
    });
    console.log(result); // 1 Data Added
  • Experimental

    Parameters

    Returns Promise<string>

    Description

    Streams data to a device in chunks.

    See

    https://help.tago.io/portal/en/kb/articles/95-device-emulator Device Emulator

    Example

    If receive an error "Authorization Denied", check policy Device / Send data in Access Management.

    const result = await Resources.devices.sendDeviceDataStreaming("device-id-123",
    [{
    variable: "temperature",
    value: 55,
    unit: "F",
    }],
    { poolingRecordQty: 1000 }
    );
    console.log(result);
  • Parameters

    • token: string

    Returns Promise<string>

    Description

    Deletes a device token.

    See

    https://help.tago.io/portal/en/kb/articles/4-device-token Device Token

    Example

    If receive an error "Authorization Denied", check policy Device / Token access in Access Management.

    const result = await Resources.devices.tokenDelete("token-123");
    console.log(result); // Token Successfully Removed
  • Type Parameters

    Parameters

    • deviceID: string
    • Optional queryObj: T

    Returns Promise<DeviceTokenDataList<T["fields"] extends (keyof DeviceTokenData)[]
        ? any[any][number]
        : "name" | "token" | "permission">[]>

    Description

    Lists all tokens for a device with pagination support.

    See

    https://help.tago.io/portal/en/kb/articles/4-device-token Device Token

    Example

    If receive an error "Authorization Denied", check policy Device / Token access in Access Management.

    const tokens = await Resources.devices.tokenList("device-id-123", {
    page: 1,
    fields: ["name", "token"],
    amount: 10
    });
    console.log(tokens); // [ { name: 'Default', token: 'token-id-123', expire_time: 'never' } ]