Skip to content

Conversation

RayBB
Copy link
Collaborator

@RayBB RayBB commented Aug 26, 2025

Closes: #11199
@mekarpeles mentioned we were getting 403 nonstop from wikidata endpoint.
I recently noticed that we were often not loading data reliably.

Turns out it's because they have a user agent policy that is being enforced actively now here.

To test this I run the following code locally:

>>> import requests
>>> requests.get("https://www.wikidata.org/w/rest.php/wikibase/v1/entities/items/Q9152")
<Response [403]>
>>> 
>>> headers = {'User-Agent': 'OpenLibrary.org Wikidata Integration' }
>>> requests.get("https://www.wikidata.org/w/rest.php/wikibase/v1/entities/items/Q9152", headers=headers)
<Response [200]>

As we can see, with no headers we 403. But when you set headers it's 200.

If we were being blocked by wikidata for too many requests it would be a 429 (as I see locally when I use hey to make many requests)

Technical

Testing

Screenshot

Stakeholders

@RayBB RayBB requested a review from mekarpeles August 26, 2025 18:35
@RayBB RayBB added the Priority: 1 Do this week, receiving emails, time sensitive, . [managed] label Aug 26, 2025
@mekarpeles mekarpeles merged commit 53b1d61 into master Aug 26, 2025
8 checks passed
@mekarpeles mekarpeles deleted the fix/wikidata-headers branch August 26, 2025 18:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Priority: 1 Do this week, receiving emails, time sensitive, . [managed]

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Address Wikidata 429s

2 participants