androidretrofit2wikipedia

Wikipedia denies access froom my Android app (through retrofit)


I have an Android app (a word game) that relies on grabbing random pages from Wikipedia. I wrote this a couple of years ago and it worked just fine. Then recently (say, June 2025) I started to get:

HTTP 429 errors (too many requests in a given amount of time).

I added some delays between successive calls and this worked. But more recently (Aug 2025) all my requests are failing with:

HTTP 403 (server refusing to authorize).

What's an acceptable way to access Wikipedia without straining its resources?

I am using boilerplate Retrofit code. In build.gradle I have:

implementation 'com.squareup.retrofit2:converter-scalars:2.12.0'

And the code is:

private val retrofit = Retrofit.Builder()
    .addConverterFactory(ScalarsConverterFactory.create())
    .baseUrl("https://en.wikipedia.org")
    .build()

interface WikipediaApiService {
    @GET("https://en.wikipedia.org/wiki/Special:Random")
    suspend fun getArticle(): String
}

object WikipediaApi {
    val retrofitService : WikipediaApiService by lazy {
        retrofit.create(WikipediaApiService::class.java)
    }
}

Solution

  • Use the Wikimedia REST API ...