Viewing Logs API - Straas/Straas-web-document GitHub Wiki

The Viewing Logs APIs provide different kinds of viewing logs.

Definitions

Term Description

Concept

Straas calculates viewing logs data of yesterday at 01:00 UTC everyday.

Authentication

These APIs are authenticated through an application token. Knowing how to create and get an application token please refer application token document.

Live Viewing logs

This API provides viewing logs of daily statistics of Live.

Endpoint

GET https://app.straas.net/api/v1/app/members/:id/live_viewing_logs

Request Headers

Field Required Description
Authorization O Bearer <YOUR_TOKEN>

Request Parameters

Field Required Description
id O member ID
start_time O start time in query, iso8601 format, day unit
end_time O end time in query, iso8601 format, day unit
page X pagination, which page is it? default is 1
per_page X pagination, how many data in one page? default is 100
  • difference of end_time and start_time must smaller than one month
  • note that, start_time and end_time would be truncated to day unit. e.g. 2018-03-27T03:12:14.457Z => 2018-03-27T00:00:00.000Z

Response Headers

Field Type Description
Link string web linking relations in RFC-5988 standard: first, last, next & prev relation
Page int current page number
Per-page int items per page
Total int total items

Response

Field Type Description
data array viewing log data
[data.member_id] string member ID
[data.live_id] string live ID
[data.viewed_start] string iso8601 format
[data.viewed_end] string iso8601 format
  • ordered by viewed_start asc

Status

200

Example

curl -X GET \
  -H "Authorization: Bearer <YOUR_TOKEN>" \
  "https://app.straas.net/api/v1/app/members/uuu/live_viewing_logs?start_time=2018-03-27T00:00:00.000Z&end_time=2018-03-28T00:00:00.000Z"

HTTP/1.1 200 OK
Link: <https://app.straas.net/api/v1/app/members/uuu/live_viewing_logs?start_time=2018-03-27T00:00:00.000Z&end_time=2018-03-28T00:00:00.000Z&per_page=100&page=1>; rel="first",
  <https://app.straas.net/api/v1/app/members/uuu/live_viewing_logs?start_time=2018-03-27T00:00:00.000Z&end_time=2018-03-28T00:00:00.000Z&per_page=100&page=1>; rel="last",
  <https://app.straas.net/api/v1/app/members/uuu/live_viewing_logs?start_time=2018-03-27T00:00:00.000Z&end_time=2018-03-28T00:00:00.000Z&per_page=100&page=1>; rel="next",
  <https://app.straas.net/api/v1/app/members/uuu/live_viewing_logs?start_time=2018-03-27T00:00:00.000Z&end_time=2018-03-28T00:00:00.000Z&per_page=100&page=1>; rel="prev"
Total: 3
Page: 1
Per-Page: 100
Response:
{
  "data": [
    {
      "member_id": "uuu",
      "live_id": "live_1",
      "viewed_start": "2018-03-27T03:12:14.457Z",
      "viewed_end": "2018-03-27T03:20:14.457Z"
    },
    // log belongs to different session might not merge together
    {
      "member_id": "uuu",
      "live_id": "live_1",
      "viewed_start": "2018-03-27T03:25:14.457Z",
      "viewed_end": "2018-03-27T03:30:14.457Z"
    },
    {
      "member_id": "uuu",
      "live_id": "live_2",
      "viewed_start": "2018-03-27T03:33:14.457Z",
      "viewed_end": "2018-03-27T03:36:14.457Z"
    }
  ]
}

Video Viewing logs

This API provides viewing logs of daily statistics of VOD.

Endpoint

GET https://app.straas.net/api/v1/app/members/:id/video_viewing_logs

Request Headers

Field Required Description
Authorization O Bearer <YOUR_TOKEN>

Request Parameters

Field Required Description
id O member ID
start_time O start time in query, iso8601 format, day unit
end_time O end time in query, iso8601 format, day unit
page X pagination, which page is it? default is 1
per_page X pagination, how many data in one page? default is 100
  • difference of end_time and start_time must smaller than one month
  • note that, start_time and end_time would be truncated to day unit. e.g. 2018-03-27T03:12:14.457Z => 2018-03-27T00:00:00.000Z

Response Headers

Field Type Description
Link string web linking relations in RFC-5988 standard: first, last, next & prev relation
Page int current page number
Per-page int items per page
Total int total items

Response

Field Type Description
data array viewing log data
[data.member_id] string member ID
[data.video_id] string vod ID
[data.viewed_start] string iso8601 format
[data.viewed_end] string iso8601 format
  • ordered by viewed_start asc

Status

200

Example

curl -X GET \
  -H "Authorization: Bearer <YOUR_TOKEN>" \
  "https://app.straas.net/api/v1/app/members/uuu/video_viewing_logs?start_time=2018-03-27T00:00:00.000Z&end_time=2018-03-28T00:00:00.000Z"

HTTP/1.1 200 OK
Link: <https://app.straas.net/api/v1/app/members/uuu/video_viewing_logs?start_time=2018-03-27T00:00:00.000Z&end_time=2018-03-28T00:00:00.000Z&per_page=100&page=1>; rel="first",
  <https://app.straas.net/api/v1/app/members/uuu/video_viewing_logs?start_time=2018-03-27T00:00:00.000Z&end_time=2018-03-28T00:00:00.000Z&per_page=100&page=1>; rel="last",
  <https://app.straas.net/api/v1/app/members/uuu/video_viewing_logs?start_time=2018-03-27T00:00:00.000Z&end_time=2018-03-28T00:00:00.000Z&per_page=100&page=1>; rel="next",
  <https://app.straas.net/api/v1/app/members/uuu/video_viewing_logs?start_time=2018-03-27T00:00:00.000Z&end_time=2018-03-28T00:00:00.000Z&per_page=100&page=1>; rel="prev"
Total: 3
Page: 1
Per-Page: 100
Response:
{
  "data": [
    {
      "member_id": "uuu",
      "video_id": "vod_1",
      "viewed_start": "2018-03-27T03:12:14.457Z",
      "viewed_end": "2018-03-27T03:20:14.457Z"
    },
    // log belongs to different session might not merge together
    {
      "member_id": "uuu",
      "video_id": "vod_1",
      "viewed_start": "2018-03-27T03:25:14.457Z",
      "viewed_end": "2018-03-27T03:30:14.457Z"
    },
    {
      "member_id": "uuu",
      "video_id": "vod_2",
      "viewed_start": "2018-03-27T03:33:14.457Z",
      "viewed_end": "2018-03-27T03:36:14.457Z"
    }
  ]
}
⚠️ **GitHub.com Fallback** ⚠️