Does Reddit block an HttpClient after too many requests?

Good morning
I wrote a discord bot with the function to pull content from Reddit.
About 3 weeks ago, when I last used it, everything was working fine.
Meanwhile I get this exception:

Error: Response status code does not indicate success: 403 (Blocked).

Blocking the IP is unlikely since I tried it with a VPN and from a different physical location.

I get kicked out on the second line:

 var client = new HttpClient();                var result = await client.GetStringAsync($" https://reddit.com/r/ {subreddit ?? "dankmemes"}/random.json?limit=1");

Does anyone have any idea why this is happening? The command is usually spammed a lot…
Maybe that's why something was blocked?
Maybe you know a better way to do this?
Thanks in advance!

"Complete" code:

 var client = new HttpClient();                var result = await client.GetStringAsync($" https://reddit.com/r/ {subreddit ?? "dankmemes"}/random.json?limit=1");                if (!result.StartsWith("["))                {                    await Context.Channel.SendMessageAsync("Subreddit doesn't exist...");                    return;                }                JArray arr = JArray.Parse(result);                JObject post = JObject.Parse(arr[0]["data"]["children"][0]["data"].ToString());                var builder = new EmbedBuilder()                    .WithImageUrl(post["url"].ToString())                    .WithColor(new Color(0, 0, 255))                    .WithTitle(post["title"].ToString())                    .WithUrl(" https://reddit.com/ " + post["permalink"].ToString())                    .WithFooter($"🗨 {post["num_comments"]} ⬆️ {post["ups"]}");                var embed = builder.Build();                await Context.Channel.SendMessageAsync(null, false, embed);
(1 votes)
Loading...

Similar Posts

Subscribe
Notify of
5 Answers
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
BeamerBen
1 year ago

Look into the Reddit API documentation according to Rate Limits and the Error Codes.

But of course, if you don’t catch the rate limits or don’t use the official API, your requests will be blocked.

That makes every reasonable side.

W00dp3ckr
1 year ago

I don’t see the error message. But it is clear that if you move from an IP to a significant content automatically. And that may be locked, or there is a rate limit or or.

Normally, the scraping is prohibited according to AGB, as it can force pages into the knees.

W00dp3ckr
1 year ago
Reply to  SupfgamingTV

They are probably not quite stupid and know VPNs.

elmex7
1 year ago

You should use the terms of use of

a) Reddit

and

b) Good question

read…