2

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?

sideshowbarker
  • 81,827
  • 26
  • 193
  • 197
Porthos3
  • 381
  • 5
  • 19

1 Answers1

9

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.

Community
  • 1
  • 1
user253751
  • 57,427
  • 7
  • 48
  • 90
  • Adding code example in case someone needs HttpGet httpGet = new HttpGet(yourUrl); httpGet.setHeader("User-Agent", yourUserAgentString); – Aerim Aug 06 '15 at 17:12