tidyverse / googlesheets4

Google Spreadsheets R API (reboot of the googlesheets package)
https://googlesheets4.tidyverse.org
Other
357 stars 51 forks source link

range_speedread request failed [429] -> too many calls? #302

Closed HugoGit39 closed 10 months ago

HugoGit39 commented 10 months ago

Hi

I just tested the range_speedread function where I called it like 5 times close to each other (within a minute). I received a Request failed [429]. error...how come?

As I understand this is request is not called via the API right? So calls should be unlimited? Or how do I see this?

Moreover, my plan is to use it with a lot of users in a Shiny app (way more than 300 calls per minute which Google now limits per minute). Solution is to pay for more calls? Or is range_speedread not really convinient for this?

jennybc commented 10 months ago

My memory of range_speedread() is a big foggy now, but even in the docs I see this:

Note that the Sheets API is still used to retrieve metadata on the target Sheet, in order to support range specification. range_speedread() also sends an auth token with the request, unless a previous call to gs4_deauth() has put googlesheets4 into a de-authorized state.

So I suspect it's these API calls that are biting you. It sounds possible that you should read the source of range_speedread() and build the URL you need with your bare hands.

HugoGit39 commented 10 months ago

Thx for your quick answer!

What do you mean with:

It sounds possible that you should read the source of range_speedread() and build the URL you need with your bare hands.

Btw I have currently range_speedreadin the server side.....does it make sense to possibly put this in the global section? Than its only loaded once right?

Moreover is range_speedread scalable wit lots of users by elevating the APi call quota? Or are other methods prefered?

jennybc commented 10 months ago

I am loath to offer Shiny-specific advice, but yes it definitely makes sense to arrange your app's logic to only read the data anew as often as you think it could be changing.

I think if you're really worried about quota you should cut the Sheets API out of the story altogether and use the special URL that's formed inside range_speedread() to get the data, in csv form, from a normal HTTP call.

HugoGit39 commented 10 months ago

How do i do this?

use the special URL that's formed inside range_speedread() to get the data, in csv form, from a normal HTTP call.

jennybc commented 10 months ago

You could look at the source of range_speedread()?

I think we've now reached "let me StackOverflow that for you". Here's a post on forming a URL for downloading Google Sheets as csv:

https://stackoverflow.com/a/64778214