Movatterモバイル変換


[0]ホーム

URL:


Keyboard Shortcuts

Thread View

  • j: Next unread message
  • k: Previous unread message
  • j a: Jump to all threads
  • j l: Jump to MailingList overview
List overview
Download

Mediawiki-apiJanuary 2013

mediawiki-api@lists.wikimedia.org
  • 14 participants
  • 14 discussions
Start a nNew thread

20 Jan '26
Hi there,I'm using the API to extract the raw wiki text from my pages, usingthe "?action=query&titles=Main_Page&export&exportnowrap" syntax. Thatworks perfectly.Now I would like to get the templates expanded out in the result, so Iuse: "?action=query&titles=Main_Page&prop=revisions&rvlimit=1&rvprop=content&rvexpandtemplates",which does the job, as expected, but it also strips out the comments.My problem is that the comments are meaningful to me (I use them tohelp process the wiki text in subsequent steps).Is there a way to expand templates with the API, but leave thecomments intact?Thanks,Kevin
4 5
0 0
Need to extract abstract of a wikipedia page
by aditya srinivas 23 Nov '23

23 Nov '23
Hello,I am writing a Java program to extract the abstract of the wikipedia pagegiven the title of the wikipedia page. I have done some research and foundout that the abstract with be in rvsection=0 So for example if I want the abstract of 'Eiffel Tower" wiki page then I amquerying using the api in the following way.http://en.wikipedia.org/w/api.php?action=query&prop=revisions&titles=Eiffel…and parse the XML data which we get and take the wikitext in the tag <revxml:space="preserve"> which represents the abstract of the wikipedia page.But this wiki text also contains the infobox data which I do not need. Iwould like to know if there is anyway in which I can remove the infobox dataand get only the wikitext related to the page's abstract Or if there is anyalternative method by which I can get the abstract of the page directly.Looking forward to your help.Thanks in AdvanceAditya Uppu
4 3
0 0

26 Jan '13
After talking to some of you at the office on Friday (was great, thanks!),and reading some new suggestions (thanks Brion), it seems API has gainedseveral distinct, slightly overlapping areas of operation.* SQL-like: This is what the API is best at - providing complex structuredaccess to the database - various page properties and lists like "what pageslink to X". The prime beneficiaries are bots (spam fighting, link/iwfixing, etc). Required improvements are fairly cosmetic in nature -minor refactoring, warning/error localization, per module versioning (seeRFC <http://www.mediawiki.org/wiki/Requests_for_comment/API_Future>).* Actions (MasterDB changes): API has greatly grown in this area, providingaccess to most MW functionality like editing, uploading, watching, accountcreation, etc. Some cleanup work might still be required, i.e. better tokenmanagement, but overall this portion is also fairly mature.* Content - wiki markup/html/sub-sections - this area seems to needimprovements the most, due to the much wider variety and style of uses andthe potential server load.For example, mobile requires quick access to rendered individual sectionsof an article, a web site might embed the page header, a javascript clientsmight want some pieces of information specific to the given site - textfrom some table, template parameters, and many other - this list *needs tobe expanded* for better planning, ideally at the RFCpage<http://www.mediawiki.org/wiki/Requests_for_comment/API_Future>.Unlike query, content-access rarely requires multi-source aggregatedresults, yet has a much higher usage load, making it the primary target forcaching. In my opinion, this difference is the root of misunderstandingbetween the REST and the current API style advocates.This brings us to how we want to grow the "content API", assuming thatcaching is by far the most important concern:* JSON-only output* Minimum number of parameters* URL rewritingMost improvements for querying and actions are listed athttp://www.mediawiki.org/wiki/Requests_for_comment/API_Future and arecurrently being worked on, but the content approach needs use cases,requests, and interface suggestions.
1 0
0 0
I'm going to copy this to the mediawiki-api list, too.On Fri, Jan 25, 2013 at 8:01 AM, Daniel Kinzler <daniel(a)brightbyte.de> wrote:> Hi all!>> Wikidata (technically, Wikibase) uses a lot of JS/API based editing, and we have> several times hit upon the question of how to best report errors from the API.> I'll try to break the issue down into several concrete questions. But first off,> the status quo as I understand it:>> * errors are reported using an error code (a string) and a free form error> message. The message is usually not internationalized, though sometimes it is.> * warnings are reported as free form text.> * Additional information can be added to both errors and warnings, but there is> no standard way to do this.> * Errors exposed by the API are often not generated but just passed through by> the API; Typically, a generic error code is used with the original error message> (e.g. from an exception).Sounds generally correct. Anything coming out of the APIinternationalized is probably either being passed through fromsomething else or being generated in an extension.> So, here are my questions:>> * Should error messages returned by the API be translated? Or should the> translation be left to JavaScript in the client?> ** In both cases, it would be nice to have a consistent relationship between> error codes and the corresponding system message.> ** If translation is done on the client, we need to pass any message parameters> separately.> ** The message key would have to somehow be derived or mapped from the error code.It would be nice to have internationalized and parameterized errormessages from the API. The problem is that if we want to do anythingwithout waiting for "API version 2", we want to avoid as much aspossible breaking backwards compatibility with existing clients. Whichprobably means that we'll want to add a parameter for the client tospecify the new style errors and warnings; this can double asselecting the language the errors should be returned in.I'd have to look at what existing code does as far as errors/warningsbefore making a more concrete proposal.> * When using system messages to translate the error codes from the API, these> messages will often contain wikitext. How can we best avoid this? Wikitext is> likely to be quite useless to the client - it would be better to return HTML; or> pass all the message keys and parameters, and let the client generate the message.I'd suggest that messages actually returned by the API should be inplain text, and should ''not'' use the MediaWiki namespace. In termsof the Message class, $msg->useDatabase( false )->text(). This makesthings sensible for bots and such; they will often be writing errorsto a log file or showing them in some user interface where HTMLparsing is probably not available.The message key and parameters should (optionally?) be returned forthe client to format as HTML or whatever. And the client is welcome touse the MediaWiki namespace. This is sensible for Javascript userinterface and such.Unfortunately, it seems that the message key prefix "api-error-" isalready in use.> * Status objects are often used to collect errors and warnings the occur while> trying to perform some task. It would be nice if the API would provide a> standard way to put the contents of a Status object into the result (well, at> least the errors and warnings).It seems it does, at least sort of: ApiResult has aconvertStatusToArray() method.> Any thoughts on that?>> -- daniel
3 2
0 0
Can't login to MW 1.71 - "WrongToken"
by Levin Magruder 25 Jan '13

25 Jan '13
I'm trying to use the API in Mediawiki 1.17. I can't get logged in.I am getting a "WrongToken". I think I have the right lgtoken andsession cookie, but I've never done any http programming, can anyonetell from the sequence below what I have wrong. Probably/hopefully it's some simple newbie mistake in not understanding how to handle a cookie or make a session not expire.The user/password combo is able to login thru the normal interactive web interface.ThanksLevin--------------------------------------------------------------------------------Begin Attempt--------------------------------------------------------------------------------POST /mw/api.php HTTP/1.1Cache-Control: no-cachePragma: no-cacheUser-Agent: Java/1.7.0_09Host:wiki.readytheory.comAccept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2Connection: keep-aliveContent-type: application/x-www-form-urlencodedContent-Length: 59format=xml&action=login&lgname=mybot&lgpassword=pwd--------------------------------------------------------------------------------First response:--------------------------------------------------------------------------------HTTP/1.1 200 OKDate: Thu, 24 Jan 2013 04:04:01 GMTServer: Apache/2.2.23 (Amazon)X-Powered-By: MonoSet-Cookie: wikidb_session=8foa9hj555b6re8mri4ajd7qi3; path=/; HttpOnlyCache-Control: privateContent-Length: 162Connection: closeContent-Type: text/xml; charset=utf-8<?xml version="1.0"?><api><login result="NeedToken" token="0e8287f8976207131b153ca2acf25cfb" cookieprefix="wikidb" sessionid="8foa9hj555b6re8mri4ajd7qi3" /></api>--------------------------------------------------------------------------------SECOND request with cookie--------------------------------------------------------------------------------POST /mw/api.php HTTP/1.1Cookie: wikidb_session=8foa9hj555b6re8mri4ajd7qi3Cache-Control: no-cachePragma: no-cacheUser-Agent: Java/1.7.0_09Host:wiki.readytheory.comAccept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2Connection: keep-aliveContent-type: application/x-www-form-urlencodedContent-Length: 99format=xml&action=login&lgname=mybot&lgpassword=pwd&lgtoken=0e8287f8976207131b153ca2acf25cfb --------------------------------------------------------------------------------second response, where I get "WrongToken"--------------------------------------------------------------------------------HTTP/1.1 200 OKDate: Thu, 24 Jan 2013 04:04:01 GMTServer: Apache/2.2.23 (Amazon)X-Powered-By: MonoCache-Control: privateContent-Length: 61Connection: closeContent-Type: text/xml; charset=utf-8<?xml version="1.0"?><api><login result="WrongToken" /></api>
3 4
0 0
Since it has been broken since the move to git[1] and is unlikely tohave been particularly useful anyway, I've just merged a change[2] toremove the version information (and the 'version' parameter) from theAPI help. This may result in a warning about an unrecognizedparameter.Also, the 'version' property in the results from action=paraminfo willnow be the empty string. It was not removed completely at this time toavoid breaking clients where accessing an undefined property is afatal error; however, it should be considered deprecated and may beremoved in a future version.Note that version information for MediaWiki as a whole is stillavailable via prop=siteinfo.[3] [1]:https://bugzilla.wikimedia.org/show_bug.cgi?id=35885 [2]:https://gerrit.wikimedia.org/r/#/c/43622/ [3]: e.g.https://en.wikipedia.org/w/api.php?action=query&meta=siteinfo-- Brad JorschSoftware EngineerWikimedia Foundation_______________________________________________Mediawiki-api-announce mailing listMediawiki-api-announce(a)lists.wikimedia.orghttps://lists.wikimedia.org/mailman/listinfo/mediawiki-api-announce
1 0
0 0
For badcontinue errors, the API currently returns a code of either"??badcontinue" or "??_badcontinue" (where ?? is the module's prefix),depending on the module. The human-readable error message text mayalso vary depending on the module.In 1.21wmf8,[1] these will be standardized as "??badcontinue", with ahuman-readable message of "Invalid continue param. You should pass theoriginal value returned by the previous query".Since well-behaved API clients should never see this error message,this change should not require any client updates. [1]: Gerrit changehttps://gerrit.wikimedia.org/r/#/c/42398-- Brad JorschSoftware EngineerWikimedia Foundation_______________________________________________Mediawiki-api-announce mailing listMediawiki-api-announce(a)lists.wikimedia.orghttps://lists.wikimedia.org/mailman/listinfo/mediawiki-api-announce
1 0
0 0

11 Jan '13
Hi,Something changed in the last couple of days that causes a bunch of APIcalls to fail when grabbing image dimensions.This error is consistently generated from the URL below:{"servedby":"mw72","error":{"code":"internal_api_error_MWException","info":"ExceptionCaught: Internal error in ApiResult::setElement: Attempting to addelement imagerepository=shared, existing value is shared","*":""}}http://en.wikipedia.org/w/api.php?titles=File:Convento_Cristo_Decemebr_2008…Requesting the data separately, i.e.http://en.wikipedia.org/w/api.php?titles=File:Convento_Cristo_Decemebr_2008…andhttp://en.wikipedia.org/w/api.php?titles=File:Convento_Cristo_Decemebr_2008…give the correct result.Other multi-queries likehttp://en.wikipedia.org/w/api.php?titles=File:Convento_Cristo_Decemebr_2008…also consistently work fine.What's going on here?Thanks,Eric
2 1
0 0
APIv2 alpha implementation
by Yuri Astrakhan 09 Jan '13

09 Jan '13
It's almost New Year, and time for presents (according to the Russiantraditions).I hereby present you the API versioning framework. Navigate tohttps://gerrit.wikimedia.org/r/#/c/41014/ and get that patch to your localinstallation for a test run.There shouldn't be any visible functionality changes. At least that was thegoal. But now we can easily add a new version module or a submodule(prop/list/etc) without breaking existing code.To see it in action -- in ApiMain.php, add this line into $Modules array: 'query2' => 'ApiQuery',it adds another version of query implemented by the same existing class.now if you look athttp://localhost/api.php you will see* action=query * This module is obsolete. See old documentation atapi.php?action=help&modules=query* action=query2 *... -- the regular query parameters -- ...both query and query2 will work identically in this example unless youchange ApiQuery.php.Let the rotten egg throwing commence!Once we settle on this, I propose you join me at the mediawiki labs --https://labsconsole.wikimedia.org/wiki/Nova_Resource:Mediawiki-apito develop and test the actual changes to the APIv2 interface. To keep itgoing full steam ahead, I will accept ideas, criticisms, cookies, codepatches, small unmarked bills and large paychecks, but most importantly -your time analyzing and commenting this effort.--Yurik
4 12
0 0
binary param
by webmaster@numerica.cl 08 Jan '13

08 Jan '13
Hello again. I've got another question using the api:One of the params my api receives is the binary representation of an hexadecimal value (the info hash),this parmeter arrives spilled to the $params array.Diving down the debug, I found that the responsible is getGPCVal method in WebRequest.php, which makes the string go through$data = $wgContLang->checkTitleEncoding( $data ); [l.340]and $data = $this->normalizeUnicode( $data ); [l.343]being therefore altered twice.I don't know much of Unicode normalization, but I do understand the problem here is it shouldn't be applied on binary data...integer type won't do though, and there is not much more choice... or maybe api types can be extended?I'm curious about checkTitleEncoding on the other hand. What is it meant for? Could I be lacking mb_check_encoding function and that's why it falls back to 8bit encoding?I can always use good old $_GET, but I feel I'd rather not. Is it really problematic?Thanks in advance for any ideas.Numerico
2 2
0 0
Results per page:

[8]ページ先頭

©2009-2026 Movatter.jp