Historical GitHub Traffic Decreasing Over Time

I am working on a project to assemble GitHub profile statistics. In particular, I am interested in retrieving project page views. For this I have been using the v3 REST API traffic endpoints, since this data is unavailable on the v4 GraphQL API.

Because page views are only presented for the past 14 days, I have been logging them offline. That way, I can accumulate an accurate long-term view total as the API stops returning data from more than two weeks ago.

Unexpectedly, I have noticed that view data from past days (within the two-week period, and thus returned by the API endpoint) has decreased. Specifically, the view count and number of unique viewers from one day last week has decreased in subsequent API accesses.

Edit: Looking more at the logs seems to show that the decrease happens on the date exactly 14 days ago. It seems like the view data is for exactly 14 days from the current moment, and thus data for the last day “fades out” even though the timestamp indicates it represents the whole day.

Is this a glitch or intended behavior? What can I do to ensure the maximum accuracy of my data?

Thanks in advance!

Greetings @jstrieb! How are you going? I appreciate you taking the time to post in the hopes of understanding expected behavior for the returns of the page views endpoint.

I wish I understood better your question. Because when I read:

Looking more at the logs seems to show that the decrease happens on the date exactly 14 days ago. It seems like the view data is for exactly 14 days from the current moment, and thus data for the last day “fades out” even though the timestamp indicates it represents the whole day.

…it sounds as though this would accurately describe the expected behavior. Our docs say:

Get the total number of views and breakdown per day or week for the last 14 days. Timestamps are aligned to UTC midnight of the beginning of the day or week. Week begins on Monday.

…and I’d not be sure how to answer your remaining question(s).

Some additional detail might be helpful, here. Is there a particular pattern that suggests the returns are cutting this off prematurely?

1 Like

Thanks for the reply!

The docs say that timestamps are aligned to UTC midnight, so I expected the data itself to also be aligned to UTC midnight. Instead, the data is aligned to the current time, which is what causes it to change as the 14-day window moves forward.

My question was whether this is intended behavior? If not, is this detail documented anywhere?

I want to make sure I don’t miss details like this moving forward if it is documented somewhere I didn’t see.

Well that:

Instead, the data is aligned to the current time, which is what causes it to change as the 14-day window moves forward.

…certainly doesn’t seem right. Though, I assume what you mean by “current,” time is, your local time?

Let me do some testing on my own, and dig around, for anything that seems amiss. I’ll report back, once I have something substantial for you.

Edit: I totally misunderstood. The concern here is that it’s the “now,” time being used to pull the past 14 days. This changes the start time, based on when the query was run. To my knowledge, this is expected behavior.

@jstrieb considering this ^ I’m curious what you might suggest instead? Is it enough to know the expected behavior that there is a rolling start time for that 14 day window? Or would an enhancement make more sense?

2 Likes

Thank you for looking into this!

I would have liked documentation explicitly saying that the 14-day window is rolling based on the current time rather than the current day. Even if this is expected behavior, it’s not necessarily intuitive behavior based on the documentation and the timestamps.

In addition to (or instead of) changing the documentation, if the timestamp used the current time, it would be clearer which time period each 24-hour day represents. Since the timestamps are all for UTC midnight, it seems like that is how the days are aligned. Instead, the days are aligned to the current time (or at least the last viewable day is).

Hopefully my suggestions and original confusion are clear.

2 Likes