Jump to content

API talk:Properties

Add topic
From mediawiki.org
Latest comment: 4 years ago by Le Deluge in topic Increasing limit on image comment size?

Getting revision content only via revid

[edit]

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

Suggestion for including thumbnail location

[edit]

Within <imageinfo>, I suggest (for this example):

<thumbnail url_before="http://upload.wikimedia.org/wikipedia/commons/thumb/3/37/PassifloraCaerulea-flower-1m.jpg/" url_after="px-PassifloraCaerulea-flower-1m.jpg">

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

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)Reply
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)Reply
On reflection, something like this might be better (Using Magnus's example image again)
<thumbnail url="http://upload.wikimedia.org/wikipedia/commons/thumb/3/37/PassifloraCaerulea-flower-1m.jpg/$1-PassifloraCaerulea-flower-1m.jpg" />
(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)Reply

Getting Page Restrictions

[edit]

Is it possible to add the 'page restriction' columns to the query report? [user:jldupont|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)Reply
At some point, can we get documentation on here regarding the inprop=protection function? -- SatyrTN 03:45, 3 September 2007 (UTC)Reply
[edit]

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

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)Reply
Ah, too bad. More work for me to deal with this ;) --NicoV 19:36, 16 July 2007 (UTC)Reply

img_sha1

[edit]

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

Limits?

[edit]

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

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

Category members

[edit]

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? — Timotab 04:07, 30 October 2007 (UTC)Reply

See list=categorymembers. --Yurik 07:13, 3 November 2007 (UTC)Reply
[edit]

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)Reply
[edit]

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

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)Reply
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)Reply
[edit]

Hi, if a page contains [[link#anchor|text]], is there a way for the links request to return the anchor information ? --NicoV 19:24, 23 February 2008 (UTC)Reply

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)Reply
Ok, thanks, I was afraid of that. --NicoV 22:09, 23 February 2008 (UTC)Reply

sort revisions

[edit]

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 [[Talk:API:Query - Properties/es|es]], sorry VanGore 16:34, 2 October 2008 (UTC))Reply

Category id

[edit]

Hi

It would be great to have category ids in <cl /> 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

<xml version="1.0">
<api>
  <query>
    <pages>
      <page pageid="691810" ns="14" title="Category:Philosophy">
        <categories>
          <cl pageid="1111" ns="14" title="Category:Abstraction" />
          <cl pageid="2222" ns="14" title="Category:Belief" />
          <cl pageid="3333" ns="14" title="Category:Culture" />
          <cl pageid="4444" ns="14" title="Category:Humanities" />
        </categories>
      </page>
    </pages>
  </query>
</api>

PageId of deleted pages ?

[edit]

Hi,

Is there a way to get the pageid of a deleted page ? A request like 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)Reply

Is it mandatory that a title be provided when using prop=revisions?

[edit]

Or is there a way to get it to work when only revision IDs are provided? Thanks, Tisane 11:57, 13 May 2010 (UTC)Reply

Did you try http://en.wikipedia.org/w/api.php?action=query&revids=691810&prop=revisions and see what happens? --R'n'B 18:29, 13 May 2010 (UTC)Reply
Ah, yes, that works great! http://en.wikipedia.org/w/api.php?action=query&revids=691810&prop=revisions&rvprop=ids%7Cflags%7Ctimestamp%7Cuser%7Ccomment%7Ccontent That's just what I needed. Thanks, Tisane 23:36, 13 May 2010 (UTC)Reply

Duplicates - commons vs. wikipedia

[edit]

I notice the duplicates part of the API doesn't include the feature available on the standard interface at WP. w:File:AlCole.JPG 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: [1]. Magog the Ogre 00:45, 19 October 2010 (UTC)Reply

Perhaps a new XML field like <commonsduplicates> 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)Reply

info / in

[edit]

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

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

[edit]

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

Revision content contains localized namespace

[edit]

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:

  • you can guess language settings from users by reading one of their pages.
  • running bot on such page would not work properly.

--DavidL (talk) 14:37, 10 March 2013 (UTC)Reply

links/pl with revid

[edit]

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

rvpop pipes

[edit]

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

Commons API variation for rvcontinue/rvstartid

[edit]

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. -- (talk) 13:06, 30 September 2013 (UTC)Reply

Requesting with multiple titles

[edit]

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

rvprop=contentformat

[edit]

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

Sections

[edit]

Is it possible to retrieve the list of valid section names and numbers (as passed to &section=, etc.)? Preferably without manual parsing. Keφr 13:37, 8 March 2014 (UTC)Reply

Found at API:Parse. A bit counterintuitive, though. (Why is this not available through API:Revisions?) Keφr 22:26, 10 March 2014 (UTC)Reply

rvdiffto not working with sectionless pages?

[edit]

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...

Result
{
    "servedby": "mw1142",
    "error": {
        "code": "rvnosuchsection",
        "info": "There is no section  in r574596"
    }
}

124.181.106.190 07:01, 30 March 2014 (UTC)Reply

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

How does the search API for MediaWiki work?

[edit]

I am using media wiki search API i.e. http://en.wikipedia.org/w/api.php?action=query&list=search&format=json&srsearch=Taj+Mahal+Agra 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)Reply
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 http://en.wikipedia.org/w/api.php?action=query&list=search&format=json&srsearch=Taj+Mahal+Agra. 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)Reply
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)Reply
Adding a redirect from Taj Mahal, Agra solved this particular case. Rich Farmbrough 21:36, 14 April 2016 (UTC).Reply

Submodules short descriptions

[edit]

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

Increasing limit on image comment size?

[edit]

I'm trying to extract date information from image files on Commons and en.wiki, and whilst it's often to be found in camera metadata or categories, sometimes the only source is in the Date= field in the Information template of the comment (as eg on File:Albert Einstein's exam of maturity grades (color2).jpg). But I can't access it via the Imageinfo comment field because the date is outside the 200-character limit for that field. Is there a way to either increase the character limit or grab the date field directly somehow? TIA Le Deluge (talk) 08:56, 27 March 2020 (UTC)Reply