Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6674391
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:44:23+00:00 2026-05-26T03:44:23+00:00

I have a Ruby script which downloads YouTube Insight reports for specific videos within

  • 0

I have a Ruby script which downloads YouTube Insight reports for specific videos within specific date ranges. It authorizes with ClientLogin, retrieves <entry> XML data for a video, and extracts from that data a URL which points to a CSV report:

http://insight.youtube.com/video-analytics/csvreports
  ?query={VIDEO_ID}
  &type=v
  &starttime=1315353600000
  &endtime=1317772800000
  &user_starttime=1317168000000
  &user_endtime=1317772800000
  &region=world
  &token={API_TOKEN}
  &hl=en_US

The above URL works. However, I want a report for a specific date range, not the default range provided.

An Insight report query’s requested date range is set in the user_starttime and user_endtime params. (In the above default case, it’s 2011-09-27 through 2011-10-04.) The YouTube API docs say that you can specify your own date range (covering a span of up to 28 days) by substituting timestamps (in milliseconds) that represent the dates you want.

So, why does the following query 404?

http://insight.youtube.com/video-analytics/csvreports
  ?query={VIDEO_ID}
  &type=v
  &starttime=1315353600000
  &endtime=1317772800000
  &user_starttime=1307937600000
  &user_endtime=1308110400000
  &region=world
  &token={API_TOKEN}
  &hl=en_US

The date range looks OK:

ruby > Time.at 1307937600
=> 2011-06-13 00:00:00 -0400 
ruby > Time.at 1308110400
=> 2011-06-15 00:00:00 -0400 

The fact that the “default” URL works indicates that I must be doing something wrong with these date values, but I can’t figure out what. What am I overlooking?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T03:44:24+00:00Added an answer on May 26, 2026 at 3:44 am

    UPDATE 2 — Nov. 4, 2011:

    There has recently been a change to the YouTube Data API Protocol for Insight data, and the answer below is no longer accurate.

    YouTube now permits date ranges of up to 31 days for a single Insight report query, and they now allow requests pertaining to dates going back to March 1, 2009. The docs now say:

    You can adjust the date range for which a report contains data 
    to a period of up to 31 days beginning no earlier than March 1, 2009. 
    

    This is excellent news. (Leaving the below for posterity.)


    I believe I’ve figured out why the above Insight report query with the custom date range is 404ing. I was able to retrieve a report with a custom date range like this:

    http://insight.youtube.com/video-analytics/csvreports
    ?query={VIDEO_ID}
    &type=v
    &starttime=1315353600000
    &endtime=1317772800000
    &user_starttime=1315627200000
    &user_endtime=1315972800000
    &region=world
    &token={API_TOKEN}
    &hl=en_US
    

    What’s the difference between this (good) URL and the previous (bad) URL in my question above? Well, my custom date range here, specified in the user_starttime and user_endtime parameters both fall within the range set by YouTube in the starttime and endtime params.

    In other words, starttime and endtime seem to represent the outer bounds of any user-specified custom date range possible through these types of requests.

    So, when the YouTube API docs say:

    You can adjust the date range for which a report contains data to a period of up to 28 days

    What they mean, I suppose, is:

    • Your date range may not span more than 28 days … AND ALSO …
    • Your date range may not fall outside of a date range going back 28 days from the most recent date on which reports are currently available, which we tell you through the starttime and endtime parameters.

    UPDATE:

    In this thread, a YouTube API Team member says:

    You should consider the starttime value the absolute earliest supported start date and endtime the absolute latest supported end date. If you try to set user_starttime to something earlier than starttime then you’re going to ask for data that dates back more than 28 days, and that data isn’t available.

    This exact text should be in the documentation.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written a ruby script which opens up dlink admin page in firefox
I have a small ruby script in which I'd like to use ActiveRecord to
I have a cron job to run a Ruby script, which runs fine on
I have the following Ruby script that creates a Debian package, which works fine:
I have a ruby cgi script which writes it output like this: cgi.out(Cache-Control =>
I have a Ruby script, which uses one external lib. Sometimes script exits with
I have a ruby script below which infinitely prints numbers from 1 onward. How
I have the following Ruby script, in which class Foo includes module Baz, module
I have a ruby script which I run using the JRuby Interpreter. The script
I have a long running ruby script, in Linux, which has some interesting data

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.