Reports

Remember instance an object of FouryouseeAPI, according to the basic set up

Getting requested reports

fouryousee.FouryouseeAPI.get_reports(self, **kwargs)

Get the requested reports of the 4YouSee account.

Parameters

id (int, optional) – Id of the report.

Returns

List of dicts, where every dict, depicts a report.

Return type

list

Usage

Once “my” object has been created. You can execute the next:

Getting all reports. It will return all the reports of your account. It will be a list of dicts. If there is no report will return a empty list.

>>> my.get_reports()

If you know the report id

>>> my.get_reports(id=521546)  # When the report is ready (status = 'success')
{
   "id":521546,
   "type":"detailed",
   "format":"json",
   "filter":{
      "startDate":"2020-07-26",
      "startTime":"00:00:00",
      "endDate":"2020-08-24",
      "endTime":"23:59:59",
      "mediaId":[ 1, 2, 3 ],
      "playerId":[ 2 ],
      "sort":-1
   },
   "status":"success",
   "url":"https://4yousee-playlogs-reports.s3.amazonaws.com/...62bb067d43ac1.gz",
   "createdAt":"2022-06-28T13:47:36+00:00",
   "updatedAt":"2022-06-28T13:47:41+00:00"
}

If the id doesn’t exists.

>>> my.get_reports(id=123_456)
Exception: {"message":"Report with ID 5215464 was not found"}

Requesting reports

fouryousee.FouryouseeAPI.request_report(self, **kwargs) dict

Create a new request of report in the 4yousee account. Once is received the response, through the id will be possible to consult if the report is ready.

Parameters
  • type (str, optional) – Default value is ‘detailed’.

  • webhook (str, optional) – Web service that may allow the response with the report Ex.: http://4fc8e5ddf059.ngrok.io

  • filter (dict, required) – Interval of time of the desired report.

  • sort (int, optional) – Default values is -1.

Returns

Dict that depicts the report requested.

Return type

dict

Usage

Once “my” object has been created. You can execute the next:

Passing only the required params

>>> my.request_report(filter={
...                            "startDate": "2020-07-26",
...                            "startTime": "00:00:00",
...                            "endDate": "2020-08-24",
...                            "endTime": "23:59:59",
...                            "mediaId": [ ],  # List of id medias.
...                            "playerId": [ ],  # List of id players.
...                             "sort": -1 })
{ # Inmediately response
  "id": 522873,
  "type": "detailed",
  "format": "json",
  "filter": {
    "startDate": "2020-07-26",
    "startTime": "00:00:00",
    "endDate": "2020-08-24",
    "endTime": "23:59:59",
    "mediaId": [],
    "playerId": [],
    "sort": -1
  },
  "status": "waiting", # Look, the report wont be ready inmediately
  "url": null,
  "createdAt": "2022-07-02T12:42:05+00:00",
  "updatedAt": "2022-07-02T12:42:05+00:00"
}

Note

If a webhook url is passed, the report will make a post request to that url when is ready. Then you will have to download the file of the url field.

Note

On this repository (Django project), the view playlog shows how to handle the POST sent by 4YouSee.