Semestra

Pomodoro plugin

POST
/pomodoro/sessions

Called by the pomodoro card when a focus session completes. Do not use it to log time the user only mentions in chat: sessions come from the timer.

Authorization

cookiesemestra_session<token>

Set by the sign-in endpoints for the web app. Requests other than GET, HEAD and OPTIONS also need the X-Semestra-CSRF header set to the semestra_csrf cookie.

Request Body

application/json
  1. body
instance_id*Instance Id

Pomodoro card instance id

Length1 <= length <= 64
course_id?|

Course the focus time was spent on, if any

started_at*Started At

When the session started (UTC, timezone-aware)

Formatdate-time
ended_at*Ended At

When the session ended (UTC, timezone-aware)

Formatdate-time
duration_sec*Duration Sec

Seconds actually spent, without pauses

Range1 <= value <= 14400
mode?Mode

Only focus sessions count towards statistics

Default"focus"
Value in"focus""short_break""long_break"

Response Body

Successful Response

application/json
  1. response
id*Id
duplicate*Duplicate

True when this session had been recorded before

Example Request
curl -X POST 'https://example.com/pomodoro/sessions' \  -H 'Content-Type: application/json' \  -d '{  "instance_id": "string",  "started_at": "2019-08-24T14:15:22Z",  "ended_at": "2019-08-24T14:15:22Z",  "duration_sec": 1}'
Example Response
{  "id": "string",  "duplicate": true}
GET
/pomodoro/stats

Use to answer how long the user focused, e.g. "how long did I study APS105 this week". Pass course_id to limit to one course (find it with academics.course.find). Defaults to the last 7 days. Days follow the Program's time zone.

Authorization

cookiesemestra_session<token>

Set by the sign-in endpoints for the web app. Requests other than GET, HEAD and OPTIONS also need the X-Semestra-CSRF header set to the semestra_csrf cookie.

Query Parameters

from_date?|

First day (inclusive); defaults to 6 days before to_date

to_date?|

Last day (inclusive); defaults to today

course_id?|

Only count focus time spent on this course

program_id?|

Program whose time zone defines the days; defaults to the active Program

Response Body

Successful Response

application/json
  1. response
from_date*From Date
Formatdate
to_date*To Date
Formatdate
today*Today

Today in the time zone used for the days

Formatdate
timezone*Timezone
total_focus_sec*Total Focus Sec
total_sessions*Total Sessions
days*array<>

Days with focus time, ascending

by_course*array<>

Focus time per course, longest first

Example Request
curl -X GET 'https://example.com/pomodoro/stats'
Example Response
{  "from_date": "2019-08-24",  "to_date": "2019-08-24",  "today": "2019-08-24",  "timezone": "string",  "total_focus_sec": 0,  "total_sessions": 0,  "days": [    {      "date": "2019-08-24",      "focus_sec": 0,      "sessions": 0    }  ],  "by_course": [    {      "course_id": "string",      "focus_sec": 0,      "sessions": 0    }  ]}