Wiktionary API: Get tags for a word, and specify language - wikipedia-api

For example, if the word is dog, I want to get the following, but only the English section, not other language sections like ==Afrikaans==, ==Danish== and so on. What API should I use? I saw the API page, but it was difficult to understand. The only thing I could find was parse (https://en.wiktionary.org/w/api.php?action=parse&page=dog), but that gives me the HTML, not the tags, it has a warning "Unrecognized parameter: url", and I don't know how to specify the language.
[[Image:YellowLabradorLooking.jpg|thumb|A dog (a [[Labrador retriever]])]]
===Alternative forms===
* {{l|en|darg}}, {{l|en|dawg}}, {{l|en|dug}} {{qualifier|dialectal}}
* {{l|en|doggie}}, {{l|en|doggy}} {{qualifier|childish}}
===Pronunciation===
* {{a|RP}} {{IPA|en|/dɒɡ/}}
...

This looks to do what you want:
https://en.wiktionary.org/w/api.php?action=parse&page=dog&section=1&prop=wikitext
You probably want to check that it starts with ==English==, but I think if you are using en.wiktionary, section 1 will always be English.

Related

how to get table info and summary of page using Wikipedia api?

I want to get minimal information of a Wikipedia page using MediaWiki API like DuckDuckGo. For example for Steve Carell: https://duckduckgo.com/?q=steve+carell&t=hp&ia=news&iax=about
How can I get this information with a Wikipedia url (eg https://en.wikipedia.org/wiki/Steve_Carell) in HTML format?
You can use the MediaWiki API for that. There's an extension, TextExtracts, which is exactly for that (and it is installed on Wikipedia).
In your case, e.g.:
https://en.wikipedia.org/w/api.php?action=query&prop=extracts&exsentences=1&titles=Steve%20Carell
will return something like:
<p class=\"mw-empty-elt\">\n</p>\n\n<p class=\"mw-empty-elt\">\n \n</p>\n<p><b>Steven John Carell</b> (<span></span>; born August 16, 1962) is an American actor, comedian, producer, writer and director.</p>
You can customize how many sentences (or characters) the API returns, as well, please consult the API documentation for that.
There's also the way to retrieve the short description, which is saved at Wikidata (and visible in the mobile view of Wikipedia). This call would be:
https://en.wikipedia.org/w/api.php?action=query&prop=pageprops&titles=Steve_Carell
This returns the following property in the pageprops of the page:
"wikibase-shortdesc": "American actor"
This may fit better depending on your use case.
You can even get both of the results with a single, combined, request:
https://en.wikipedia.org/w/api.php?action=query&prop=extracts|pageprops&exsentences=1&titles=Steve_Carell

How can I get page id, wikidata id of some title along with multiple languages in a single API call?

I have been trying to call Wikipedia API to retrieve page id and wikidata item id using below call and it works fine.
https://en.wikipedia.org/w/api.php?action=query&prop=pageprops&ppprop=wikibase_item&redirects=1&format=xml&titles=Cat
but I need to retrieve the same information from other languages of my choice for example if I mention German and French languages in my call, it should look for their translation of word Cat and retrieve their page info. There is langlink property in Wikipedia API but somehow it doesn't work with query action along with pageprop.
So ideally, I want something like this:
https://en.wikipedia.org/w/api.php?action=query&prop=pageprops&ppprop=wikibase_item&prop=langlinks&lllang=de&lllang=fr&titles=Cat
Any help would be appreciated.
Using lllang twice will just result in the second value overwriting the first one. You'll have to omit the paramter and then you get all the links:
https://en.wikipedia.org/w/api.php?action=query&prop=pageprops|langlinks&ppprop=wikibase_item&titles=Cat

How to get result of google place API In Hindi/Korean?

I need to get Api Response in Hindi and Korean. I have passed languge parameter with(hi for hindi) and checking its response by simulator but it's result is always in English.
Here is Url that was made by me for getting Search places result in Hindi
https://maps.googleapis.com/maps/api/place/search/json?location=28.580000,77.330000&sensor=true&key=AIzaSyAnAS2zrUGCxU5zp_JvuCrBWLwndv7rElI&name=BURGER&rankby=distance&language=hi
Please tell me if anybody has idea bout my question.
See the description of the language-parameter:
The language code, indicating in which language the results should be returned, if possible
There is no guarantee that the results will be in the desired language.
When there is no translation for the desired language/particular place-detail available, you will not get it.
So your attempt is correct, but you may not get better results.
When you inspect the response you'll see that you get results in hindi(where available) e.g. for Sangam Fry Burger -> संगम फ्राय बर्गर

How do I access the "See Also" Field in the Wiktionary API?

Many of the Wiktionary pages for Chinese Characters (Hanzi) include links at the top of the page to other similar-looking characters. I'd like to use the Wiktionary API to send a single character in the query and receive a list of similar characters as the response. Unfortunately, I can't seem to find any query that includes the "See Also" field. Is this kind of query possible?
The “see also” field is just a line of wiki code in the page source, and there is no way for the API to know that it's different from any other piece of text on the page.
If you are happy with using only the English version of Wiktionary, you can fetch the wikicode: index.php?title=太&action=raw, and then parse the result for the template also. In this case, the line you are looking for is {{also|大|犬}}.
To check if the template is used on the page at all, query the API for titles=太&prop=templates&tltemplates=Template:also
Similar templates are avilable in more language editions of Wiktionary, in case you want to use other sources than the English one. The current list is:
br:Patrom:gwelet
ca:Plantilla:vegeu
cs:Šablona:Viz
de:Vorlage:Siehe auch
el:Πρότυπο:δείτε
es:Plantilla:desambiguación
eu:Txantiloi:Esanahi desberdina
fi:Malline:katso
fr:Modèle:voir
gl:Modelo:homo
id:Templat:lihat
is:Snið:sjá einnig
it:Template:Vedi
ja:テンプレート:see
no:Mal:se også
oc:Modèl:veire
pl:Szablon:podobne
pt:Predefinição:ver também
ru:Шаблон:Cf
sk:Šablóna:See
sv:Mall:se även
It has been suggested that the WikiData project be expanded to cover Wiktionary. If and when that happens, you might be able to query theWikiData API for that kind of stuff!

How to get content from the Wikipedia API for a movie?

I tried to get the description of the movie "Your Highness" from the Wikipedia API but it gives me nothing.
http://en.wikipedia.org/w/api.php?format=xml&action=query&titles=your%20highness&prop=revisions&rvprop=content
When I google "Your Highness" wikipedia shows up as the third result, that's the page that I want the API to give me.
Also I just want the text of the description of the movie, no wiki-syntax mixed in or anything.
I was wrong before about the problem being a space - it looks like it was just capitalization. If we just change your URL to use Your%20Highness instead of your%20highness it works:
http://en.wikipedia.org/w/api.php?format=xml&action=query&titles=Your%20Highness&prop=revisions&rvprop=content
EDIT: While not all titles are title-cased (such as "The Name of the Rose") if you use the &redirects query parameter, it sometimes helps - it certainly helps in "the name of the rose" but not for "your highness" for some reason. Wouldn't like to say why, but it's probably worth more investigation...