REST API

I'm not good at writing articles and English is not my native language. If you find any mistakes please tell

Model

It's important to understand object model that aTimeLogger (and TimeTrackIO in future) operates.
Type is type of activity. It can be Work, Study, Sleep, etc. Type has the following fields: name, color, image, order. Types can be grouped.

Group has the same fields as Type but it can contain other types or groups and it cannot be logged.

Activity is something you are doing (or did). Activity has the following fields: type, state, start_date, intervals, comment. Tracked time is stored in intervals field.

Interval has the following fields: activity, from, to.

Activities tab displays activities (that are in paused or running state) and types. History tab displays intervals. Types tab display Groups and Types.

When user presses on type on Activity tab activity is created with state=running and start_date=current date. If you press pause activity state is changed to paused and interval added.

Endpoint

Authentication endpoint is https://app.atimelogger.com
API endpoint is https://app.atimelogger.com/api/v2

Authentication

There are 2 methods to authenticate: Basic Authentication and OAuth 2. The first one is simple but is not very secure as you pass username/password with every request, the other one is a bit more complex but it's more secure as you pass username/password only once.

Basic Authentication

Everything is simple here - just pass your username/password with every request. Base64 of username:password should be put into Authorization header with 'Basic ' used as prefix, e.g 'Basic dXNlcm5hbWU6cGFzc3dvcmQ='

OAuth 2

The main idea is that you use access token to get data (passing it as parameter with every request) . When access token expires (it happens every 24 hours) you should use refresh token to get new access token. You can read more about OAuth here.
Default methods are used to get/refresh tokens:
1. POST oauth/token?username=${username}&password=${password}&grant_type=password
passing basic auth credentials of web client (use "androidClient" with "secret" password now) to get access and refresh tokens
2. POST oauth/token?refresh_token=${refreshToken}&grant_type=refresh_token passing basic auth credentials of web client (use "androidClient" with "secret" password now) to refresh access token

Methods

GET /types

Optional parameters: offset, limit. Returns list of types

GET /types/{type_guid}

Returns type by guid.

GET /activities

Optional parameters: offset, limit, state (running, paused, stopped), include_type_info (true or false).
Returns list of activities.
Please note, now it works only with running state passed as parameter. And it will return running and paused activities.

GET /activities/{activity_guid}

Return activity by guid

GET /intervals

Optional parameters: offset, limit, from (time in seconds since 1970), to (time in seconds since 1970), types (type guids separated by comma), include_type_info (true or false), order (asc or desc)
Returns list of time intervals for selected period and types.
Please note that groups are not supported in types param. If you pass them they will be simply ignored.

GET /statistics

Work is still in progress. Statistics for selected interval, daily/weekly/monthly statistics will be available here