API talk:Properties

Getting revision content only via revid
Is it possible to get the content of a revision only by a given revid? - It seams, that query / prop=revision could only search to revisions by a given revid AND pagetitle: f.e.: /w/api.php?action=query&prop=revisions&format=json&rvprop=timestamp%7Cuser%7Ccontent&rvlimit=10&rvstartid=100787171&titles=Benutzer%20Diskussion%3AFrieder5280

Result: Revision including Content But i want to get the revision-content only by a given revid (f.e.: 100787171).

Thanks.

Frieder5280 (talk) 14:47, 12 March 2012 (UTC)

Suggestion for including thumbnail location
Within, I suggest (for this example):  which would allow to append the two url fragments with the width in pixel in between. Maybe add a "default='90'" attribute, containing the actual width (in pixel) of the tumbnail used for image thumbnail links and galleries. That would ensure that no needless recreation of the thumbnail would occur, and that the thumbnail is available fast (and fits in a 120x120 div or td :-) To match this, "iiprop=thumb". --Magnus Manske 21:47, 8 July 2007 (UTC)


 * I don't think it will be wise to expose how images are actually stored on the server - it will force us to always use the same storage schema. What is the actual goal you are trying to achieve? To allow clients to get resized image? --Yurik 22:04, 8 July 2007 (UTC)


 * I think this is a great idea. It would allow third party tools that manage images on the wiki to get a preview, which is useful for all sorts of things. For example, an image insertion wikitext helper written in javascript.


 * Yes, this exposes our storage schema, but it actually makes it easier to change the scheme in future, because the API just has to use the new scheme and all the tools using it will reflect that. Without the API to bridge image names and their thumbnail storage, any third party tools would have to be intimately knowledgeable of our thumbnail storage scheme because the only way they can get the images is to reimplement the directory algorithm. Jim Higson 11:33, 21 August 2007 (UTC)


 * On reflection, something like this might be better (Using Magnus's example image again)


 * 


 * (where $1 is a placeholder for the size)


 * Which is nice because it shares a pattern with how we represent interwiki addresses, and we aren't stuck with using a "before bit" and an "after bit" if we later change the URL scheme for thumbnails. Jim Higson 11:48, 21 August 2007 (UTC)

Getting Page Restrictions
Is it possible to add the 'page restriction' columns to the query report? &#91;user:jldupont&#124;Jean-Lou Dupont]
 * Already done: http://en.wikipedia.org/w/api.php?action=query&prop=info&titles=Main%20Page&inprop=protection --Yurik 01:54, 11 July 2007 (UTC)
 * At some point, can we get documentation on here regarding the inprop=protection function? -- SatyrTN 03:45, 3 September 2007 (UTC)

Links query and redirects
Hi,

It seems that the links query for a redirect page returns a non-empty list of links (it includes the redirects). Is it normal ? The old query.php API wasn't returning this.

--NicoV 17:46, 15 July 2007 (UTC)


 * Yes, because it is impossible at this point to determine which of the links from a redirect page are redirect trgets, and which links are simple page links. --Yurik 19:14, 16 July 2007 (UTC)


 * Ah, too bad. More work for me to deal with this ;) --NicoV 19:36, 16 July 2007 (UTC)

img_sha1
It would be useful to add img_sha1 to imageinfo. Bryan Tong Minh 22:07, 29 August 2007 (UTC)

Limits?
The "limits" on this page appear to be erroneous. For example this query returns 1,373 links (as of the time this was written), even though the documentation says there is a limit of "200/1000". And, really, that's how it should be, since the limits are intended for the "list=" type of queries, not "prop=". --Russ Blau 21:13, 22 October 2007 (UTC)
 * Limit applies to the number of pages that the given option will work for, not the number of items for a given page. For example, prop=links will work only if the links are requested for fewer pages then the limit. --Yurik 22:55, 28 October 2007 (UTC)

Category members
I can see how to get which categories a page is in, but how would I get all the pages that are members of a specific category? &mdash; Timotab 04:07, 30 October 2007 (UTC)
 * See list=categorymembers. --Yurik 07:13, 3 November 2007 (UTC)

extlinks / link text
it'd be great if the link text could be displayed when using extlinks.

if this is currently doable with MW 1.11.0 (via xml or json) could someone describe how?

thanks.
 * Unfortunately, no. That information isn't stored in the database, so there's no efficient way to retrieve it. --Catrope 21:35, 23 February 2008 (UTC)

Wiktionary links ?
Hi,

is there a simple way to get wiktionary links or interwiki links (other than language links given by langlinks query) ?

--NicoV 10:44, 29 December 2007 (UTC)
 * Unfortunately not. If you really, desperately wanna know, you'll have to parse the page content (obtainable through prop=revisions&rvprop=content). --Catrope 12:50, 29 December 2007 (UTC)


 * Thanks for the answer but that's really not simple : I need to call expandtemplates to have all the templates expanded and then parse the result. Could a feature like this be added in a future release ?
 * My need is for a tool helping for fixing disambiguation links: when the dab page contains a link to a wiktionary page, then this link can also be used for fixing links to that dab page. --NicoV 23:19, 29 December 2007 (UTC)

links query and anchors
Hi, if a page contains text, is there a way for the links request to return the anchor information ? --NicoV 19:24, 23 February 2008 (UTC)
 * Short answer: No.
 * Long answer: unfortunately, that information is not stored in the database, so it would be ridiculously expensive to parse the entire page just for that. --Catrope 21:31, 23 February 2008 (UTC)
 * Ok, thanks, I was afraid of that. --NicoV 22:09, 23 February 2008 (UTC)

sort revisions
Hi folks,

I want to sort revisions by listing (ArticleA|ArticleB|ArticleC|...) not by alphabetic order if the 'title' is this possible? merci & VanGore 21:42, 29 September 2008 (UTC) ( importet from es, sorry VanGore 16:34, 2 October 2008 (UTC) )

Category id
Hi

It would be great to have category ids in tags, and not only the category names, which can be quite complicated to handle in some cases (encoding issues etc.). Is it likely to be implemented in the near future?

Example:

http://en.wikipedia.org/w/api.php?action=query&titles=Category:Philosophy&prop=categories

     

PageId of deleted pages ?
Hi,

Is there a way to get the pageid of a deleted page ? A request like |ids|timestamp&prop=revisions|info&action=query&titles=Synapse_Graphics&format=xml this one returns the page id only if the page is still existing.

I'd like to retrieve this because the Check Wikipedia project uses this information to identify a page. See for example, the done button calls an url with the page id. In my tool, I'd like to call this url when the error is fixed, but I can't get the pageid from the API.

Thanks, --NicoV 11:59, 4 April 2010 (UTC)

Is it mandatory that a title be provided when using prop=revisions?
Or is there a way to get it to work when only revision IDs are provided? Thanks, Tisane 11:57, 13 May 2010 (UTC)


 * Did you try http://en.wikipedia.org/w/api.php?action=query&revids=691810&prop=revisions and see what happens? --R&#39;n&#39;B 18:29, 13 May 2010 (UTC)
 * Ah, yes, that works great! http://en.wikipedia.org/w/api.php?action=query&revids=691810&prop=revisions&rvprop=ids|flags|timestamp|user|comment|content That's just what I needed. Thanks, Tisane 23:36, 13 May 2010 (UTC)

Duplicates - commons vs. wikipedia
I notice the duplicates part of the API doesn't include the feature available on the standard interface at WP. for example, has the following listed on the standard interface: The following file is a duplicate of this file (more details): However the query returns nothing:. Magog the Ogre 00:45, 19 October 2010 (UTC)
 * File:Al Cole.jpg from Wikimedia Commons.

Perhaps a new XML field like would be useful. In any case, the work around of course is to gather the hash on en.wp then use allimages on commons. Magog the Ogre 03:56, 19 October 2010 (UTC)

info / in
Unless I'm missing something (like a mis-implementation I'm unaware of), the info property was available as of MW 1.8, not MW 1.9 as indicated on the page. Can someone confirm this? The parameters look to have only been added in 1.11, though. RobinHood70 23:30, 11 November 2010 (UTC)

Using the example, I'm seeing the following properties by default (not those listed):
 * "pageid": 736,
 * "ns": 0,
 * "title": "Albert Einstein",
 * "touched": "2011-07-10T23:01:21Z",
 * "lastrevid": 438818714,
 * "counter": "",
 * "length": 93725

Is this the new default list? --Dmb 21:21, 11 July 2011 (UTC)

links / pl
Are links occurring in templates included in api call results? --Smihael 09:21, 6 August 2011 (UTC) I checked, they are. --Smihael 09:25, 6 August 2011 (UTC)

Revision content contains localized namespace
When I try to get page content from English project I expect it to use English namespace. Why do I get French ones ? Is it because DavidL account language is set to French ? Why did I get English namespace for this other page ? Is it because BryanBot account language is set to English ? This seems to be a security problem: --DavidL (talk) 14:37, 10 March 2013 (UTC)
 * https://en.wikibooks.org/w/api.php?action=query&titles=User%3ADavidL%2FSignature&prop=revisions&rvlimit=1&rvdir=newer&rvprop=timestamp%7Cuser%7Ccomment%7Ccontent&format=json
 * https://en.wikibooks.org/w/api.php?action=query&titles=User%3ABryanBot&prop=revisions&rvlimit=1&rvdir=newer&rvprop=timestamp|user|comment|content&format=json
 * you can guess language settings from users by reading one of their pages.
 * running bot on such page would not work properly.

links/pl with revid
Is there any way to list all links from specific revid? Or I have to get the content of that revid and extract links by myself? --Nullzero (talk) 18:42, 24 March 2013 (UTC) I just found that it can be done by action=parse. --Nullzero (talk) 07:09, 25 March 2013 (UTC)

rvpop pipes
Has anyone experienced there install having issues with the pipe character in the rvpop?

rvprop=ids|content|timestamp|user

works with %7C rvprop=ids%7Ccontent%7Ctimestamp%7Cuser
 * It's normal if you're typing directly the full url because it has to be URL encoded, and "|" is URL encoded as "%7C". To construct the URL, you should use a library/framework that do the URL encoding for you. --NicoV (talk) 20:33, 17 May 2013 (UTC)

Commons API variation for rvcontinue/rvstartid
Using something like "page.getVersionHistory(getAll=True)" returns errors when looking at pages on Commons that need to use the rvcontinue parameter. This is because the API uses "rvcontinue" rather than "rvstartid".

The line in wikipedia.py "params['rvstartid'] = result['query-continue']['revisions']['rvstartid']" I changed to "params['rvstartid'] = result['query-continue']['revisions']['rvcontinue']" as a dodgy work around. --Fæ (talk) 13:06, 30 September 2013 (UTC)

Requesting with multiple titles
I tried to use property "user" with multiple pages, as I was doing normally with other properties in my little "program" to test the mw API, but I'm getting the following message:

code: rvmultpages
 * info: titles, pageids or a generator was used to supply multiple pages, but the limit, startid, endid, dirNewer, user, excludeuser, start and end parameters may only be used on a single page.

Why this limitation?

Thanks for you attention.

Guiwp (talk) 14:28, 16 November 2013 (UTC)

rvprop=contentformat
Is there a reason there's no rvprop=contentformat? Would that be a useful addition? Thanks, Leucosticte (talk) 06:53, 25 February 2014 (UTC)

Sections
Is it possible to retrieve the list of valid section names and numbers (as passed to, etc.)? Preferably without manual parsing. Keφr 13:37, 8 March 2014 (UTC)
 * Found at API:Parse. A bit counterintuitive, though. (Why is this not available through API:Revisions?) Keφr 22:26, 10 March 2014 (UTC)

rvdiffto not working with sectionless pages?
It complains about there being no such section, but no section was even mentioned in the request. It outputs the revisions if rvdiffto is removed, but that obviously defeats the point if you're after the diffs...

124.181.106.190 07:01, 30 March 2014 (UTC)


 * Actually, upon further testing, it appears to not work with any page which doesn't support sections (css and js pages, for example). Strangely, rvdifftotext does work, so you could potentially work around this bug by retrieving the text you want to diff to, then putting that text in rvdifftotext. 124.181.106.190 00:58, 31 March 2014 (UTC)

How does the search API for MediaWiki work?
I am using media wiki search API i.e.  in one of my project.

When I am trying to search for Taj Mahal Agra, my search results does not show any result for Taj Mahal although its one of the very popular place of India.

Infact there are no actual search results are returned, instead some suggested results are returned and it is not even possible to identify that the returned results are not the actual results and they are the suggested one instead.

Expected was, that the API to return actual search result with atleast for Taj Mahal as the first element in the resulting response.

And my concern is that I need to search with the string "Taj Mahal Agra" and not with only "Taj Mahal".

Please advice.

Thank you in advance.


 * When I click on the link you provided, I get results, so I'm not sure what the problem is. I'm not sure what you mean by "suggested results" instead of "actual results", though. Can you clarify? Also, if you want to search for the specific phrase "Taj Mahal Agra", just enclose it in quotes in the srsearch parameter. – RobinHood70 talk 18:43, 8 January 2015 (UTC)


 * RobinHood70, Thanks for replying. What I meant was that the search results should show the result for title "Taj Mahal" i.e. (For More Info, I mean the article Taj Mahal) as it is a very famous place. And as you said that when you clicked on the link provided by me and it showed you the search results, but they are not the actual search results I guess. I am saying so because, if you search in wikipedia for any article, if the article is searched then it immediately redirects to that article only, while if the article that was searched for doesnot exist, then it shows some list of suggested articles. And this list of articles is what is being provided by the link  . You can compare the response provided with the list appears when you search in wikepedia with phrase "Taj Mahal Agra". Since this is the most popular place of India, I believe that it should show the article Taj Mahal. Even this article is not being retrieved if one also tries to search with the phrase "Taj Mahal, Agra, India" or something similar to it. It is being retrieved only with the phrase "Taj Mahal". So I belive that the article should also be retrieved with the phrase "Taj Mahal Agra" as well as Taj Mahal Agra India. Please Advice.--Krishdamani (talk) 06:00, 9 January 2015 (UTC)


 * The lists may be in a different order, but they should show the same results if you were to go through them all, assuming you limited your search to just Main space on Wikipedia. To see more than just the first set of results for the API, you have to use the "continue" parameter, as documented here. If you do that, you'll see that Taj Mahal appears in the third set of results. Perhaps it should be higher, but I don't think either Wikipedia or the API have any concept of "most popular". Or have I misunderstood what you wanted? – RobinHood70 talk 06:26, 9 January 2015 (UTC)

Submodules short descriptions
It could be useful to add a short description for each sub-module. I could do it but I don't know if there is a specific format for that. Any suggestion?

--Mikima (talk) 08:15, 24 June 2015 (UTC)