Getting only ~100 requests every 10 minute reset instead of the expected 600
Hello, after Pushshift got axed a couple of weeks ago, I started messing around with PRAW to essentially create a personal replacement for what I primarily used that for - seeing all the recent comments which contained certain keywords across reddit.
Initially, I tried the often recommended reddit.subreddit('all').stream.comments() to fetch comments and print them if they matched a filter, which worked quite well... but I didn't like how it would miss many comments at peak times.
I then discovered that I could simply fetch comments by their ID using reddit.info([commentID1, commentID2...]), so I switched over to initially fetching the latest comment using reddit.subreddit('all').comments() on startup, and with its ID then repeatedly polling reddit.info() with sequential comment IDs from that one onward, 100 at a time, with the requests being spaced out by 1-1.2s, so within the specified rate limit of 1 req/sec. This worked splendidly and didn't skip any comments at all, albeit with the downside being that it was slightly falling behind live (not too badly though), but it was acceptable.
However, last night, all my requests have seemingly started being throttled, and now printing PRAW's reddit.auth.limits is showing that every 10 minutes, the remaining request count is only being reset to ~95 (so, 1 request every ~6 seconds) instead of the 600 it's supposed to be, leading to PRAW forcefully spacing every call out by 10 seconds, thus now lagging behind a much-less-acceptable thousands of comments per call, instead of the ~dozens it was before.
Even after shutting off the script for the night and trying again in the morning, the same thing persists; immediately after the first request on start up: used: 1, remaining: 95, reset_timestamp: ~600s from now. So yeah, any clues as to what's going on and how I could resolve this would be much appreciated.
#Edit:
This seems to be resolved now thanks to the replies below. Turns out you need to pass username and password to praw as well, not just client_id and secret (which the guides I used missed).
Posted May 12, 2023, 10:46 AM UTC · edited
It’s unsurprising you’re being limited, you’re reading every single comment to get a handful. That’s a total abuse of the API and I’m surprised you haven’t been banned completely. Instead of trying to read literally everything, why don’t you just use the
searchfunction to get only the comments you’re actually interested in seeing. From Reddit’s perspective it looks like you’re trying to clone their database.Yes, the ideal way would absolutely be to just search for comments directly via reddit instead of manually filtering.
However, it is my understanding (feel free to correct me if I am wrong, I'm basing it off research I did over the past few days) that reddit doesn't support searching for comments, only submissions. Even the "Remind Me" bot, which similarly used to comb Pushshift for comments mentioning its trigger keyword, is currently not working due to the same limitation.
I also don't really see how this is "total abuse of the API" - there is no real functional difference between this and
.subreddit().stream.comments()which has been the recommended method pretty much everywhere; both are repeatedly calling an endpoint to fetch comments in batches, I'm just trying to poll /info instead of /comments.Either way, I'm completely fine with abandoning this method if needed and going back to using stream.comments() instead, but mainly I'd just like to know how long until the rate limit goes back to normal, or if I'm just going to be gimped indefinitely :\
Ha, the reddit API allows search on user, subreddit, or submission but not comments. It's clearly a gap in the API that's existed for a while, despite existing on the front end.
Pushshift being banned was obviously about stopping API users stripping and storing Reddit historical data wholesale. I imagine the reason you've been restricted is for the exact same reason, even if you're not doing that. From the perspective of Reddit, you're circumventing the comments stream to fill the gaps.
I guess the only other option is web scraping the search page, but that's definitely the sort of thing that won't be allowed by Reddit.
Yeah, I guess the gap-filled subreddit('all').stream.comments() is gonna have to be the way to go. I'm just hoping my rate limit gets restored at some point in the near future if I stop using it for a while, as right now even that's being limited too.