Jump to content

API talk:Opensearch

Add topic
From mediawiki.org

JSON & XML Format Result Difference

[edit]

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

[edit]

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)Reply

examples not reflect the real searches

[edit]

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 <description> tags once again)

The <description> tags are not appearing (25th Jul 2024).

Namespace Main and exact NS prefix

[edit]

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

[edit]

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?

  • For example searching for "Wik" should return e.g. "Enterprise Wiki".

--user:212.77.177.35

+1. Yug (talk) 10:53, 3 December 2021 (UTC)Reply

Multiple Namespaces

[edit]

"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:
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)Reply

CORS block

[edit]

I tried to fetch('https://en.wiktionary.org/w/api.php?action=opensearch&namespace=0&format=json&limit=max&search=mic') 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)Reply

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)Reply
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)Reply

Only for web browsers

[edit]

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)Reply