If you don't find an answer, please click here to post your question.
Reply
Occasional Contributor
Posts: 7
Registered: ‎08-16-2017
Accepted Solution

Most efficient way to track live show metrics (v3 IQ API)

So I'd like to be able to grab data from the IQ API to make my own graphs of the amount of viewers watching a particular live stream that runs 24hrs.  As the content changes according to a schedule (but is still just considered a single conglomerated asset), I would be able to post-process and determine which types of content are the most popular.

 

So far, the best way I can think of doing this is by setting a start date/time for the day of interest, and time 00:00, and then the end date of the same day with time 00:15.  Then I would iterate, increasing the start time and end time by 15 minutes, and making another get request.  If I wanted to do this for Aug 26, 2017, my python code would look something like this:

tdelta = datetime.timedelta(minutes=15);
start_datetime = datetime.datetime(2017,8,26,00,00,00);

for x in range(0,96): # (24 hrs) * (4 15-minute-chunks per hour) = 96 
  next_datetime = start_datetime + tdelta;
  if x== 0:
    get_metric_15min(start_datetime);
  else:
    start_datetime = next_datetime;
    get_metric_15min(start_datetime);

Where get_metric_15min is a function that creates a get request with a start_date defined by start_datetime, and an end date of start_datetime + 15 minutes (and parses the JSON result and stores the metric of interest). 

So basically I am doing 96 GET requests to get the data I want for 1 day.  Is this a good way of accomplishing what I want?


Accepted Solutions
Ooyalan
Posts: 7
Registered: ‎01-17-2017

Re: Most efficient way to track live show metrics (v3 IQ API)

Hello redpine,

 

Thats an interesting approach to gathering metrics for our Analytics API. However, there is a way to get a whole day broken by 15 minutes segments instead of iterating 96 times throghout the whole day, please see this example:

 

v3/analytics/reports?start_date=2017-07-25T00:00Z&end_date=2017-07-26T00:00Z&report_type=performance&api_key=YOUR_API_KEY&metrics=displays&time_segment=15min

 

By adding the time_segment parameter the report will return the whole day in segments of 15 minutes with just one call instead of making 96 calls every 15 minutes for 24 hours.

 

Cheers!

View solution in original post


All Replies
Ooyalan
Posts: 7
Registered: ‎01-17-2017

Re: Most efficient way to track live show metrics (v3 IQ API)

Hello redpine,

 

Thats an interesting approach to gathering metrics for our Analytics API. However, there is a way to get a whole day broken by 15 minutes segments instead of iterating 96 times throghout the whole day, please see this example:

 

v3/analytics/reports?start_date=2017-07-25T00:00Z&end_date=2017-07-26T00:00Z&report_type=performance&api_key=YOUR_API_KEY&metrics=displays&time_segment=15min

 

By adding the time_segment parameter the report will return the whole day in segments of 15 minutes with just one call instead of making 96 calls every 15 minutes for 24 hours.

 

Cheers!