API talk:Langlinks

About this board

Several pages in one request

7
Alex Blokha (talkcontribs)

How can I pass several pages in one request? Is it possible?

RobinHood70 (talkcontribs)

Just add pipes between the page names. So, for example: https://www.mediawiki.org/w/api.php?action=query&prop=langlinks&titles=Mediawiki|API:Main%20page|Project:About&lllimit=500

Alex Blokha (talkcontribs)
RobinHood70 (talkcontribs)

Wikipedia limits the number of results returned for any given query. To get the rest of the results, look at the <continue> result near the top and add all those parameters to your next query. So, that ends up like this: https://ru.wikipedia.org/w/api.php?format=xml&action=query&prop=langlinks&lllimit=500&titles=1977%20%D0%B3%D0%BE%D0%B4%7C1988%20%D0%B3%D0%BE%D0%B4%7C1999%20%D0%B3%D0%BE%D0%B4&llcontinue=2715%7Cln&continue=%7C%7C

If there had been another <continue> in those results, then you'd put those values instead of the previous ones, but since there isn't, you know you're done.

Alex Blokha (talkcontribs)

Ok, I am trying to get this url https://uk.wikipedia.org/w/api.php?format=xml&action=query&prop=langlinks&lllang=uk&lllimit=500&titles=%D0%97%D0%B0%D0%B3%D0%BB%D0%B0%D0%B2%D0%BD%D0%B0%D1%8F%20%D1%81%D1%82%D1%80%D0%B0%D0%BD%D0%B8%D1%86%D0%B0%7C%D0%9A%D0%BE%D1%80%D0%BE%D0%BD%D0%B0%D0%B2%D0%B8%D1%80%D1%83%D1%81%D1%8B%7C%D0%9C%D0%B0%D0%BB%D0%B8%D0%BA%D0%BE%D0%B2%2C%20%D0%94%D0%BC%D0%B8%D1%82%D1%80%D0%B8%D0%B9%20%D0%AE%D1%80%D1%8C%D0%B5%D0%B2%D0%B8%D1%87%7C%D0%92%D1%81%D0%BF%D1%8B%D1%88%D0%BA%D0%B0%20%D0%BA%D0%BE%D1%80%D0%BE%D0%BD%D0%B0%D0%B2%D0%B8%D1%80%D1%83%D1%81%D0%B0%202019-nCoV%7C%D0%9B%D0%B5%D1%89%D0%B5%D0%BD%D0%BA%D0%BE%2C%20%D0%9B%D0%B5%D0%B2%20%D0%92%D0%B0%D0%BB%D0%B5%D1%80%D1%8C%D1%8F%D0%BD%D0%BE%D0%B2%D0%B8%D1%87%7C%D0%95%D0%B2%D1%80%D0%BE%D0%BF%D0%B5%D0%B9%D1%81%D0%BA%D0%B8%D0%B9%20%D1%81%D0%BE%D1%8E%D0%B7%7C%D0%A5%D0%B0%D0%BD%D0%B3%D0%B0%2C%20%D0%95%D0%BB%D0%B5%D0%BD%D0%B0%20%D0%90%D0%B1%D0%B4%D1%83%D0%BB%D0%B0%D0%B5%D0%B2%D0%BD%D0%B0%7C%D0%9A%D0%B5%D0%BD%D0%B8%D0%BD%2C%20%D0%A1%D0%BE%D1%84%D0%B8%D1%8F%7C%D0%92%D1%8B%D1%85%D0%BE%D0%B4%20%D0%92%D0%B5%D0%BB%D0%B8%D0%BA%D0%BE%D0%B1%D1%80%D0%B8%D1%82%D0%B0%D0%BD%D0%B8%D0%B8%20%D0%B8%D0%B7%20%D0%95%D0%B2%D1%80%D0%BE%D0%BF%D0%B5%D0%B9%D1%81%D0%BA%D0%BE%D0%B3%D0%BE%20%D1%81%D0%BE%D1%8E%D0%B7%D0%B0%7C%D0%A1%D0%BF%D0%B8%D1%81%D0%BE%D0%BA%20%D0%B8%D0%B3%D1%80%D0%BE%D0%BA%D0%BE%D0%B2%20%D0%9D%D0%A5%D0%9B%2C%20%D0%B7%D0%B0%D0%B1%D1%80%D0%BE%D1%81%D0%B8%D0%B2%D1%88%D0%B8%D1%85%20500%20%D0%B8%20%D0%B1%D0%BE%D0%BB%D0%B5%D0%B5%20%D1%88%D0%B0%D0%B9%D0%B1%7C

And I can see both pages, which have uk interwiki and which don't have. I use 'lllang' parametr.

RobinHood70 (talkcontribs)

Was that supposed to be on ru.wikipedia.org? Because if I do that, I get lllang results as expected.

Alex Blokha (talkcontribs)

Yes, that supposed to be articles from ruwiki.

Thank you.

Reply to "Several pages in one request"
Dalba (talkcontribs)

Is it possible for a language code to have more than one language link? The current API help states that the lllang parameter causes the API to "only return language links with this language code". That "links" makes one think that the API may return multiple links for an individual language code, but I cant think of any situation or example that it would be the case.

I tried to manually add a language link to (different that the one that was already stored at wikidata), but it just overrode the previous language link and the API was still returning only one link.

RobinHood70 (talkcontribs)

Yup, there it is. If you look at Manual:Langlinks table, you'll see that the primary key ("PRI" in the Key column) is based on the page_id and the language link. Therefore, it's guaranteed that there can only ever be one result for a given language.

RobinHood70 (talkcontribs)

Nevermind, you already tried that. I didn't read closely enough. :) My guess is that it will probably only ever return one value, but that's just a guess. I don't see anything in the API that would preclude multiple language links being returned for the same language, but there could be something in how the table itself is populated that precludes it.

Sette-quattro (talkcontribs)
RobinHood70 (talkcontribs)

The parameter doesn't seem to be set up as a multi-input parameter. About the only way I can see of doing what you want is to drop the lllang parameter altogether (and optionally add lllimit=500), which will return all the language links. Then, you can filter those results to just French and Italian.

Sette-quattro (talkcontribs)

Thanks!

Reply to "lllang"
78.50.242.204 (talkcontribs)

Is it possible to have the API return only language links defined in the source code, i.e. exclude language links obtained from WikiData? --~~~~

Reply to "no wikidata"
There are no older topics