Jump to content

Policy talk:Wikimedia Foundation User-Agent Policy

From Wikimedia Foundation Governance Wiki
Latest comment: 5 days ago by Quiddity (WMF) in topic mw.ForeignApi

Cross domain jQuery ajax request does not send Api-User-Agent header

I have a JavaScript gadget hosted on wikidata.org (d:User:Bamyers99/PhotoNearby.js) that makes a call to commons.wikimedia.org. The Api-User-Agent header is not sent by the jQuery ajax request. Any suggestions? Bamyers99 (talk) 02:09, 25 March 2025 (UTC)Reply

@Bamyers99 you can't send custom headers via JSONP. You should use CORS instead. Tgr (WMF) (talk) 15:19, 18 July 2025 (UTC)Reply
Switching to CORS worked. The Api-User-Agent header is now being sent. The change was easy: replace callback=? with origin=* in the url for a request that does not need credentials. --Bamyers99 (talk) 20:00, 18 July 2025 (UTC)Reply

Copyedits and small updates

Remove the notice "This page is purely informative..."

Change first sentence to: "All HTTP requests to Wikimedia sites must have an accurate and informative User-Agent header."

Change second sentence ("This was an operative decision") to "This policy was adopted in February 2010" and move to a new background section.

Move third sentence ("The rationale is..without benefiting the projects") to the new background section.

Update last paragraph in intro section ("As of 2015...specific cases as needed.") as follows: "As of 2025, Wikimedia sites do not automatically reject all requests that violate this policy. Rather, the policy is enforced in specific cases as needed."

Remove the first paragraph in the code examples section ("On Wikimedia wikis...may have similar policies.") This duplicates other information and is inaccurate (requests may fail, but will not necessarily do so).

Background: I was reading this page and was confused about whether blank or non-descriptive user agents are automatically blocked. I got confirmation from SRE that they are not, so I wanted to update this page to confirm. I also wanted to do a little cleanup while I'm at it 😊 Neil Shah-Quinn (WMF) (talk) 19:48, 28 March 2025 (UTC)Reply

For the record, the Legal team has decided not to make these changes right now, but will keep them in mind for future planned updates. Neil Shah-Quinn (WMF) (talk) 19:52, 23 June 2025 (UTC)Reply

Missing space

The sentence starting with "If you run a bot, please send a User-Agent header identifying the bot with an identifier that isn't going to be confused with many other bots" should have a space before it, separating it from the reference after the previous sentence. TTWIDEE (talk) 20:00, 17 June 2025 (UTC)Reply

 Done Fixed, thanks for mentioning! Quiddity (WMF) (talk) 22:54, 18 June 2025 (UTC)Reply

mw.Api syntax update

Since gerrit 1112339 mw.Api supports a simpler syntax for setting the user agent. Please replace

// Using mw.Api
var api = new mw.Api( {
    ajax: {
        headers: { 'Api-User-Agent': 'Example/1.0' }
    }
} );
api.get( ... ).then( function ( data ) {
    // ...
});

with

// Using mw.Api
var api = new mw.Api( {
    userAgent: 'Example/1.0'
} );
api.get( ... ).then( function ( data ) {
    // ...
});

Tgr (WMF) (talk) 15:08, 18 July 2025 (UTC)Reply

 Done. Thanks. Quiddity (WMF) (talk) 18:01, 18 July 2025 (UTC)Reply

https://meta.wikimedia.org/wiki/User-Agent_policy is outdated, yet it is reported in forbidden connections

Failed to open stream: HTTP request failed! HTTP/1.1 403 Forbidden. Please comply with the User-Agent policy: https://meta.wikimedia.org/wiki/User-Agent_policy

Proper URL (also too long): https://foundation.wikimedia.org/wiki/Policy:Wikimedia_Foundation_User-Agent_Policy Dusoft (talk) 20:38, 24 July 2025 (UTC)Reply

Thank you for this bug-report. I've filed phab:T400421 for the developers to resolve this. Quiddity (WMF) (talk) 22:00, 24 July 2025 (UTC)Reply

Update enforcement

Parts of this document are rather outdated – especially the last paragraph before the “Code examples” section:

As of 2015, Wikimedia sites do not reject all page views and API requests from clients that do not set a User-Agent header. As such, the requirement is not automatically enforced. Rather, it may be enforced in specific cases as needed.

This could really use an update for T400119. The very beginning (As of February 15, 2010, Wikimedia sites require a HTTP User-Agent header for all requests) has also sounded rather anachronistic for a while now (“as of” this specific day 15 years ago? or “since” then?) IMHO. Can someone update this? (I’d try it myself, but ITSAWIKI no longer applies now that this policy was moved out of Meta-Wiki.) Lucas Werkmeister (talk) 20:24, 22 September 2025 (UTC)Reply

Thanks for the note. I'll point you to the similar request (and especially the followup note) above at #Copyedits and small updates, and I'll add that I think they're planning an update within the next few months (but nothing is ever as simple as it seems, especially when legal nuances are involved!). Hope that helps. Quiddity (WMF) (talk) 17:08, 24 September 2025 (UTC)Reply

Documenting this in robots.txt

It might be worthwhile to put a link to this policy from https://en.wikipedia.org/robots.txt and friends. That's the first place I looked when I started having trouble caused by increased enforcement. (Eventually I found the link in the HTTP 403 body, but that required some code changes to extract.) -- Beland (talk) 22:14, 27 September 2025 (UTC)Reply

Hi Beland. Thanks for this suggestion. I'll point to the reply in the thread directly above, as a response. In a nutshell: the relevant people will keep this in mind for any future planned updates. Thanks again, Quiddity (WMF) (talk) 19:07, 8 October 2025 (UTC)Reply

Help With User Agent

Hello! I am trying to make an application using the wiktionary api. I followed the example to add a User-Agent parameter to my request with a description of the application and contact information. It still gives me the following response however:

"Please set a user-agent and respect our robot policy https://w.wiki/4wJS. See also T400119."

Is there something necessary I'm missing, other than the User-Agent parameter specified on this page? Samot2 (talk) 04:23, 8 October 2025 (UTC)Reply

Hi Samot2. Unfortunately we cannot help with technical questions at this talkpage. Please ask your question at m:Tech or one of the other locations documented in mw:Communication. I hesitantly suggest (speaking as a non-developer) that it might be helpful (for potential responders to your question) if you could either link to your existing code, or just provide more details about what precise parameters you are currently using (so that they can more easily respond with suggestions for changes/additions/etc). I hope that information helps. Quiddity (WMF) (talk) 19:12, 8 October 2025 (UTC)Reply

mw.ForeignApi

Hi!

Does this work with mw.ForeignApi? In the only signature that I'm aware of, mw.ForeignApi accepts a string which is the foreign domain. I can't find any mention of userAgent in the source code for mw.ForeignApi Nirmos (talk) 00:51, 3 November 2025 (UTC)Reply

Hi Nirmos. Unfortunately, we cannot help with technical questions at this talkpage. Please ask your question at m:Tech or one of the other locations documented in mw:Communication. Best regards, Quiddity (WMF) (talk) 20:20, 3 November 2025 (UTC)Reply