API talk:Opensearch

JSON & XML Format Result Difference
I just wanted to know why there is difference between the results for XML and JSON output formats?

Exact search
Hi

Is there a way to do a case-insensitive exact search (diacritic independant) ?

for example I'd like to look for articles about "GEANT" on fr.wiktionnaire.org. There are 2 answwers : "Géant" and "géant"

But : http://fr.wiktionary.org/w/api.php?action=opensearch&search=geant&format=json gives me :

["geant",["g\u00e9ant","g\u00e9ante","G\u00e9ant","g\u00e9ants","g\u00e9ante gazeuse","G\u00e9ants","g\u00e9ante rouge","g\u00e9ante bleue","g\u00e9ante de glace","g\u00e9ant des Flandres"]]

wheras I'd like to get only

["geant",["g\u00e9ant", "G\u00e9ant" ]]

Another example would be http://fr.wiktionary.org/w/api.php?action=opensearch&search=CREE&format=json which replies

["CREE",["cr\u00e9er","Cree","cr\u00e9\u00e9","cr\u00e9\u00e9e","creek","cr\u00e9eras","creer","creed","creep","cr\u00e9ent"]]

I'd like to get only :

["CREE",["Cree","cr\u00e9\u00e9"]]

By the way "cr\u00e9e" (which exists) seems to be missing ?

How can I do that (of course I could post a post-query filter, but I guess this should be possible natively) ?

Thx

Paul Apc005 (talk) 20:19, 16 March 2012 (UTC)

examples not reflect the real searches
Recently, the examples are different with the links they gave, resulting in different XML format and layout. Don't really know what they have changed!

I just found out it is missing "Description" in the XML return.

- Noticed this too after an IRC bot script that uses this API broke recently (14th Dec 2014). Unfortunately without the Description field being returned, it's made the script rather useless. (edit 27/12/2014 - API now appears to be returning tags once again)

Namespace Main and exact NS prefix
Hi. I noticed that when I filter by Main namespace (0) I get results from other namespaces if I enter the namespace name exactly. So if I search for "Category:" I get articles from the Category namespace. Is there a way to remove/skip this feature?

Search for pages containing the search string
Opensearch currently returns only pages that start with the search string.

Is there a way to configure Opensearch to return pages containing a search string? --user:212.77.177.35
 * For example searching for "Wik" should return e.g. "Enterprise Wiki".
 * +1. Yug (talk) 10:53, 3 December 2021 (UTC)

Multiple Namespaces
"Namespaces to search. Values (separate with |):"

I worked out 3 reasons why not:
 * 1) setNamespaces accepts an int array
 * 2) No explode on the url query string is performed
 * 3) Even if setNamespaces is passed an int array, it will not search in more than one namespace

I have no answers for now


 * To address your various points, namespace lists are expected to be pipe-separated ints in the API (you can see the specific numbers using action=query&meta=siteinfo&siprop=namespaces). These are exploded in the extractRequestParams routine. As for your last point, this is an abstract class. Search engines are just passed the namespaces as an arrary (via the PrefixSearchBackend hook, if I understand correctly), and are expected to deal with them however they want. It does indeed appear that defaultSearchBackend only searches the first namespace provided, but clearly, if you look at the examples below, whatever MediaWiki is using as a search engine is overriding that and does support multiple namespaces:
 * Suggested example, but in Main space only
 * Suggested example, but in Talk space only
 * Suggested example in both |1&format=jsonfm Main and Talk space
 * Now, that said, I completely agree with one of the comments in the code: there's a lot of things about the search scheme modules, including the API module, that're just really weird at a glance. – Robin Hood  (talk)  07:09, 3 August 2016 (UTC)

CORS block
I tried to  in JavaScript, however, I got "Cross-Origin Request Blocked" saying "(Reason: CORS header ‘Access-Control-Allow-Origin’ missing)". What could be the reason? Acagastya (talk) 21:49, 11 September 2018 (UTC)
 * Manual:CORS documents how to use CORS in your javascript code. You might get some hints there! SSethi (WMF) (talk) 00:11, 12 September 2018 (UTC)
 * I guess I might have screwed up with the device -- it is working perfectly fine on other devices. Acagastya (talk) 06:33, 12 September 2018 (UTC)

Only for web browsers
I'm confused by the message at the top of this page:
 * You should use this API only if you are developing a web browser. This would allow you to want to obtain results in a standard and accessible format suitable for syndication or aggregation.

What does this even mean? You should only use this API if you're a developer for Firefox or Chrome? This API is used on all Wikimedia sites to power the autocomplete box on the top right, and those are definitely not 'web browsers'. I would suggest removing it or rewriting it to make it less confusing. Husky (talk) 21:38, 19 May 2020 (UTC)