Issue with CURL query for Bits Leaderboard

I’m trying to get bits data using the leaderboard stuffs so I can monitor new transactions and add them to our database. I understand the limitations of this method, but it’s a small channel and I figured if I cut down the time scope it would allow me to effectively track all incoming bits for the foreseeable future (until I have the knowledge to work with the chat api stuff (I’ve looked - it’s too hard!)). I can access all time, however day, week and month all return an empty response.
I’ve tried this like in their example
curl_setopt($GBL, CURLOPT_URL, “https://api.twitch.tv/helix/bits/leaderboard?count=2&period=week”);
I get this:
array(3) {
[“data”]=>
array(0) {
}
[“date_range”]=>
array(2) {
[“started_at”]=>
string(0) “”
[“ended_at”]=>
string(0) “”
}
[“total”]=>
int(0)
}
The ‘all time’ query works fine, but it would have a limited usage before new small bits quantities would be outside of the 100 entries range. I’m guessing I’m missing something like when the day/week/month starts or some other parameter from this query string, the documentation wasn’t very helpful (to me, because I’m stupid)? Can some kind person please provide me with an example query - ideally for a day of what it should look like? The channel has received bits in the past 24 hours.

When using period you also need to specify a started_at

And you didn’t

An example call

https://api.twitch.tv/helix/bits/leaderboard?started_at=2021-01-29T00:00:00Z&period=day

It just doesn’t error if you omit a started_at

1 Like

Yes I realized just after I posted that I should look at that again, I tried inputting a timestamp converted to RFC3339 but I formatted it incorrectly (lesson learned, never type out what you can copy/paste)! At least I was on the right lines! Thank you again for your extremely prompt and helpful… er… help! Much appreciated! Edit… missing words change the meaning of things!

I threw in a bug report too https://github.com/twitchdev/issues/issues/298

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.