Visits - Proj-P/project-p-api GitHub Wiki

Insert a visit

POST /visits

Parameters
Name Type Description
start_time int Start time in UNIX time
end_time int End time in UNIX time
Response
Status: 201 Created
Content-Type: application/json
{
  "code": 201,
  "message": "Visit 2 has been uploaded successfully.",
  "visit": {
    "duration": 40,
    "end_time": "Mon, 09 Sep 2019 11:46:32 GMT",
    "id": 2,
    "location_id": 1,
    "start_time": "Mon, 09 Sep 2019 11:45:52 GMT"
  }
}

Get all visits

GET /visits

Response
Status: 200 OK
Content-Type: application/json
[
  {
    "duration": 10,
    "end_time": "Mon, 09 Sep 2019 11:45:32 GMT",
    "id": 1,
    "location_id": 1,
    "start_time": "Mon, 09 Sep 2019 11:45:22 GMT"
  },
  {
    "duration": 40,
    "end_time": "Mon, 09 Sep 2019 11:46:32 GMT",
    "id": 2,
    "location_id": 1,
    "start_time": "Mon, 09 Sep 2019 11:45:52 GMT"
  }
]

Get a visit

GET /visits/:id

Response
Status: 200 OK
Content-Type: application/json
{
  "duration": 19,
  "end_time": "Tue, 10 Sep 2019 12:23:32 GMT",
  "id": 3,
  "location_id": 1,
  "start_time": "Tue, 10 Sep 2019 12:23:13 GMT"
}

Get all visits in a certain period

GET /visits/:from/:to

Date format is YYYY-MM-DD

Response
Status: 200 OK
Content-Type: application/json
[
  {
    "duration": 10,
    "end_time": "Mon, 09 Sep 2019 11:45:32 GMT",
    "id": 1,
    "location_id": 1,
    "start_time": "Mon, 09 Sep 2019 11:45:22 GMT"
  },
  {
    "duration": 40,
    "end_time": "Mon, 09 Sep 2019 11:46:32 GMT",
    "id": 2,
    "location_id": 1,
    "start_time": "Mon, 09 Sep 2019 11:45:52 GMT"
  }
]

Get all visits from the past day

GET /visits/recent

Response
Status: 200 OK
Content-Type: application/json
[
  {
    "duration": 10,
    "end_time": "Mon, 09 Sep 2019 11:45:32 GMT",
    "id": 1,
    "location_id": 1,
    "start_time": "Mon, 09 Sep 2019 11:45:22 GMT"
  },
  {
    "duration": 40,
    "end_time": "Mon, 09 Sep 2019 11:46:32 GMT",
    "id": 2,
    "location_id": 1,
    "start_time": "Mon, 09 Sep 2019 11:45:52 GMT"
  }
]