Trckr relies on a well defined API to communicate between the backend and the frontend applications. This sections describes the current available API endpoints.
https://trckr.trvlr.ch/api/auth/login/
https://trckr.trvlr.ch/api/token-auth/
When a user tries to login the frontend will send a JSON request with following attributes:
{
"username": <username>,
"password": <pw>
}
The backend will reply with either a fail:
{
"non_field_errors":["Unable to log in with provided credentials."]
}
or a success:
{
"token":"eyJ0eXAiOiJKV1QiLCJhb[...]vJzuiWUvZxytJ9yscldA"
}
The token is then used to authenticate for every action the user wants to perform.
To use the token to authenticate other API calls, the token has to be put into the header: Authorization: Token <token>
. The current life time of a token is 365 days.
POST https://trckr-api.trvlr.ch/api/tokens/invalidate/
This action will delete the token used in the authorization header with this request. A post body is not required.
POST https://trckr-api.trvlr.ch/api/user/
Request body:
{
"username" : "testuser",
"email" : "test@example.com",
"password" : "testpassword",
"first_name" : "Max",
"last_name" : "Muster"
}
Response:
{
"id": 8,
"username": "testuser",
"email": "test@example.com",
"first_name": "Max",
"last_name": "Muster",
"token": "450c24407787bba7e14b9386029789c14fa200a0"
}
GET https://trckr-api.trvlr.ch/api/projects/
Response:
[
{
"id": 1,
"name": "test 1",
"description": "foobar",
"modifiedDate": "2018-04-04T19:29:43.296915Z",
"createdDate": "2018-04-04T19:29:43.296847Z"
},
{
"id": 2,
"name": "test project 2",
"description": "hello",
"modifiedDate": "2018-04-04T19:29:57.017325Z",
"createdDate": "2018-04-04T19:29:57.017285Z"
}
]
POST https://trckr-api.trvlr.ch/api/projects/
Request body:
{
"name": "test",
"description": "foo",
}
GET https://trckr-api.trvlr.ch/api/projects/<id>/
Response:
{
"id": 1,
"name": "test 1",
"description": "foobar",
"modifiedDate": "2018-04-04T19:29:43.296915Z",
"createdDate": "2018-04-04T19:29:43.296847Z"
},
PUT https://trckr-api.trvlr.ch/api/projects/<id>/
Request body:
{
"name": "test",
"description": "foo",
}
DELETE https://trckr-api.trvlr.ch/api/projects/<id>/
GET https://trckr-api.trvlr.ch/api/projects/<id>/tasks/
[
{
"id": 2,
"name": "second test task",
"description": "foo",
"project": 1
},
{
"id": 1,
"name": "test task",
"description": "foo",
"project": 1
}
]
POST https://trckr-api.trvlr.ch/api/tasks/
Request body:
{
"name": "second test task",
"description": "foo",
"project": 1
}
Response:
HTTP 201 Created
{
"id": 2,
"name": "second test task",
"description": "foo",
"project": 1
}
GET https://trckr-api.trvlr.ch/api/tasks/<id>
Response:
HTTP 200 OK
{
"id": 2,
"name": "second test task",
"description": "foo",
"project": 1
}
PUT https://trckr-api.trvlr.ch/api/tasks/<id>/
Request body:
{
"name": "second test task",
"description": "bar",
"project": 1
}
GET https://trckr-api.trvlr.ch/api/tasks/<id>/time-entries
Response:
HTTP 200 OK
[
{
"id": 2,
"timeSpent" : 5.123
"description": "foo",
"task": 1
},
{
"id": 3,
"timeSpent" : 10
"description": "bar",
"task": 1
}
]
POST https://trckr-api.trvlr.ch/api/time-entries/
Request body:
{
"description": "foo",
"startTime": "2018-05-10 12:00:00",
"timeSpent" : 5.123,
"task": 1
}
Response:
HTTP 201 Created
{
"id": 2,
"description": "foo",
"startTime": "2018-05-10T12:00:00",
"timeSpent" : 5.123,
"task": 1
}
GET https://trckr-api.trvlr.ch/api/time-entries/<id>
Response:
HTTP 200 OK
{
"id": 2,
"timeSpent" : 5.123
"startTime": "2018-05-10T12:00:00",
"description": "foo",
"task": 1
}
GET https://trckr-api.trvlr.ch/api/time-entries
Response:
HTTP 200 OK
[
{
"id": 2,
"timeSpent" : 5.123
"startTime": "2018-05-10T12:00:00",
"description": "foo",
"task": 1
},
{
"id": 3,
"timeSpent" : 10
"startTime": "2018-05-10T12:00:00",
"description": "bar",
"task": 1
}
]
PUT https://trckr-api.trvlr.ch/api/time-entries/<id>/
Request body:
{
"description": "bar",
"startTime": "2018-05-10 12:00:00",
"timeSpent" : 10,
"task": 1
}