Get Time Until Due
Calculates the time until the next event is due for a given project and streak ID.
Endpoint
GET /events/:projectId/timeUntilDueMS/:streakId?<streakConfig>
Authentication
This endpoint requires API key authentication. See the Authentication for more information.
Parameters
Path Parameters
-
projectId
- (required)
- The ID of the project.
-
streakId
- (optional)
- The ID of the streak.
- Default is
default
.
Query Parameters
StreakConfig
(optional)
- The object used to customize the streak calculation options.
StreakConfig Fields:
frequencyType
:FrequencyType
- The frequency type of the streak (e.g., daily, weekly, monthly, custom). Events in two consecutive 'frequency periods' will continue a streak, and the amount of time between events is not considered (unless using 'custom' frequency). For example, an event at 1:00am on Monday followed by an event at 11:00pm on Tuesday will count towards a daily streak, even though the two events are more than 24 hours apart.
- Default is
Daily
.
customFrequencyMS
:number
- Custom frequency in milliseconds. Used only when
frequencyType
iscustom
. - Default is
0
.
- Custom frequency in milliseconds. Used only when
weekStartDay
:WeekStartDay
- The start day of the week. Only considered if
frequencyType
isweekly
. - Default is
Monday
.
- The start day of the week. Only considered if
Response
TimeUntilDue
: number
- The time in milliseconds until the next event is due for the provided project ID, streak ID, and configuration.
NodeJS Example
import axios from 'axios';
const getTimeUntilDue = async (projectId, streakId, config) => {
try {
const response = await axios.get(`https://api.streaksapi.com/events/${projectId}/timeUntilDueMS/${streakId}`, {
params: config,
headers: {
'x-api-key': 'YOUR_API_KEY'
}
});
console.log('Time Until Due:', response.data);
} catch (error) {
console.error('Error fetching time until due:', error);
}
};
// Example usage
getTimeUntilDue('123', '456', {
frequencyType: 'daily',
customFrequencyMS: 0,
weekStartDay: 'Monday'
});