Creates a new SenseApiClient instance.
Optional
session: SessionOptional initial Session value.
Optional
options: SenseApiClientOptionsOptional configuration SenseApiClientOptions.
Readonly
emitterEvent emitter for client events.
SenseApiClientEventTypes for the possible events and their payloads.
Returns whether the client currently has an active session.
True if the client has an active session, false otherwise.
Sets the current session and emits a sessionChanged event if changed.
The new session value.
Completes a multi-factor authentication (MFA) login flow with the Sense API.
The MFA token received from the initial login attempt.
The one-time password (OTP) code for MFA verification.
The current date/time on the client device for time synchronization.
SenseApiError If the MFA authentication fails.
Retrieves all devices detected by a specific Sense monitor.
The ID of the Sense monitor to get devices for.
A promise that resolves to an array of Device objects representing the detected devices.
SenseApiError If the API request fails.
UnauthenticatedError If there is no valid session.
Retrieves an overview of a specific Sense monitor.
The ID of the Sense monitor to get an overview for.
A promise that resolves to a MonitorOverview object containing the monitor's overview data.
SenseApiError If the API request fails.
UnauthenticatedError If there is no valid session.
Retrieves the status of a specific Sense monitor.
The ID of the Sense monitor to get the status for.
A promise that resolves to a MonitorStatus object containing the monitor's status data.
SenseApiError If the API request fails.
UnauthenticatedError If there is no valid session.
Retrieves historical trend data for a Sense monitor.
The ID of the Sense monitor to get trends for.
The timezone to use for date calculations, in IANA format (e.g. 'America/New_York'). This should correspond to the timezone of the monitor, as found in the Monitor object returned by getMonitorOverview.
The time scale for which to retrieve trends (e.g. DAY
, WEEK
, MONTH
, YEAR
, CYCLE
).
Optional
startDate: DateOptional start date to retrieve trends from. If not provided, trends will start from the current date.
A promise that resolves to a Trends object containing the trend data.
SenseApiError If the API request fails.
UnauthenticatedError If there is no valid session.
Authenticates a user with the Sense API using email and password credentials.
The email address of the user attempting to authenticate.
The password of the user attempting to authenticate.
A promise that resolves to an MFA token if multi-factor authentication is required, or undefined if authentication is successful without MFA.
This method will:
If this method returns a value, it indicates that multi-factor authentication is required. In this case, the returned MFA token should be used to complete the authentication process using the completeMfaLogin method.
SenseApiError If authentication fails for reasons other than MFA being required.
Starts real-time updates for a monitor.
The ID of the monitor to start real-time updates for.
UnauthenticatedError If there is no valid session.
Stops real-time updates.
A client for interacting with the Sense API.