HTTP 429 Too Many Requests when accessing a Reddit .json page only once using Java

3.7k views Asked by At

I am getting a HTTP 429 Too Many Requests response when I attempt to access any Reddit page using a .json extension using Java.

I am using Java code found here without any modification (except to change the target URL). I am attempting to access URLs such as the following:

I can access these pages just fine using a browser, but cannot access them programmatically despite the fact I am making a single request each time and waiting in between. Reddit returns this message when more than 30 requests are made in a minute, but I am making far less than that and no-one else on my network uses Reddit.

Is anyone familiar with this and why I might be getting these errors? Would there be a better way to approach this using Java?

1

There are 1 answers

1
user253751 On BEST ANSWER

Make sure to use a custom user-agent string - see the 4th bullet point on the API rules:

  • Change your client's User-Agent string to something unique and descriptive, including the target platform, a unique application identifier, a version string, and your username as contact information, in the following format:

      <platform>:<app ID>:<version string> (by /u/<reddit username>)
    
    • Example:

          User-Agent: android:com.example.myredditapp:v1.2.3 (by /u/kemitche)
      
    • Many default User-Agents (like "Python/urllib" or "Java") are drastically limited (emphasis mine) to encourage unique and descriptive user-agent strings.

    • Including the version number and updating it as your build your application allows us to safely block old buggy/broken versions of your app.

    • NEVER lie about your user-agent. This includes spoofing popular browsers and spoofing other bots. We will ban liars with extreme prejudice.