mirror of
				https://scm.univ-tours.fr/22107988t/rappaurio-sae501_502.git
				synced 2025-11-04 07:35:22 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			6142 lines
		
	
	
		
			90 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			6142 lines
		
	
	
		
			90 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
<!DOCTYPE html>
 | 
						|
<html lang="en">
 | 
						|
<head>
 | 
						|
    
 | 
						|
    <meta charset="utf-8">
 | 
						|
    <title>Wikiapi - Documentation</title>
 | 
						|
    
 | 
						|
    
 | 
						|
    <script src="scripts/prettify/prettify.js"></script>
 | 
						|
    <script src="scripts/prettify/lang-css.js"></script>
 | 
						|
    <!--[if lt IE 9]>
 | 
						|
      <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
 | 
						|
    <![endif]-->
 | 
						|
    <link type="text/css" rel="stylesheet" href="styles/prettify.css">
 | 
						|
    <link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
 | 
						|
    <script src="scripts/nav.js" defer></script>
 | 
						|
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
 | 
						|
</head>
 | 
						|
<body>
 | 
						|
 | 
						|
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
 | 
						|
<label for="nav-trigger" class="navicon-button x">
 | 
						|
  <div class="navicon"></div>
 | 
						|
</label>
 | 
						|
 | 
						|
<label for="nav-trigger" class="overlay"></label>
 | 
						|
 | 
						|
<nav >
 | 
						|
    
 | 
						|
    <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Wikiapi.html">Wikiapi</a><ul class='methods'><li data-type='method'><a href="Wikiapi.html#category_tree">category_tree</a></li><li data-type='method'><a href="Wikiapi.html#convert_Chinese">convert_Chinese</a></li><li data-type='method'><a href="Wikiapi.html#data">data</a></li><li data-type='method'><a href="Wikiapi.html#delete">delete</a></li><li data-type='method'><a href="Wikiapi.html#download">download</a></li><li data-type='method'><a href="Wikiapi.html#edit">edit</a></li><li data-type='method'><a href="Wikiapi.html#edit_page">edit_page</a></li><li data-type='method'><a href="Wikiapi.html#for_each_page">for_each_page</a></li><li data-type='method'><a href="Wikiapi.html#get_featured_content">get_featured_content</a></li><li data-type='method'><a href="Wikiapi.html#listen">listen</a></li><li data-type='method'><a href="Wikiapi.html#login">login</a></li><li data-type='method'><a href="Wikiapi.html#move_page">move_page</a></li><li data-type='method'><a href="Wikiapi.html#move_to">move_to</a></li><li data-type='method'><a href="Wikiapi.html#new_data_entity">new_data_entity</a></li><li data-type='method'><a href="Wikiapi.html#page">page</a></li><li data-type='method'><a href="Wikiapi.html#purge">purge</a></li><li data-type='method'><a href="Wikiapi.html#query">query</a></li><li data-type='method'><a href="Wikiapi.html#redirects_here">redirects_here</a></li><li data-type='method'><a href="Wikiapi.html#redirects_root">redirects_root</a></li><li data-type='method'><a href="Wikiapi.html#register_redirects">register_redirects</a></li><li data-type='method'><a href="Wikiapi.html#search">search</a></li><li data-type='method'><a href="Wikiapi.html#site_name">site_name</a></li><li data-type='method'><a href="Wikiapi.html#SPARQL">SPARQL</a></li><li data-type='method'><a href="Wikiapi.html#tracking_revisions">tracking_revisions</a></li><li data-type='method'><a href="Wikiapi.html#upload">upload</a></li></ul></li></ul><h3>Global</h3><ul><li><a href="global.html#CeL">CeL</a></li><li><a href="global.html#KEY_SESSION">KEY_SESSION</a></li><li><a href="global.html#KEY_wiki_session">KEY_wiki_session</a></li><li><a href="global.html#modify_data_entity">modify_data_entity</a></li><li><a href="global.html#page_data_attributes">page_data_attributes</a></li><li><a href="global.html#reject_edit_error">reject_edit_error</a></li><li><a href="global.html#set_page_data_attributes">set_page_data_attributes</a></li><li><a href="global.html#setup_data_entity">setup_data_entity</a></li><li><a href="global.html#setup_wiki_session">setup_wiki_session</a></li><li><a href="global.html#wiki_API">wiki_API</a></li><li><a href="global.html#Wikiapi_list">Wikiapi_list</a></li></ul>
 | 
						|
</nav>
 | 
						|
 | 
						|
<div id="main">
 | 
						|
    
 | 
						|
    <h1 class="page-title">Wikiapi</h1>
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<section>
 | 
						|
 | 
						|
<header>
 | 
						|
    
 | 
						|
        <h2>
 | 
						|
        Wikiapi
 | 
						|
        </h2>
 | 
						|
        
 | 
						|
    
 | 
						|
</header>
 | 
						|
 | 
						|
<article>
 | 
						|
    
 | 
						|
        <div class="container-overview">
 | 
						|
        
 | 
						|
            
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    <h4 class="name" id="Wikiapi"><span class="type-signature"></span>new Wikiapi<span class="signature">(API_URL<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span></h4>
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<dl class="details">
 | 
						|
 | 
						|
    
 | 
						|
    <dt class="tag-source">Source:</dt>
 | 
						|
    <dd class="tag-source"><ul class="dummy"><li>
 | 
						|
        <a href="wikiapi.js.html">wikiapi.js</a>, <a href="wikiapi.js.html#line91">line 91</a>
 | 
						|
    </li></ul></dd>
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
</dl>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<div class="description usertext">
 | 
						|
    main Wikiapi operator 操作子.
 | 
						|
</div>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
    <h5>Parameters:</h5>
 | 
						|
    
 | 
						|
 | 
						|
<table class="params">
 | 
						|
    <thead>
 | 
						|
    <tr>
 | 
						|
        
 | 
						|
        <th>Name</th>
 | 
						|
        
 | 
						|
 | 
						|
        <th>Type</th>
 | 
						|
 | 
						|
        
 | 
						|
        <th>Attributes</th>
 | 
						|
        
 | 
						|
 | 
						|
        
 | 
						|
 | 
						|
        <th class="last">Description</th>
 | 
						|
    </tr>
 | 
						|
    </thead>
 | 
						|
 | 
						|
    <tbody>
 | 
						|
    
 | 
						|
 | 
						|
        <tr>
 | 
						|
            
 | 
						|
                <td class="name"><code>API_URL</code></td>
 | 
						|
            
 | 
						|
 | 
						|
            <td class="type">
 | 
						|
            
 | 
						|
                
 | 
						|
<span class="param-type">String</span>
 | 
						|
|
 | 
						|
 | 
						|
<span class="param-type">Object</span>
 | 
						|
 | 
						|
 | 
						|
            
 | 
						|
            </td>
 | 
						|
 | 
						|
            
 | 
						|
                <td class="attributes">
 | 
						|
                
 | 
						|
                    <optional><br>
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
                </td>
 | 
						|
            
 | 
						|
 | 
						|
            
 | 
						|
 | 
						|
            <td class="description last">language code or service endpoint of MediaWiki project.<br />
 | 
						|
           Input {Object} will be treat as options.</td>
 | 
						|
        </tr>
 | 
						|
 | 
						|
    
 | 
						|
    </tbody>
 | 
						|
</table>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
        
 | 
						|
        </div>
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
    
 | 
						|
    
 | 
						|
 | 
						|
     
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
        <h3 class="subsection-title">Members</h3>
 | 
						|
 | 
						|
        
 | 
						|
            
 | 
						|
<h4 class="name" id=".KEY_subcategories"><span class="type-signature">(static) </span>KEY_subcategories<span class="type-signature"></span></h4>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<dl class="details">
 | 
						|
 | 
						|
    
 | 
						|
    <dt class="tag-source">Source:</dt>
 | 
						|
    <dd class="tag-source"><ul class="dummy"><li>
 | 
						|
        <a href="wikiapi.js.html">wikiapi.js</a>, <a href="wikiapi.js.html#line1123">line 1123</a>
 | 
						|
    </li></ul></dd>
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
</dl>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<div class="description usertext">
 | 
						|
    export key for subcategory 子分類 used in <a href="Wikiapi.html#category_tree">Wikiapi#category_tree</a>
 | 
						|
</div>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
    <h5>Example</h5>
 | 
						|
    
 | 
						|
    <pre class="prettyprint"><code>// <code>
 | 
						|
const KEY_subcategories = Wikiapi.KEY_subcategories;
 | 
						|
// </code></code></pre>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
        
 | 
						|
            
 | 
						|
<h4 class="name" id=".skip_edit"><span class="type-signature">(static) </span>skip_edit<span class="type-signature"></span></h4>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<dl class="details">
 | 
						|
 | 
						|
    
 | 
						|
    <dt class="tag-source">Source:</dt>
 | 
						|
    <dd class="tag-source"><ul class="dummy"><li>
 | 
						|
        <a href="wikiapi.js.html">wikiapi.js</a>, <a href="wikiapi.js.html#line525">line 525</a>
 | 
						|
    </li></ul></dd>
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
</dl>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<div class="description usertext">
 | 
						|
    Return <code>Wikiapi.skip_edit</code> when we running edit function, but do not want to edit current page.
 | 
						|
</div>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
        
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
        <h3 class="subsection-title">Methods</h3>
 | 
						|
 | 
						|
        
 | 
						|
            
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    <h4 class="name" id="category_tree"><span class="type-signature"></span>category_tree<span class="signature">(root_category, options<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Promise}</span></h4>
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<dl class="details">
 | 
						|
 | 
						|
    
 | 
						|
    <dt class="tag-source">Source:</dt>
 | 
						|
    <dd class="tag-source"><ul class="dummy"><li>
 | 
						|
        <a href="wikiapi.js.html">wikiapi.js</a>, <a href="wikiapi.js.html#line1099">line 1099</a>
 | 
						|
    </li></ul></dd>
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
</dl>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<div class="description usertext">
 | 
						|
    Get structural category tree with sub-categories of <code>root_category</code>. This is powerful than categorymembers. Get sub-categories with <a href="Wikiapi.html#.KEY_subcategories">Wikiapi.KEY_subcategories</a>.
 | 
						|
</div>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
    <h5>Examples</h5>
 | 
						|
    
 | 
						|
        <p class="code-caption">Checking if [[Category:Countries in North America]] including [[Mexico]].</p>
 | 
						|
    
 | 
						|
    <pre class="prettyprint"><code>// <code>
 | 
						|
const enwiki = new Wikiapi('en');
 | 
						|
const page_list = await enwiki.category_tree('Countries in North America', 1);
 | 
						|
assert(page_list.some(page_data => page_data.title === 'United States'), 'list category tree: [[Category:Countries in North America]] must includes [[United States]]');
 | 
						|
assert('Mexico' in page_list[Wikiapi.KEY_subcategories], 'list category tree: [[Category:Mexico]] is a subcategory of [[Category:Countries in North America]]');
 | 
						|
// </code></code></pre>
 | 
						|
 | 
						|
        <p class="code-caption">Get all sub-categories of [[Category:Echinodermata]] with depth=2.</p>
 | 
						|
    
 | 
						|
    <pre class="prettyprint"><code>// <code>
 | 
						|
const wiki = new Wikiapi('commons');
 | 
						|
const all_sub_categories = (await wiki.category_tree('Echinodermata', { depth: 2, cmtype: 'subcat', get_flated_subcategories: true })).flated_subcategories;
 | 
						|
// </code></code></pre>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
    <h5>Parameters:</h5>
 | 
						|
    
 | 
						|
 | 
						|
<table class="params">
 | 
						|
    <thead>
 | 
						|
    <tr>
 | 
						|
        
 | 
						|
        <th>Name</th>
 | 
						|
        
 | 
						|
 | 
						|
        <th>Type</th>
 | 
						|
 | 
						|
        
 | 
						|
        <th>Attributes</th>
 | 
						|
        
 | 
						|
 | 
						|
        
 | 
						|
 | 
						|
        <th class="last">Description</th>
 | 
						|
    </tr>
 | 
						|
    </thead>
 | 
						|
 | 
						|
    <tbody>
 | 
						|
    
 | 
						|
 | 
						|
        <tr>
 | 
						|
            
 | 
						|
                <td class="name"><code>root_category</code></td>
 | 
						|
            
 | 
						|
 | 
						|
            <td class="type">
 | 
						|
            
 | 
						|
                
 | 
						|
<span class="param-type">String</span>
 | 
						|
 | 
						|
 | 
						|
            
 | 
						|
            </td>
 | 
						|
 | 
						|
            
 | 
						|
                <td class="attributes">
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
                </td>
 | 
						|
            
 | 
						|
 | 
						|
            
 | 
						|
 | 
						|
            <td class="description last">category name</td>
 | 
						|
        </tr>
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
        <tr>
 | 
						|
            
 | 
						|
                <td class="name"><code>options</code></td>
 | 
						|
            
 | 
						|
 | 
						|
            <td class="type">
 | 
						|
            
 | 
						|
                
 | 
						|
<span class="param-type">Object</span>
 | 
						|
 | 
						|
 | 
						|
            
 | 
						|
            </td>
 | 
						|
 | 
						|
            
 | 
						|
                <td class="attributes">
 | 
						|
                
 | 
						|
                    <optional><br>
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
                </td>
 | 
						|
            
 | 
						|
 | 
						|
            
 | 
						|
 | 
						|
            <td class="description last">options to run this function.</td>
 | 
						|
        </tr>
 | 
						|
 | 
						|
    
 | 
						|
    </tbody>
 | 
						|
</table>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<h5>Returns:</h5>
 | 
						|
 | 
						|
        
 | 
						|
<div class="param-desc">
 | 
						|
    Promise object represents {Array} category_tree.
 | 
						|
</div>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<dl class="param-type">
 | 
						|
    <dt>
 | 
						|
        Type
 | 
						|
    </dt>
 | 
						|
    <dd>
 | 
						|
        
 | 
						|
<span class="param-type">Promise</span>
 | 
						|
 | 
						|
 | 
						|
    </dd>
 | 
						|
</dl>
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
 | 
						|
 | 
						|
        
 | 
						|
            
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    <h4 class="name" id="convert_Chinese"><span class="type-signature"></span>convert_Chinese<span class="signature">(text, options<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Promise}</span></h4>
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<dl class="details">
 | 
						|
 | 
						|
    
 | 
						|
    <dt class="tag-source">Source:</dt>
 | 
						|
    <dd class="tag-source"><ul class="dummy"><li>
 | 
						|
        <a href="wikiapi.js.html">wikiapi.js</a>, <a href="wikiapi.js.html#line1616">line 1616</a>
 | 
						|
    </li></ul></dd>
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
</dl>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<div class="description usertext">
 | 
						|
    convert text to traditional Chinese / simplified Chinese.
 | 
						|
</div>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
    <h5>Example</h5>
 | 
						|
    
 | 
						|
        <p class="code-caption">繁簡轉換</p>
 | 
						|
    
 | 
						|
    <pre class="prettyprint"><code>// <code>
 | 
						|
const wiki = new Wikiapi('en');
 | 
						|
await wiki.convert_Chinese('中国', { uselang: 'zh-hant' });
 | 
						|
await wiki.convert_Chinese('中國', { uselang: 'zh-hans' });
 | 
						|
await wiki.convert_Chinese(['繁體', '簡體'], { uselang: 'zh-hans' });
 | 
						|
// </code></code></pre>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
    <h5>Parameters:</h5>
 | 
						|
    
 | 
						|
 | 
						|
<table class="params">
 | 
						|
    <thead>
 | 
						|
    <tr>
 | 
						|
        
 | 
						|
        <th>Name</th>
 | 
						|
        
 | 
						|
 | 
						|
        <th>Type</th>
 | 
						|
 | 
						|
        
 | 
						|
        <th>Attributes</th>
 | 
						|
        
 | 
						|
 | 
						|
        
 | 
						|
 | 
						|
        <th class="last">Description</th>
 | 
						|
    </tr>
 | 
						|
    </thead>
 | 
						|
 | 
						|
    <tbody>
 | 
						|
    
 | 
						|
 | 
						|
        <tr>
 | 
						|
            
 | 
						|
                <td class="name"><code>text</code></td>
 | 
						|
            
 | 
						|
 | 
						|
            <td class="type">
 | 
						|
            
 | 
						|
                
 | 
						|
<span class="param-type">String</span>
 | 
						|
|
 | 
						|
 | 
						|
<span class="param-type">Array</span>
 | 
						|
|
 | 
						|
 | 
						|
<span class="param-type">Object</span>
 | 
						|
 | 
						|
 | 
						|
            
 | 
						|
            </td>
 | 
						|
 | 
						|
            
 | 
						|
                <td class="attributes">
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
                </td>
 | 
						|
            
 | 
						|
 | 
						|
            
 | 
						|
 | 
						|
            <td class="description last">text or objects to convert. Will convert to {String} using JSON.stringify().</td>
 | 
						|
        </tr>
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
        <tr>
 | 
						|
            
 | 
						|
                <td class="name"><code>options</code></td>
 | 
						|
            
 | 
						|
 | 
						|
            <td class="type">
 | 
						|
            
 | 
						|
                
 | 
						|
<span class="param-type">Object</span>
 | 
						|
 | 
						|
 | 
						|
            
 | 
						|
            </td>
 | 
						|
 | 
						|
            
 | 
						|
                <td class="attributes">
 | 
						|
                
 | 
						|
                    <optional><br>
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
                </td>
 | 
						|
            
 | 
						|
 | 
						|
            
 | 
						|
 | 
						|
            <td class="description last">options to run this function</td>
 | 
						|
        </tr>
 | 
						|
 | 
						|
    
 | 
						|
    </tbody>
 | 
						|
</table>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<h5>Returns:</h5>
 | 
						|
 | 
						|
        
 | 
						|
<div class="param-desc">
 | 
						|
    Promise object represents the converted text.
 | 
						|
</div>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<dl class="param-type">
 | 
						|
    <dt>
 | 
						|
        Type
 | 
						|
    </dt>
 | 
						|
    <dd>
 | 
						|
        
 | 
						|
<span class="param-type">Promise</span>
 | 
						|
 | 
						|
 | 
						|
    </dd>
 | 
						|
</dl>
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
 | 
						|
 | 
						|
        
 | 
						|
            
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    <h4 class="name" id="data"><span class="type-signature"></span>data<span class="signature">(data_entity, options<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Promise}</span></h4>
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<dl class="details">
 | 
						|
 | 
						|
    
 | 
						|
    <dt class="tag-source">Source:</dt>
 | 
						|
    <dd class="tag-source"><ul class="dummy"><li>
 | 
						|
        <a href="wikiapi.js.html">wikiapi.js</a>, <a href="wikiapi.js.html#line841">line 841</a>
 | 
						|
    </li></ul></dd>
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
</dl>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<div class="description usertext">
 | 
						|
    Get wikidata entity / property
 | 
						|
</div>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
    <h5>Examples</h5>
 | 
						|
    
 | 
						|
        <p class="code-caption">Get wikidata entity method 1</p>
 | 
						|
    
 | 
						|
    <pre class="prettyprint"><code>// <code>
 | 
						|
const wiki = new Wikiapi;
 | 
						|
const data_entity = await wiki.data('Q1');
 | 
						|
// Work with other language
 | 
						|
console.assert(CeL.wiki.data.value_of(data_entity.labels.zh) === '宇宙');
 | 
						|
// </code></code></pre>
 | 
						|
 | 
						|
        <p class="code-caption">Get wikidata entity of [[Human]]</p>
 | 
						|
    
 | 
						|
    <pre class="prettyprint"><code>// <code>
 | 
						|
const wiki = new Wikiapi;
 | 
						|
const page_data = await wiki.page('Human');
 | 
						|
const data_entity = await wiki.data(page_data);
 | 
						|
console.assert(CeL.wiki.data.value_of(data_entity.labels.zh) === '人類');
 | 
						|
// </code></code></pre>
 | 
						|
 | 
						|
        <p class="code-caption">Get wikidata entity method 2: Get P1419 of wikidata entity: 'Universe'</p>
 | 
						|
    
 | 
						|
    <pre class="prettyprint"><code>// <code>
 | 
						|
const wiki = new Wikiapi;
 | 
						|
// Read, access by title (English), access property P1419
 | 
						|
let data = await wiki.data('Universe', 'P1419');
 | 
						|
// assert: {Array}data = [ 'shape of the universe', '', ... ]
 | 
						|
console.assert(data.includes('shape of the universe'));
 | 
						|
// </code></code></pre>
 | 
						|
 | 
						|
        <p class="code-caption">update wikidata</p>
 | 
						|
    
 | 
						|
    <pre class="prettyprint"><code>// <code>
 | 
						|
// Just for test
 | 
						|
delete CeL.wiki.query.default_maxlag;
 | 
						|
const wiki = new Wikiapi;
 | 
						|
await wiki.login('user', 'password', 'test');
 | 
						|
 | 
						|
// Get https://test.wikidata.org/wiki/Q7
 | 
						|
let entity = await wiki.data('Q7');
 | 
						|
// search [ language, label ]
 | 
						|
//entity = await wiki.data(['en', 'Earth']);
 | 
						|
 | 
						|
// Reset claim
 | 
						|
entity = await wiki.data('Q1841');
 | 
						|
await entity.modify({ claims: [{ P3: "old.wav", remove: true }] }, { bot: 1, summary: 'test edit: Remove specific value' });
 | 
						|
// Warning: If you want to perform multiple operations on the same property, you need to get the entity again!
 | 
						|
entity = await wiki.data('Q1841');
 | 
						|
await entity.modify({ claims: [{ P3: "new.wav" }] }, { bot: 1, summary: 'test edit: Add value' });
 | 
						|
 | 
						|
// Update claim
 | 
						|
await entity.modify({ claims: [{ P17: 'Q213280' }] }, { bot: 1, summary: 'test edit: Update claim' });
 | 
						|
 | 
						|
// Update claim: set country (P17) to 'Test Country 1' (Q213280) ([language, label] as entity)
 | 
						|
await entity.modify({ claims: [{ language: 'en', country: [, 'Test Country 1'] }] }, { summary: '' });
 | 
						|
 | 
						|
// Remove country (P17) : 'Test Country 1' (Q213280)
 | 
						|
await entity.modify({ claims: [{ language: 'en', country: [, 'Test Country 1'], remove: true }] }, { summary: '' });
 | 
						|
 | 
						|
// Update label
 | 
						|
await entity.modify({ labels: [{ language: 'zh-tw', value: '地球' }] }, { summary: '' });
 | 
						|
// </code></code></pre>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
    <h5>Parameters:</h5>
 | 
						|
    
 | 
						|
 | 
						|
<table class="params">
 | 
						|
    <thead>
 | 
						|
    <tr>
 | 
						|
        
 | 
						|
        <th>Name</th>
 | 
						|
        
 | 
						|
 | 
						|
        <th>Type</th>
 | 
						|
 | 
						|
        
 | 
						|
        <th>Attributes</th>
 | 
						|
        
 | 
						|
 | 
						|
        
 | 
						|
 | 
						|
        <th class="last">Description</th>
 | 
						|
    </tr>
 | 
						|
    </thead>
 | 
						|
 | 
						|
    <tbody>
 | 
						|
    
 | 
						|
 | 
						|
        <tr>
 | 
						|
            
 | 
						|
                <td class="name"><code>data_entity</code></td>
 | 
						|
            
 | 
						|
 | 
						|
            <td class="type">
 | 
						|
            
 | 
						|
                
 | 
						|
<span class="param-type">Object</span>
 | 
						|
 | 
						|
 | 
						|
            
 | 
						|
            </td>
 | 
						|
 | 
						|
            
 | 
						|
                <td class="attributes">
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
                </td>
 | 
						|
            
 | 
						|
 | 
						|
            
 | 
						|
 | 
						|
            <td class="description last">wiki_API data entity</td>
 | 
						|
        </tr>
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
        <tr>
 | 
						|
            
 | 
						|
                <td class="name"><code>options</code></td>
 | 
						|
            
 | 
						|
 | 
						|
            <td class="type">
 | 
						|
            
 | 
						|
                
 | 
						|
<span class="param-type">Object</span>
 | 
						|
 | 
						|
 | 
						|
            
 | 
						|
            </td>
 | 
						|
 | 
						|
            
 | 
						|
                <td class="attributes">
 | 
						|
                
 | 
						|
                    <optional><br>
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
                </td>
 | 
						|
            
 | 
						|
 | 
						|
            
 | 
						|
 | 
						|
            <td class="description last">options to run this function</td>
 | 
						|
        </tr>
 | 
						|
 | 
						|
    
 | 
						|
    </tbody>
 | 
						|
</table>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<h5>Returns:</h5>
 | 
						|
 | 
						|
        
 | 
						|
<div class="param-desc">
 | 
						|
    Promise object represents {Object} wikidata entity / property
 | 
						|
</div>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<dl class="param-type">
 | 
						|
    <dt>
 | 
						|
        Type
 | 
						|
    </dt>
 | 
						|
    <dd>
 | 
						|
        
 | 
						|
<span class="param-type">Promise</span>
 | 
						|
 | 
						|
 | 
						|
    </dd>
 | 
						|
</dl>
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
 | 
						|
 | 
						|
        
 | 
						|
            
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    <h4 class="name" id="delete"><span class="type-signature"></span>delete<span class="signature">(title, options<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Promise}</span></h4>
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<dl class="details">
 | 
						|
 | 
						|
    
 | 
						|
    <dt class="tag-source">Source:</dt>
 | 
						|
    <dd class="tag-source"><ul class="dummy"><li>
 | 
						|
        <a href="wikiapi.js.html">wikiapi.js</a>, <a href="wikiapi.js.html#line1790">line 1790</a>
 | 
						|
    </li></ul></dd>
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
</dl>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<div class="description usertext">
 | 
						|
    delete page
 | 
						|
</div>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
    <h5>Example</h5>
 | 
						|
    
 | 
						|
        <p class="code-caption">delete page [[Page to delete]]</p>
 | 
						|
    
 | 
						|
    <pre class="prettyprint"><code>// <code>
 | 
						|
const testwiki = new Wikiapi('test');
 | 
						|
await testwiki.delete('Page to delete', { reason: 'test' });
 | 
						|
// { title: 'Aaaaaaa', reason: 'test', logid: 346223 }
 | 
						|
// </code></code></pre>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
    <h5>Parameters:</h5>
 | 
						|
    
 | 
						|
 | 
						|
<table class="params">
 | 
						|
    <thead>
 | 
						|
    <tr>
 | 
						|
        
 | 
						|
        <th>Name</th>
 | 
						|
        
 | 
						|
 | 
						|
        <th>Type</th>
 | 
						|
 | 
						|
        
 | 
						|
        <th>Attributes</th>
 | 
						|
        
 | 
						|
 | 
						|
        
 | 
						|
 | 
						|
        <th class="last">Description</th>
 | 
						|
    </tr>
 | 
						|
    </thead>
 | 
						|
 | 
						|
    <tbody>
 | 
						|
    
 | 
						|
 | 
						|
        <tr>
 | 
						|
            
 | 
						|
                <td class="name"><code>title</code></td>
 | 
						|
            
 | 
						|
 | 
						|
            <td class="type">
 | 
						|
            
 | 
						|
                
 | 
						|
<span class="param-type">String</span>
 | 
						|
 | 
						|
 | 
						|
            
 | 
						|
            </td>
 | 
						|
 | 
						|
            
 | 
						|
                <td class="attributes">
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
                </td>
 | 
						|
            
 | 
						|
 | 
						|
            
 | 
						|
 | 
						|
            <td class="description last">page title</td>
 | 
						|
        </tr>
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
        <tr>
 | 
						|
            
 | 
						|
                <td class="name"><code>options</code></td>
 | 
						|
            
 | 
						|
 | 
						|
            <td class="type">
 | 
						|
            
 | 
						|
                
 | 
						|
<span class="param-type">Object</span>
 | 
						|
 | 
						|
 | 
						|
            
 | 
						|
            </td>
 | 
						|
 | 
						|
            
 | 
						|
                <td class="attributes">
 | 
						|
                
 | 
						|
                    <optional><br>
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
                </td>
 | 
						|
            
 | 
						|
 | 
						|
            
 | 
						|
 | 
						|
            <td class="description last">options to run this function</td>
 | 
						|
        </tr>
 | 
						|
 | 
						|
    
 | 
						|
    </tbody>
 | 
						|
</table>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<h5>Returns:</h5>
 | 
						|
 | 
						|
        
 | 
						|
<div class="param-desc">
 | 
						|
    Promise object represents response of delete.
 | 
						|
</div>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<dl class="param-type">
 | 
						|
    <dt>
 | 
						|
        Type
 | 
						|
    </dt>
 | 
						|
    <dd>
 | 
						|
        
 | 
						|
<span class="param-type">Promise</span>
 | 
						|
 | 
						|
 | 
						|
    </dd>
 | 
						|
</dl>
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
 | 
						|
 | 
						|
        
 | 
						|
            
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    <h4 class="name" id="download"><span class="type-signature"></span>download<span class="signature">(file_title, options<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Promise}</span></h4>
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<dl class="details">
 | 
						|
 | 
						|
    
 | 
						|
    <dt class="tag-source">Source:</dt>
 | 
						|
    <dd class="tag-source"><ul class="dummy"><li>
 | 
						|
        <a href="wikiapi.js.html">wikiapi.js</a>, <a href="wikiapi.js.html#line1475">line 1475</a>
 | 
						|
    </li></ul></dd>
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
</dl>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<div class="description usertext">
 | 
						|
    Download file to local path.
 | 
						|
</div>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
    <h5>Examples</h5>
 | 
						|
    
 | 
						|
        <p class="code-caption">Download original file / media to current directory.</span></p>
 | 
						|
    
 | 
						|
    <pre class="prettyprint"><code>// <code>
 | 
						|
const wiki = new Wikiapi('commons');
 | 
						|
await wiki.download('File:Example.svg');
 | 
						|
// </code></code></pre>
 | 
						|
 | 
						|
        <p class="code-caption">Download file / media with options</span></p>
 | 
						|
    
 | 
						|
    <pre class="prettyprint"><code>// <code>
 | 
						|
const wiki = new Wikiapi('commons');
 | 
						|
 | 
						|
// Download non-vector version of .svg
 | 
						|
await wiki.download('File:Example.svg', { width: 80 });
 | 
						|
 | 
						|
// Change width / height
 | 
						|
await wiki.download('File:Example.png', {
 | 
						|
	file_name: 'example.png', directory: '/tmp/',
 | 
						|
	// reget and overwrite existed file.
 | 
						|
	reget: true,
 | 
						|
	width: 80,// height: 80
 | 
						|
});
 | 
						|
 | 
						|
// Download all files from a (Commons) category and its subcategories WITH directory structure.
 | 
						|
const file_data_list = await wiki.download('Category:name', {
 | 
						|
	directory: './',
 | 
						|
	max_threads: 4,
 | 
						|
	// depth of categories
 | 
						|
	depth: 4,
 | 
						|
	// Only download files with these formats.
 | 
						|
	//download_derivatives : ['wav', 'mp3', 'ogg'],
 | 
						|
	// Warning: Will skip downloading if there is no new file!
 | 
						|
	download_derivatives : 'mp3',
 | 
						|
	// A function to filter result pages. Return `true` if you want to keep the element.
 | 
						|
	page_filter(page_data) {
 | 
						|
		return page_data.title.includes('word');
 | 
						|
	}
 | 
						|
});
 | 
						|
 | 
						|
// Download all files from a (Commons) category WITHOUT directory structure.
 | 
						|
for (const page_data of await wiki.categorymembers('Category:name', { namespace: 'File' })) {
 | 
						|
	try {
 | 
						|
		//if (wiki.is_namespace(page_data, 'File'))
 | 
						|
		const file_data = await wiki.download(page_data, { directory: './' });
 | 
						|
	} catch (e) { console.error(e); }
 | 
						|
}
 | 
						|
// also
 | 
						|
const categorymembers = await wiki.categorymembers('Category:name', { namespace: 'File' });
 | 
						|
const file_data_list = await wiki.download(categorymembers, { directory: './', no_category_tree: true });
 | 
						|
// </code></code></pre>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
    <h5>Parameters:</h5>
 | 
						|
    
 | 
						|
 | 
						|
<table class="params">
 | 
						|
    <thead>
 | 
						|
    <tr>
 | 
						|
        
 | 
						|
        <th>Name</th>
 | 
						|
        
 | 
						|
 | 
						|
        <th>Type</th>
 | 
						|
 | 
						|
        
 | 
						|
        <th>Attributes</th>
 | 
						|
        
 | 
						|
 | 
						|
        
 | 
						|
 | 
						|
        <th class="last">Description</th>
 | 
						|
    </tr>
 | 
						|
    </thead>
 | 
						|
 | 
						|
    <tbody>
 | 
						|
    
 | 
						|
 | 
						|
        <tr>
 | 
						|
            
 | 
						|
                <td class="name"><code>file_title</code></td>
 | 
						|
            
 | 
						|
 | 
						|
            <td class="type">
 | 
						|
            
 | 
						|
                
 | 
						|
<span class="param-type">String</span>
 | 
						|
 | 
						|
 | 
						|
            
 | 
						|
            </td>
 | 
						|
 | 
						|
            
 | 
						|
                <td class="attributes">
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
                </td>
 | 
						|
            
 | 
						|
 | 
						|
            
 | 
						|
 | 
						|
            <td class="description last">file title starts with "File:"</td>
 | 
						|
        </tr>
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
        <tr>
 | 
						|
            
 | 
						|
                <td class="name"><code>options</code></td>
 | 
						|
            
 | 
						|
 | 
						|
            <td class="type">
 | 
						|
            
 | 
						|
                
 | 
						|
<span class="param-type">Object</span>
 | 
						|
 | 
						|
 | 
						|
            
 | 
						|
            </td>
 | 
						|
 | 
						|
            
 | 
						|
                <td class="attributes">
 | 
						|
                
 | 
						|
                    <optional><br>
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
                </td>
 | 
						|
            
 | 
						|
 | 
						|
            
 | 
						|
 | 
						|
            <td class="description last">options to run this function. Refer to example codes.</td>
 | 
						|
        </tr>
 | 
						|
 | 
						|
    
 | 
						|
    </tbody>
 | 
						|
</table>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<h5>Returns:</h5>
 | 
						|
 | 
						|
        
 | 
						|
<div class="param-desc">
 | 
						|
    Promise object represents [ {Object}file informations ]
 | 
						|
</div>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<dl class="param-type">
 | 
						|
    <dt>
 | 
						|
        Type
 | 
						|
    </dt>
 | 
						|
    <dd>
 | 
						|
        
 | 
						|
<span class="param-type">Promise</span>
 | 
						|
 | 
						|
 | 
						|
    </dd>
 | 
						|
</dl>
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
 | 
						|
 | 
						|
        
 | 
						|
            
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    <h4 class="name" id="edit"><span class="type-signature"></span>edit<span class="signature">(content, options<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Promise}</span></h4>
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<dl class="details">
 | 
						|
 | 
						|
    
 | 
						|
    <dt class="tag-source">Source:</dt>
 | 
						|
    <dd class="tag-source"><ul class="dummy"><li>
 | 
						|
        <a href="wikiapi.js.html">wikiapi.js</a>, <a href="wikiapi.js.html#line1838">line 1838</a>
 | 
						|
    </li></ul></dd>
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
</dl>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<div class="description usertext">
 | 
						|
    edits content of target page.<br />
 | 
						|
<em>MUST using after <a href="Wikiapi.html#page">Wikiapi#page</a>!</em><br />
 | 
						|
Note: for multiple pages, you should use <a href="Wikiapi.html#for_each_page">Wikiapi#for_each_page</a>.<br />
 | 
						|
Note: The function will check sections of [[User talk:user name/Stop]] if somebody tells us needed to stop edit. See <a href="https://zh.wikipedia.org/wiki/User:Cewbot/Stop">mechanism to stop operations</a>.
 | 
						|
</div>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
    <h5>Parameters:</h5>
 | 
						|
    
 | 
						|
 | 
						|
<table class="params">
 | 
						|
    <thead>
 | 
						|
    <tr>
 | 
						|
        
 | 
						|
        <th>Name</th>
 | 
						|
        
 | 
						|
 | 
						|
        <th>Type</th>
 | 
						|
 | 
						|
        
 | 
						|
        <th>Attributes</th>
 | 
						|
        
 | 
						|
 | 
						|
        
 | 
						|
 | 
						|
        <th class="last">Description</th>
 | 
						|
    </tr>
 | 
						|
    </thead>
 | 
						|
 | 
						|
    <tbody>
 | 
						|
    
 | 
						|
 | 
						|
        <tr>
 | 
						|
            
 | 
						|
                <td class="name"><code>content</code></td>
 | 
						|
            
 | 
						|
 | 
						|
            <td class="type">
 | 
						|
            
 | 
						|
                
 | 
						|
<span class="param-type">String</span>
 | 
						|
|
 | 
						|
 | 
						|
<span class="param-type">function</span>
 | 
						|
 | 
						|
 | 
						|
            
 | 
						|
            </td>
 | 
						|
 | 
						|
            
 | 
						|
                <td class="attributes">
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
                </td>
 | 
						|
            
 | 
						|
 | 
						|
            
 | 
						|
 | 
						|
            <td class="description last">'wikitext page content' || page_data => 'wikitext'</td>
 | 
						|
        </tr>
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
        <tr>
 | 
						|
            
 | 
						|
                <td class="name"><code>options</code></td>
 | 
						|
            
 | 
						|
 | 
						|
            <td class="type">
 | 
						|
            
 | 
						|
                
 | 
						|
<span class="param-type">Object</span>
 | 
						|
 | 
						|
 | 
						|
            
 | 
						|
            </td>
 | 
						|
 | 
						|
            
 | 
						|
                <td class="attributes">
 | 
						|
                
 | 
						|
                    <optional><br>
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
                </td>
 | 
						|
            
 | 
						|
 | 
						|
            
 | 
						|
 | 
						|
            <td class="description last">options to run this function. e.g., { summary: '', bot: 1, nocreate: 1, minor: 1 }</td>
 | 
						|
        </tr>
 | 
						|
 | 
						|
    
 | 
						|
    </tbody>
 | 
						|
</table>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<h5>Returns:</h5>
 | 
						|
 | 
						|
        
 | 
						|
<div class="param-desc">
 | 
						|
    Promise object represents {Object} result of MediaWiki API
 | 
						|
</div>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<dl class="param-type">
 | 
						|
    <dt>
 | 
						|
        Type
 | 
						|
    </dt>
 | 
						|
    <dd>
 | 
						|
        
 | 
						|
<span class="param-type">Promise</span>
 | 
						|
 | 
						|
 | 
						|
    </dd>
 | 
						|
</dl>
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
 | 
						|
 | 
						|
        
 | 
						|
            
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    <h4 class="name" id="edit_page"><span class="type-signature"></span>edit_page<span class="signature">(title, content, options<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Promise}</span></h4>
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<dl class="details">
 | 
						|
 | 
						|
    
 | 
						|
    <dt class="tag-source">Source:</dt>
 | 
						|
    <dd class="tag-source"><ul class="dummy"><li>
 | 
						|
        <a href="wikiapi.js.html">wikiapi.js</a>, <a href="wikiapi.js.html#line465">line 465</a>
 | 
						|
    </li></ul></dd>
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
</dl>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<div class="description usertext">
 | 
						|
    edits content of target page.<br />
 | 
						|
Note: for multiple pages, you should use <a href="Wikiapi.html#for_each_page">Wikiapi#for_each_page</a>.<br />
 | 
						|
Note: The function will check sections of [[User talk:user name/Stop]] if somebody tells us needed to stop edit. See <a href="https://zh.wikipedia.org/wiki/User:Cewbot/Stop">mechanism to stop operations</a>.
 | 
						|
</div>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
    <h5>Examples</h5>
 | 
						|
    
 | 
						|
        <p class="code-caption">edit page: method 1: basic operation</p>
 | 
						|
    
 | 
						|
    <pre class="prettyprint"><code>// <code>
 | 
						|
const enwiki = new Wikiapi;
 | 
						|
await enwiki.login('bot name', 'password', 'en');
 | 
						|
 | 
						|
const SB_page_data = await enwiki.page('Wikipedia:Sandbox');
 | 
						|
// You may do some operations on SB_page_data
 | 
						|
const parsed = SB_page_data.parse();
 | 
						|
parsed.each('template', template_token => {
 | 
						|
	// modify template token
 | 
						|
});
 | 
						|
// and then edit it. ** You MUST call enwiki.page() before enwiki.edit()! **
 | 
						|
await enwiki.edit(parsed.toString(), { bot: 1, minor: 1, nocreate: 1 });
 | 
						|
 | 
						|
// exmaple 2: append text in the tail of page content
 | 
						|
await enwiki.edit(page_data => {
 | 
						|
	return page_data.wikitext
 | 
						|
		+ '\nTest edit using {{GitHub|kanasimi/wikiapi}}.';
 | 
						|
}, { bot: 1 });
 | 
						|
 | 
						|
// exmaple 3: replace page content
 | 
						|
await enwiki.edit('Just replace by this wikitext', { bot: 1, minor: 1, nocreate: 1, summary: 'test edit' });
 | 
						|
 | 
						|
// exmaple 4: append a new section
 | 
						|
await enwiki.edit('section content', {
 | 
						|
	section: 'new',
 | 
						|
	sectiontitle: 'section title',
 | 
						|
	nocreate : 1,
 | 
						|
	summary: 'test edit',
 | 
						|
});
 | 
						|
// </code></code></pre>
 | 
						|
 | 
						|
        <p class="code-caption">edit page: method 2: modufy summary inside function</p>
 | 
						|
    
 | 
						|
    <pre class="prettyprint"><code>// <code>
 | 
						|
const enwiki = new Wikiapi;
 | 
						|
await enwiki.login('bot name', 'password', 'en');
 | 
						|
await enwiki.edit_page('Wikipedia:Sandbox', function (page_data) {
 | 
						|
	this.summary += ': You may set additional summary inside the function';
 | 
						|
	delete this.minor;
 | 
						|
	return page_data.wikitext
 | 
						|
		+ '\nTest edit using {{GitHub|kanasimi/wikiapi}}.';
 | 
						|
}, { bot: 1, nocreate: 1, minor: 1, redirects: 1, summary: 'test edit' });
 | 
						|
// </code></code></pre>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
    <h5>Parameters:</h5>
 | 
						|
    
 | 
						|
 | 
						|
<table class="params">
 | 
						|
    <thead>
 | 
						|
    <tr>
 | 
						|
        
 | 
						|
        <th>Name</th>
 | 
						|
        
 | 
						|
 | 
						|
        <th>Type</th>
 | 
						|
 | 
						|
        
 | 
						|
        <th>Attributes</th>
 | 
						|
        
 | 
						|
 | 
						|
        
 | 
						|
 | 
						|
        <th class="last">Description</th>
 | 
						|
    </tr>
 | 
						|
    </thead>
 | 
						|
 | 
						|
    <tbody>
 | 
						|
    
 | 
						|
 | 
						|
        <tr>
 | 
						|
            
 | 
						|
                <td class="name"><code>title</code></td>
 | 
						|
            
 | 
						|
 | 
						|
            <td class="type">
 | 
						|
            
 | 
						|
                
 | 
						|
<span class="param-type">String</span>
 | 
						|
 | 
						|
 | 
						|
            
 | 
						|
            </td>
 | 
						|
 | 
						|
            
 | 
						|
                <td class="attributes">
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
                </td>
 | 
						|
            
 | 
						|
 | 
						|
            
 | 
						|
 | 
						|
            <td class="description last">page title</td>
 | 
						|
        </tr>
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
        <tr>
 | 
						|
            
 | 
						|
                <td class="name"><code>content</code></td>
 | 
						|
            
 | 
						|
 | 
						|
            <td class="type">
 | 
						|
            
 | 
						|
                
 | 
						|
<span class="param-type">String</span>
 | 
						|
|
 | 
						|
 | 
						|
<span class="param-type">function</span>
 | 
						|
 | 
						|
 | 
						|
            
 | 
						|
            </td>
 | 
						|
 | 
						|
            
 | 
						|
                <td class="attributes">
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
                </td>
 | 
						|
            
 | 
						|
 | 
						|
            
 | 
						|
 | 
						|
            <td class="description last">'wikitext page content' || page_data => 'wikitext'</td>
 | 
						|
        </tr>
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
        <tr>
 | 
						|
            
 | 
						|
                <td class="name"><code>options</code></td>
 | 
						|
            
 | 
						|
 | 
						|
            <td class="type">
 | 
						|
            
 | 
						|
                
 | 
						|
<span class="param-type">Object</span>
 | 
						|
 | 
						|
 | 
						|
            
 | 
						|
            </td>
 | 
						|
 | 
						|
            
 | 
						|
                <td class="attributes">
 | 
						|
                
 | 
						|
                    <optional><br>
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
                </td>
 | 
						|
            
 | 
						|
 | 
						|
            
 | 
						|
 | 
						|
            <td class="description last">options to run this function. e.g., { summary: '', bot: 1, nocreate: 1, minor: 1 }</td>
 | 
						|
        </tr>
 | 
						|
 | 
						|
    
 | 
						|
    </tbody>
 | 
						|
</table>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<h5>Returns:</h5>
 | 
						|
 | 
						|
        
 | 
						|
<div class="param-desc">
 | 
						|
    Promise object represents {Object} result of MediaWiki API
 | 
						|
</div>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<dl class="param-type">
 | 
						|
    <dt>
 | 
						|
        Type
 | 
						|
    </dt>
 | 
						|
    <dd>
 | 
						|
        
 | 
						|
<span class="param-type">Promise</span>
 | 
						|
 | 
						|
 | 
						|
    </dd>
 | 
						|
</dl>
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
 | 
						|
 | 
						|
        
 | 
						|
            
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    <h4 class="name" id="for_each_page"><span class="type-signature"></span>for_each_page<span class="signature">(page_list, for_each_page, options<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Promise}</span></h4>
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<dl class="details">
 | 
						|
 | 
						|
    
 | 
						|
    <dt class="tag-source">Source:</dt>
 | 
						|
    <dd class="tag-source"><ul class="dummy"><li>
 | 
						|
        <a href="wikiapi.js.html">wikiapi.js</a>, <a href="wikiapi.js.html#line1544">line 1544</a>
 | 
						|
    </li></ul></dd>
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
</dl>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<div class="description usertext">
 | 
						|
    Edit / process pages listing in <code>page_list</code>. Will get the content of multiple pages at once to save transmission times. 一次取得多個頁面內容,以節省傳輸次數。
 | 
						|
</div>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
    <h5>Example</h5>
 | 
						|
    
 | 
						|
        <p class="code-caption">read / edit multiple pages</p>
 | 
						|
    
 | 
						|
    <pre class="prettyprint"><code>// <code>
 | 
						|
const enwiki = new Wikiapi('en');
 | 
						|
const link_from = await wiki.redirects_here('ABC');
 | 
						|
await wiki.for_each_page(link_from, page_data => {
 | 
						|
	// Return `Wikiapi.skip_edit` if you just want to get the page data.
 | 
						|
	return Wikiapi.skip_edit;
 | 
						|
	return 'You may also modify page contents for each page';
 | 
						|
}, {
 | 
						|
	// The options below are sample, not default configuration.
 | 
						|
 | 
						|
	// denotes we do not edit pages
 | 
						|
	no_edit: true,
 | 
						|
 | 
						|
	// Only needed if you want to modify page.
 | 
						|
	summary: 'test edit',
 | 
						|
	// Allow content to be emptied. 允許內容被清空。白紙化。
 | 
						|
	allow_empty: true,
 | 
						|
	tags: 'bot trial',
 | 
						|
	// prevent creating new pages
 | 
						|
	// Throw an error if the page doesn't exist.
 | 
						|
	// 若頁面不存在/已刪除,則產生錯誤。
 | 
						|
	nocreate: 1,
 | 
						|
	// denotes this is a bot edit. 標記此編輯為機器人編輯。
 | 
						|
	bot: 1,
 | 
						|
	minor: 1,
 | 
						|
 | 
						|
	// options to get page revisions
 | 
						|
	page_options: { redirects: 1, rvprop: 'ids|content|timestamp|user' }
 | 
						|
 | 
						|
	// <code>.for_each_page()</code> will generate a report. It can be written to the specified page.
 | 
						|
	log_to: 'log to this page',
 | 
						|
	// no warning messages on console. e.g., hide "wiki_API_page: No contents: [[title]]" messages
 | 
						|
	no_warning: true,
 | 
						|
	// no warning messages and debug messages on console
 | 
						|
	no_message: true,
 | 
						|
});
 | 
						|
// </code></code></pre>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
    <h5>Parameters:</h5>
 | 
						|
    
 | 
						|
 | 
						|
<table class="params">
 | 
						|
    <thead>
 | 
						|
    <tr>
 | 
						|
        
 | 
						|
        <th>Name</th>
 | 
						|
        
 | 
						|
 | 
						|
        <th>Type</th>
 | 
						|
 | 
						|
        
 | 
						|
        <th>Attributes</th>
 | 
						|
        
 | 
						|
 | 
						|
        
 | 
						|
 | 
						|
        <th class="last">Description</th>
 | 
						|
    </tr>
 | 
						|
    </thead>
 | 
						|
 | 
						|
    <tbody>
 | 
						|
    
 | 
						|
 | 
						|
        <tr>
 | 
						|
            
 | 
						|
                <td class="name"><code>page_list</code></td>
 | 
						|
            
 | 
						|
 | 
						|
            <td class="type">
 | 
						|
            
 | 
						|
                
 | 
						|
<span class="param-type">Array</span>
 | 
						|
 | 
						|
 | 
						|
            
 | 
						|
            </td>
 | 
						|
 | 
						|
            
 | 
						|
                <td class="attributes">
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
                </td>
 | 
						|
            
 | 
						|
 | 
						|
            
 | 
						|
 | 
						|
            <td class="description last">title list or page_data list</td>
 | 
						|
        </tr>
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
        <tr>
 | 
						|
            
 | 
						|
                <td class="name"><code>for_each_page</code></td>
 | 
						|
            
 | 
						|
 | 
						|
            <td class="type">
 | 
						|
            
 | 
						|
                
 | 
						|
<span class="param-type">function</span>
 | 
						|
 | 
						|
 | 
						|
            
 | 
						|
            </td>
 | 
						|
 | 
						|
            
 | 
						|
                <td class="attributes">
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
                </td>
 | 
						|
            
 | 
						|
 | 
						|
            
 | 
						|
 | 
						|
            <td class="description last">processor for each page. for_each_page(page_data with contents)</td>
 | 
						|
        </tr>
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
        <tr>
 | 
						|
            
 | 
						|
                <td class="name"><code>options</code></td>
 | 
						|
            
 | 
						|
 | 
						|
            <td class="type">
 | 
						|
            
 | 
						|
                
 | 
						|
<span class="param-type">Object</span>
 | 
						|
 | 
						|
 | 
						|
            
 | 
						|
            </td>
 | 
						|
 | 
						|
            
 | 
						|
                <td class="attributes">
 | 
						|
                
 | 
						|
                    <optional><br>
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
                </td>
 | 
						|
            
 | 
						|
 | 
						|
            
 | 
						|
 | 
						|
            <td class="description last">options to run this function. Refer to example codes.</td>
 | 
						|
        </tr>
 | 
						|
 | 
						|
    
 | 
						|
    </tbody>
 | 
						|
</table>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<h5>Returns:</h5>
 | 
						|
 | 
						|
        
 | 
						|
<div class="param-desc">
 | 
						|
    Promise object represents the operations are done.
 | 
						|
</div>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<dl class="param-type">
 | 
						|
    <dt>
 | 
						|
        Type
 | 
						|
    </dt>
 | 
						|
    <dd>
 | 
						|
        
 | 
						|
<span class="param-type">Promise</span>
 | 
						|
 | 
						|
 | 
						|
    </dd>
 | 
						|
</dl>
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
 | 
						|
 | 
						|
        
 | 
						|
            
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    <h4 class="name" id="get_featured_content"><span class="type-signature"></span>get_featured_content<span class="signature">(options<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Promise}</span></h4>
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<dl class="details">
 | 
						|
 | 
						|
    
 | 
						|
    <dt class="tag-source">Source:</dt>
 | 
						|
    <dd class="tag-source"><ul class="dummy"><li>
 | 
						|
        <a href="wikiapi.js.html">wikiapi.js</a>, <a href="wikiapi.js.html#line1709">line 1709</a>
 | 
						|
    </li></ul></dd>
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
</dl>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<div class="description usertext">
 | 
						|
    Get featured content.
 | 
						|
</div>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
    <h5>Example</h5>
 | 
						|
    
 | 
						|
        <p class="code-caption">Get featured content of current wiki site.</p>
 | 
						|
    
 | 
						|
    <pre class="prettyprint"><code>// <code>
 | 
						|
// MUST including wiki.featured_content first to get featured content!
 | 
						|
CeL.run('application.net.wiki.featured_content');
 | 
						|
 | 
						|
// ...
 | 
						|
 | 
						|
const FC_data_hash = await wiki.get_featured_content();
 | 
						|
console.assert(FC_data_hash === wiki.FC_data_hash);
 | 
						|
// </code></code></pre>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
    <h5>Parameters:</h5>
 | 
						|
    
 | 
						|
 | 
						|
<table class="params">
 | 
						|
    <thead>
 | 
						|
    <tr>
 | 
						|
        
 | 
						|
        <th>Name</th>
 | 
						|
        
 | 
						|
 | 
						|
        <th>Type</th>
 | 
						|
 | 
						|
        
 | 
						|
        <th>Attributes</th>
 | 
						|
        
 | 
						|
 | 
						|
        
 | 
						|
 | 
						|
        <th class="last">Description</th>
 | 
						|
    </tr>
 | 
						|
    </thead>
 | 
						|
 | 
						|
    <tbody>
 | 
						|
    
 | 
						|
 | 
						|
        <tr>
 | 
						|
            
 | 
						|
                <td class="name"><code>options</code></td>
 | 
						|
            
 | 
						|
 | 
						|
            <td class="type">
 | 
						|
            
 | 
						|
                
 | 
						|
<span class="param-type">String</span>
 | 
						|
|
 | 
						|
 | 
						|
<span class="param-type">Object</span>
 | 
						|
 | 
						|
 | 
						|
            
 | 
						|
            </td>
 | 
						|
 | 
						|
            
 | 
						|
                <td class="attributes">
 | 
						|
                
 | 
						|
                    <optional><br>
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
                </td>
 | 
						|
            
 | 
						|
 | 
						|
            
 | 
						|
 | 
						|
            <td class="description last">options to run this function.
 | 
						|
           {String}type (FFA|GA|FA|FL)
 | 
						|
           || {type,on_conflict(FC_title, {from,to})}</td>
 | 
						|
        </tr>
 | 
						|
 | 
						|
    
 | 
						|
    </tbody>
 | 
						|
</table>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<h5>Returns:</h5>
 | 
						|
 | 
						|
        
 | 
						|
<div class="param-desc">
 | 
						|
    Promise object represents {Object} featured content data hash
 | 
						|
</div>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<dl class="param-type">
 | 
						|
    <dt>
 | 
						|
        Type
 | 
						|
    </dt>
 | 
						|
    <dd>
 | 
						|
        
 | 
						|
<span class="param-type">Promise</span>
 | 
						|
 | 
						|
 | 
						|
    </dd>
 | 
						|
</dl>
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
 | 
						|
 | 
						|
        
 | 
						|
            
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    <h4 class="name" id="listen"><span class="type-signature"></span>listen<span class="signature">(listener, options<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span></h4>
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<dl class="details">
 | 
						|
 | 
						|
    
 | 
						|
    <dt class="tag-source">Source:</dt>
 | 
						|
    <dd class="tag-source"><ul class="dummy"><li>
 | 
						|
        <a href="wikiapi.js.html">wikiapi.js</a>, <a href="wikiapi.js.html#line1871">line 1871</a>
 | 
						|
    </li></ul></dd>
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
</dl>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<div class="description usertext">
 | 
						|
    Listen to page modification. 監視最近更改的頁面。<br />
 | 
						|
wrapper for <a href="global.html#wiki_API">wiki_API</a>#listen
 | 
						|
</div>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
    <h5>Example</h5>
 | 
						|
    
 | 
						|
        <p class="code-caption">listen to new edits</p>
 | 
						|
    
 | 
						|
    <pre class="prettyprint"><code>// <code>
 | 
						|
const wiki = new Wikiapi;
 | 
						|
wiki.listen(function for_each_row() {
 | 
						|
	// ...
 | 
						|
}, {
 | 
						|
	// 檢查的延遲時間。
 | 
						|
	delay: '2m',
 | 
						|
	filter: function filter_row(row) {
 | 
						|
		// row is the same format as page_data
 | 
						|
	},
 | 
						|
	// also get diff
 | 
						|
	with_diff: { LCS: true, line: true },
 | 
						|
	// only for articles (0:main namespace) and talk pages
 | 
						|
	namespace: '0|talk',
 | 
						|
});
 | 
						|
// </code></code></pre>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
    <h5>Parameters:</h5>
 | 
						|
    
 | 
						|
 | 
						|
<table class="params">
 | 
						|
    <thead>
 | 
						|
    <tr>
 | 
						|
        
 | 
						|
        <th>Name</th>
 | 
						|
        
 | 
						|
 | 
						|
        <th>Type</th>
 | 
						|
 | 
						|
        
 | 
						|
        <th>Attributes</th>
 | 
						|
        
 | 
						|
 | 
						|
        
 | 
						|
 | 
						|
        <th class="last">Description</th>
 | 
						|
    </tr>
 | 
						|
    </thead>
 | 
						|
 | 
						|
    <tbody>
 | 
						|
    
 | 
						|
 | 
						|
        <tr>
 | 
						|
            
 | 
						|
                <td class="name"><code>listener</code></td>
 | 
						|
            
 | 
						|
 | 
						|
            <td class="type">
 | 
						|
            
 | 
						|
                
 | 
						|
<span class="param-type">function</span>
 | 
						|
 | 
						|
 | 
						|
            
 | 
						|
            </td>
 | 
						|
 | 
						|
            
 | 
						|
                <td class="attributes">
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
                </td>
 | 
						|
            
 | 
						|
 | 
						|
            
 | 
						|
 | 
						|
            <td class="description last">function(page_data) { return quit_listening; }</td>
 | 
						|
        </tr>
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
        <tr>
 | 
						|
            
 | 
						|
                <td class="name"><code>options</code></td>
 | 
						|
            
 | 
						|
 | 
						|
            <td class="type">
 | 
						|
            
 | 
						|
                
 | 
						|
<span class="param-type">Object</span>
 | 
						|
 | 
						|
 | 
						|
            
 | 
						|
            </td>
 | 
						|
 | 
						|
            
 | 
						|
                <td class="attributes">
 | 
						|
                
 | 
						|
                    <optional><br>
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
                </td>
 | 
						|
            
 | 
						|
 | 
						|
            
 | 
						|
 | 
						|
            <td class="description last">options to run this function. e.g., { summary: '', bot: 1, nocreate: 1, minor: 1 }</td>
 | 
						|
        </tr>
 | 
						|
 | 
						|
    
 | 
						|
    </tbody>
 | 
						|
</table>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
        
 | 
						|
            
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    <h4 class="name" id="login"><span class="type-signature"></span>login<span class="signature">(user_name, password, API_URL<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Promise}</span></h4>
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<dl class="details">
 | 
						|
 | 
						|
    
 | 
						|
    <dt class="tag-source">Source:</dt>
 | 
						|
    <dd class="tag-source"><ul class="dummy"><li>
 | 
						|
        <a href="wikiapi.js.html">wikiapi.js</a>, <a href="wikiapi.js.html#line146">line 146</a>
 | 
						|
    </li></ul></dd>
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
</dl>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<div class="description usertext">
 | 
						|
    login into the target MediaWiki API using the provided username and password.
 | 
						|
For bots, see [[Special:BotPasswords]] on your wiki.
 | 
						|
</div>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
    <h5>Examples</h5>
 | 
						|
    
 | 
						|
        <p class="code-caption"><span id="example__Login to wiki site 1">Login to wiki site method 1.</span></p>
 | 
						|
    
 | 
						|
    <pre class="prettyprint"><code>// <code>
 | 
						|
const wiki = new Wikiapi;
 | 
						|
const login_options = {
 | 
						|
	user_name: '', password: '', API_URL: 'en',
 | 
						|
	// Ror lingualibre only. @see https://github.com/kanasimi/wikibot/blob/master/wiki%20configuration.sample.js
 | 
						|
	//data_API_URL: 'https://lingualibre.org/api.php',
 | 
						|
	//SPARQL_API_URL: 'https://lingualibre.org/bigdata/namespace/wdq/sparql',
 | 
						|
	// Calling in another domain
 | 
						|
	origin: '*'
 | 
						|
};
 | 
						|
await wiki.login(login_options);
 | 
						|
// </code></code></pre>
 | 
						|
 | 
						|
        <p class="code-caption"><span id="example__Login to wiki site 2">Login to wiki site method 2.</span></p>
 | 
						|
    
 | 
						|
    <pre class="prettyprint"><code>// <code>
 | 
						|
const wiki = new Wikiapi;
 | 
						|
await wiki.login('user_name', 'password', 'en');
 | 
						|
// </code></code></pre>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
    <h5>Parameters:</h5>
 | 
						|
    
 | 
						|
 | 
						|
<table class="params">
 | 
						|
    <thead>
 | 
						|
    <tr>
 | 
						|
        
 | 
						|
        <th>Name</th>
 | 
						|
        
 | 
						|
 | 
						|
        <th>Type</th>
 | 
						|
 | 
						|
        
 | 
						|
        <th>Attributes</th>
 | 
						|
        
 | 
						|
 | 
						|
        
 | 
						|
 | 
						|
        <th class="last">Description</th>
 | 
						|
    </tr>
 | 
						|
    </thead>
 | 
						|
 | 
						|
    <tbody>
 | 
						|
    
 | 
						|
 | 
						|
        <tr>
 | 
						|
            
 | 
						|
                <td class="name"><code>user_name</code></td>
 | 
						|
            
 | 
						|
 | 
						|
            <td class="type">
 | 
						|
            
 | 
						|
                
 | 
						|
<span class="param-type">String</span>
 | 
						|
 | 
						|
 | 
						|
            
 | 
						|
            </td>
 | 
						|
 | 
						|
            
 | 
						|
                <td class="attributes">
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
                </td>
 | 
						|
            
 | 
						|
 | 
						|
            
 | 
						|
 | 
						|
            <td class="description last">Account username.</td>
 | 
						|
        </tr>
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
        <tr>
 | 
						|
            
 | 
						|
                <td class="name"><code>password</code></td>
 | 
						|
            
 | 
						|
 | 
						|
            <td class="type">
 | 
						|
            
 | 
						|
                
 | 
						|
<span class="param-type">String</span>
 | 
						|
 | 
						|
 | 
						|
            
 | 
						|
            </td>
 | 
						|
 | 
						|
            
 | 
						|
                <td class="attributes">
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
                </td>
 | 
						|
            
 | 
						|
 | 
						|
            
 | 
						|
 | 
						|
            <td class="description last">Account's password.</td>
 | 
						|
        </tr>
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
        <tr>
 | 
						|
            
 | 
						|
                <td class="name"><code>API_URL</code></td>
 | 
						|
            
 | 
						|
 | 
						|
            <td class="type">
 | 
						|
            
 | 
						|
                
 | 
						|
<span class="param-type">String</span>
 | 
						|
 | 
						|
 | 
						|
            
 | 
						|
            </td>
 | 
						|
 | 
						|
            
 | 
						|
                <td class="attributes">
 | 
						|
                
 | 
						|
                    <optional><br>
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
                </td>
 | 
						|
            
 | 
						|
 | 
						|
            
 | 
						|
 | 
						|
            <td class="description last">API URL of target wiki site.</td>
 | 
						|
        </tr>
 | 
						|
 | 
						|
    
 | 
						|
    </tbody>
 | 
						|
</table>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<h5>Returns:</h5>
 | 
						|
 | 
						|
        
 | 
						|
<div class="param-desc">
 | 
						|
    Promise object represents {String} login_name
 | 
						|
</div>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<dl class="param-type">
 | 
						|
    <dt>
 | 
						|
        Type
 | 
						|
    </dt>
 | 
						|
    <dd>
 | 
						|
        
 | 
						|
<span class="param-type">Promise</span>
 | 
						|
 | 
						|
 | 
						|
    </dd>
 | 
						|
</dl>
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
 | 
						|
 | 
						|
        
 | 
						|
            
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    <h4 class="name" id="move_page"><span class="type-signature"></span>move_page<span class="signature">(move_from_title, move_to_title, options<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Promise}</span></h4>
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<dl class="details">
 | 
						|
 | 
						|
    
 | 
						|
    <dt class="tag-source">Source:</dt>
 | 
						|
    <dd class="tag-source"><ul class="dummy"><li>
 | 
						|
        <a href="wikiapi.js.html">wikiapi.js</a>, <a href="wikiapi.js.html#line546">line 546</a>
 | 
						|
    </li></ul></dd>
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
</dl>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<div class="description usertext">
 | 
						|
    Move page <code>move_from_title</code> to <code>move_to_title</code>.
 | 
						|
</div>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
    <h5>Example</h5>
 | 
						|
    
 | 
						|
        <p class="code-caption">Move <code>move_from_title</code> to <code>move_to_title</code>.</p>
 | 
						|
    
 | 
						|
    <pre class="prettyprint"><code>// <code>
 | 
						|
await wiki.move_page(move_from_title, move_to_title, { reason, noredirect: true, movetalk: true });
 | 
						|
// </code></code></pre>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
    <h5>Parameters:</h5>
 | 
						|
    
 | 
						|
 | 
						|
<table class="params">
 | 
						|
    <thead>
 | 
						|
    <tr>
 | 
						|
        
 | 
						|
        <th>Name</th>
 | 
						|
        
 | 
						|
 | 
						|
        <th>Type</th>
 | 
						|
 | 
						|
        
 | 
						|
        <th>Attributes</th>
 | 
						|
        
 | 
						|
 | 
						|
        
 | 
						|
 | 
						|
        <th class="last">Description</th>
 | 
						|
    </tr>
 | 
						|
    </thead>
 | 
						|
 | 
						|
    <tbody>
 | 
						|
    
 | 
						|
 | 
						|
        <tr>
 | 
						|
            
 | 
						|
                <td class="name"><code>move_from_title</code></td>
 | 
						|
            
 | 
						|
 | 
						|
            <td class="type">
 | 
						|
            
 | 
						|
                
 | 
						|
<span class="param-type">Object</span>
 | 
						|
|
 | 
						|
 | 
						|
<span class="param-type">String</span>
 | 
						|
 | 
						|
 | 
						|
            
 | 
						|
            </td>
 | 
						|
 | 
						|
            
 | 
						|
                <td class="attributes">
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
                </td>
 | 
						|
            
 | 
						|
 | 
						|
            
 | 
						|
 | 
						|
            <td class="description last">move from title</td>
 | 
						|
        </tr>
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
        <tr>
 | 
						|
            
 | 
						|
                <td class="name"><code>move_to_title</code></td>
 | 
						|
            
 | 
						|
 | 
						|
            <td class="type">
 | 
						|
            
 | 
						|
                
 | 
						|
<span class="param-type">Object</span>
 | 
						|
|
 | 
						|
 | 
						|
<span class="param-type">String</span>
 | 
						|
 | 
						|
 | 
						|
            
 | 
						|
            </td>
 | 
						|
 | 
						|
            
 | 
						|
                <td class="attributes">
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
                </td>
 | 
						|
            
 | 
						|
 | 
						|
            
 | 
						|
 | 
						|
            <td class="description last">move to title</td>
 | 
						|
        </tr>
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
        <tr>
 | 
						|
            
 | 
						|
                <td class="name"><code>options</code></td>
 | 
						|
            
 | 
						|
 | 
						|
            <td class="type">
 | 
						|
            
 | 
						|
                
 | 
						|
<span class="param-type">Object</span>
 | 
						|
 | 
						|
 | 
						|
            
 | 
						|
            </td>
 | 
						|
 | 
						|
            
 | 
						|
                <td class="attributes">
 | 
						|
                
 | 
						|
                    <optional><br>
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
                </td>
 | 
						|
            
 | 
						|
 | 
						|
            
 | 
						|
 | 
						|
            <td class="description last">options to run this function</td>
 | 
						|
        </tr>
 | 
						|
 | 
						|
    
 | 
						|
    </tbody>
 | 
						|
</table>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<h5>Returns:</h5>
 | 
						|
 | 
						|
        
 | 
						|
<div class="param-desc">
 | 
						|
    Promise object represents {String} result of MediaWiki API
 | 
						|
</div>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<dl class="param-type">
 | 
						|
    <dt>
 | 
						|
        Type
 | 
						|
    </dt>
 | 
						|
    <dd>
 | 
						|
        
 | 
						|
<span class="param-type">Promise</span>
 | 
						|
 | 
						|
 | 
						|
    </dd>
 | 
						|
</dl>
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
 | 
						|
 | 
						|
        
 | 
						|
            
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    <h4 class="name" id="move_to"><span class="type-signature"></span>move_to<span class="signature">(move_to_title, options<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Promise}</span></h4>
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<dl class="details">
 | 
						|
 | 
						|
    
 | 
						|
    <dt class="tag-source">Source:</dt>
 | 
						|
    <dd class="tag-source"><ul class="dummy"><li>
 | 
						|
        <a href="wikiapi.js.html">wikiapi.js</a>, <a href="wikiapi.js.html#line595">line 595</a>
 | 
						|
    </li></ul></dd>
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
</dl>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<div class="description usertext">
 | 
						|
    Move to <code>move_to_title</code>. <em>Must call <a href="Wikiapi.html#page">Wikiapi#page</a> first!</em>
 | 
						|
</div>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
    <h5>Example</h5>
 | 
						|
    
 | 
						|
        <p class="code-caption">Move <code>move_from_title</code> to <code>move_to_title</code>.</p>
 | 
						|
    
 | 
						|
    <pre class="prettyprint"><code>// <code>
 | 
						|
page_data = await wiki.page(move_from_title);
 | 
						|
await wiki.move_to(move_to_title, { reason: reason, noredirect: true, movetalk: true });
 | 
						|
// </code></code></pre>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
    <h5>Parameters:</h5>
 | 
						|
    
 | 
						|
 | 
						|
<table class="params">
 | 
						|
    <thead>
 | 
						|
    <tr>
 | 
						|
        
 | 
						|
        <th>Name</th>
 | 
						|
        
 | 
						|
 | 
						|
        <th>Type</th>
 | 
						|
 | 
						|
        
 | 
						|
        <th>Attributes</th>
 | 
						|
        
 | 
						|
 | 
						|
        
 | 
						|
 | 
						|
        <th class="last">Description</th>
 | 
						|
    </tr>
 | 
						|
    </thead>
 | 
						|
 | 
						|
    <tbody>
 | 
						|
    
 | 
						|
 | 
						|
        <tr>
 | 
						|
            
 | 
						|
                <td class="name"><code>move_to_title</code></td>
 | 
						|
            
 | 
						|
 | 
						|
            <td class="type">
 | 
						|
            
 | 
						|
                
 | 
						|
<span class="param-type">Object</span>
 | 
						|
|
 | 
						|
 | 
						|
<span class="param-type">String</span>
 | 
						|
 | 
						|
 | 
						|
            
 | 
						|
            </td>
 | 
						|
 | 
						|
            
 | 
						|
                <td class="attributes">
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
                </td>
 | 
						|
            
 | 
						|
 | 
						|
            
 | 
						|
 | 
						|
            <td class="description last">move to title</td>
 | 
						|
        </tr>
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
        <tr>
 | 
						|
            
 | 
						|
                <td class="name"><code>options</code></td>
 | 
						|
            
 | 
						|
 | 
						|
            <td class="type">
 | 
						|
            
 | 
						|
                
 | 
						|
<span class="param-type">Object</span>
 | 
						|
 | 
						|
 | 
						|
            
 | 
						|
            </td>
 | 
						|
 | 
						|
            
 | 
						|
                <td class="attributes">
 | 
						|
                
 | 
						|
                    <optional><br>
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
                </td>
 | 
						|
            
 | 
						|
 | 
						|
            
 | 
						|
 | 
						|
            <td class="description last">options to run this function</td>
 | 
						|
        </tr>
 | 
						|
 | 
						|
    
 | 
						|
    </tbody>
 | 
						|
</table>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<h5>Returns:</h5>
 | 
						|
 | 
						|
        
 | 
						|
<div class="param-desc">
 | 
						|
    Promise object represents {String} result of MediaWiki API
 | 
						|
</div>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<dl class="param-type">
 | 
						|
    <dt>
 | 
						|
        Type
 | 
						|
    </dt>
 | 
						|
    <dd>
 | 
						|
        
 | 
						|
<span class="param-type">Promise</span>
 | 
						|
 | 
						|
 | 
						|
    </dd>
 | 
						|
</dl>
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
 | 
						|
 | 
						|
        
 | 
						|
            
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    <h4 class="name" id="new_data_entity"><span class="type-signature"></span>new_data_entity<span class="signature">(data_to_modify, options<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Promise}</span></h4>
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<dl class="details">
 | 
						|
 | 
						|
    
 | 
						|
    <dt class="tag-source">Source:</dt>
 | 
						|
    <dd class="tag-source"><ul class="dummy"><li>
 | 
						|
        <a href="wikiapi.js.html">wikiapi.js</a>, <a href="wikiapi.js.html#line890">line 890</a>
 | 
						|
    </li></ul></dd>
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
</dl>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<div class="description usertext">
 | 
						|
    Create new entity or property
 | 
						|
</div>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
    <h5>Example</h5>
 | 
						|
    
 | 
						|
        <p class="code-caption">Create new entity</p>
 | 
						|
    
 | 
						|
    <pre class="prettyprint"><code>// <code>
 | 
						|
const new_entity = await wiki.new_data_entity({ labels: { en: "Evolution in Mendelian Populations" }, P698: "17246615", P932: "1201091" }, { new: 'item' });
 | 
						|
// </code></code></pre>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
    <h5>Parameters:</h5>
 | 
						|
    
 | 
						|
 | 
						|
<table class="params">
 | 
						|
    <thead>
 | 
						|
    <tr>
 | 
						|
        
 | 
						|
        <th>Name</th>
 | 
						|
        
 | 
						|
 | 
						|
        <th>Type</th>
 | 
						|
 | 
						|
        
 | 
						|
        <th>Attributes</th>
 | 
						|
        
 | 
						|
 | 
						|
        
 | 
						|
 | 
						|
        <th class="last">Description</th>
 | 
						|
    </tr>
 | 
						|
    </thead>
 | 
						|
 | 
						|
    <tbody>
 | 
						|
    
 | 
						|
 | 
						|
        <tr>
 | 
						|
            
 | 
						|
                <td class="name"><code>data_to_modify</code></td>
 | 
						|
            
 | 
						|
 | 
						|
            <td class="type">
 | 
						|
            
 | 
						|
                
 | 
						|
<span class="param-type">Object</span>
 | 
						|
 | 
						|
 | 
						|
            
 | 
						|
            </td>
 | 
						|
 | 
						|
            
 | 
						|
                <td class="attributes">
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
                </td>
 | 
						|
            
 | 
						|
 | 
						|
            
 | 
						|
 | 
						|
            <td class="description last">Initial data.</td>
 | 
						|
        </tr>
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
        <tr>
 | 
						|
            
 | 
						|
                <td class="name"><code>options</code></td>
 | 
						|
            
 | 
						|
 | 
						|
            <td class="type">
 | 
						|
            
 | 
						|
                
 | 
						|
<span class="param-type">Object</span>
 | 
						|
 | 
						|
 | 
						|
            
 | 
						|
            </td>
 | 
						|
 | 
						|
            
 | 
						|
                <td class="attributes">
 | 
						|
                
 | 
						|
                    <optional><br>
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
                </td>
 | 
						|
            
 | 
						|
 | 
						|
            
 | 
						|
 | 
						|
            <td class="description last">options to run this function</td>
 | 
						|
        </tr>
 | 
						|
 | 
						|
    
 | 
						|
    </tbody>
 | 
						|
</table>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<h5>Returns:</h5>
 | 
						|
 | 
						|
        
 | 
						|
<div class="param-desc">
 | 
						|
    Promise object represents {Object} new entity or property.
 | 
						|
</div>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<dl class="param-type">
 | 
						|
    <dt>
 | 
						|
        Type
 | 
						|
    </dt>
 | 
						|
    <dd>
 | 
						|
        
 | 
						|
<span class="param-type">Promise</span>
 | 
						|
 | 
						|
 | 
						|
    </dd>
 | 
						|
</dl>
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
 | 
						|
 | 
						|
        
 | 
						|
            
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    <h4 class="name" id="page"><span class="type-signature"></span>page<span class="signature">(title, options<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Promise}</span></h4>
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<dl class="details">
 | 
						|
 | 
						|
    
 | 
						|
    <dt class="tag-source">Source:</dt>
 | 
						|
    <dd class="tag-source"><ul class="dummy"><li>
 | 
						|
        <a href="wikiapi.js.html">wikiapi.js</a>, <a href="wikiapi.js.html#line318">line 318</a>
 | 
						|
    </li></ul></dd>
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
</dl>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<div class="description usertext">
 | 
						|
    given a title, returns the page's data.
 | 
						|
</div>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
    <h5>Examples</h5>
 | 
						|
    
 | 
						|
        <p class="code-caption">load page</p>
 | 
						|
    
 | 
						|
    <pre class="prettyprint"><code>// <code>
 | 
						|
// on Wikipedia...
 | 
						|
const wiki = new Wikiapi('en');
 | 
						|
// ...or other MediaWiki websites
 | 
						|
//const wiki = new Wikiapi('https://awoiaf.westeros.org/api.php');
 | 
						|
let page_data = await wiki.page('Universe', {
 | 
						|
	// You may also set rvprop.
 | 
						|
	//rvprop: 'ids|content|timestamp|user',
 | 
						|
});
 | 
						|
console.log(page_data.wikitext);
 | 
						|
// </code></code></pre>
 | 
						|
 | 
						|
        <p class="code-caption">Get multi revisions</p>
 | 
						|
    
 | 
						|
    <pre class="prettyprint"><code>// <code>
 | 
						|
const wiki = new Wikiapi;
 | 
						|
let page_data = await wiki.page('Universe', {
 | 
						|
	// Get multi revisions
 | 
						|
	revisions: 2
 | 
						|
});
 | 
						|
console.log(page_data.wikitext);
 | 
						|
// </code></code></pre>
 | 
						|
 | 
						|
        <p class="code-caption">parse wiki page (The parser is more powerful than the example. Please refer to link of wikitext parser examples showing in "Features" section of README.md.)</p>
 | 
						|
    
 | 
						|
    <pre class="prettyprint"><code>// <code>
 | 
						|
// Usage with other language
 | 
						|
const zhwiki = new Wikiapi('zh');
 | 
						|
await zhwiki.login('user', 'password');
 | 
						|
let page_data = await zhwiki.page('Universe');
 | 
						|
 | 
						|
// `page_data.parse(options)` will startup the parser process, create page_data.parsed. After .parse(), we can use parsed.each().
 | 
						|
const parsed = page_data.parse();
 | 
						|
 | 
						|
// See all type in wiki_toString @ https://github.com/kanasimi/CeJS/tree/master/application/net/wiki/parser/wikitext.js
 | 
						|
// List all template name.
 | 
						|
parsed.each('template', token => console.log(token.name));
 | 
						|
// List all [[Template:Tl]] token.
 | 
						|
parsed.each('Template:Tl', token => console.log(token));
 | 
						|
// </code></code></pre>
 | 
						|
 | 
						|
        <p class="code-caption">Get information from Infobox template</p>
 | 
						|
    
 | 
						|
    <pre class="prettyprint"><code>// <code>
 | 
						|
const wiki = new Wikiapi('en');
 | 
						|
const page_data = await wiki.page('JavaScript');
 | 
						|
const parsed = page_data.parse();
 | 
						|
let infobox;
 | 
						|
// Read Infobox templates, convert to JSON.
 | 
						|
parsed.each('template', template_token => {
 | 
						|
	if (template_token.name.startsWith('Infobox')) {
 | 
						|
		infobox = template_token.parameters;
 | 
						|
		return parsed.each.exit;
 | 
						|
	}
 | 
						|
});
 | 
						|
for (const [key, value] of Object.entries(infobox))
 | 
						|
	infobox[key] = value.toString();
 | 
						|
// print json of the infobox
 | 
						|
console.log(infobox);
 | 
						|
// </code></code></pre>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
    <h5>Parameters:</h5>
 | 
						|
    
 | 
						|
 | 
						|
<table class="params">
 | 
						|
    <thead>
 | 
						|
    <tr>
 | 
						|
        
 | 
						|
        <th>Name</th>
 | 
						|
        
 | 
						|
 | 
						|
        <th>Type</th>
 | 
						|
 | 
						|
        
 | 
						|
        <th>Attributes</th>
 | 
						|
        
 | 
						|
 | 
						|
        
 | 
						|
 | 
						|
        <th class="last">Description</th>
 | 
						|
    </tr>
 | 
						|
    </thead>
 | 
						|
 | 
						|
    <tbody>
 | 
						|
    
 | 
						|
 | 
						|
        <tr>
 | 
						|
            
 | 
						|
                <td class="name"><code>title</code></td>
 | 
						|
            
 | 
						|
 | 
						|
            <td class="type">
 | 
						|
            
 | 
						|
                
 | 
						|
<span class="param-type">String</span>
 | 
						|
 | 
						|
 | 
						|
            
 | 
						|
            </td>
 | 
						|
 | 
						|
            
 | 
						|
                <td class="attributes">
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
                </td>
 | 
						|
            
 | 
						|
 | 
						|
            
 | 
						|
 | 
						|
            <td class="description last">page title</td>
 | 
						|
        </tr>
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
        <tr>
 | 
						|
            
 | 
						|
                <td class="name"><code>options</code></td>
 | 
						|
            
 | 
						|
 | 
						|
            <td class="type">
 | 
						|
            
 | 
						|
                
 | 
						|
<span class="param-type">Object</span>
 | 
						|
 | 
						|
 | 
						|
            
 | 
						|
            </td>
 | 
						|
 | 
						|
            
 | 
						|
                <td class="attributes">
 | 
						|
                
 | 
						|
                    <optional><br>
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
                </td>
 | 
						|
            
 | 
						|
 | 
						|
            
 | 
						|
 | 
						|
            <td class="description last">options to run this function</td>
 | 
						|
        </tr>
 | 
						|
 | 
						|
    
 | 
						|
    </tbody>
 | 
						|
</table>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<h5>Returns:</h5>
 | 
						|
 | 
						|
        
 | 
						|
<div class="param-desc">
 | 
						|
    Promise object represents {Object} page's data
 | 
						|
</div>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<dl class="param-type">
 | 
						|
    <dt>
 | 
						|
        Type
 | 
						|
    </dt>
 | 
						|
    <dd>
 | 
						|
        
 | 
						|
<span class="param-type">Promise</span>
 | 
						|
 | 
						|
 | 
						|
    </dd>
 | 
						|
</dl>
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
 | 
						|
 | 
						|
        
 | 
						|
            
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    <h4 class="name" id="purge"><span class="type-signature"></span>purge<span class="signature">(title, options<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Promise}</span></h4>
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<dl class="details">
 | 
						|
 | 
						|
    
 | 
						|
    <dt class="tag-source">Source:</dt>
 | 
						|
    <dd class="tag-source"><ul class="dummy"><li>
 | 
						|
        <a href="wikiapi.js.html">wikiapi.js</a>, <a href="wikiapi.js.html#line694">line 694</a>
 | 
						|
    </li></ul></dd>
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
</dl>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<div class="description usertext">
 | 
						|
    Purge the cache for the given title.
 | 
						|
</div>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
    <h5>Example</h5>
 | 
						|
    
 | 
						|
        <p class="code-caption">query flow-parsoid-utils</p>
 | 
						|
    
 | 
						|
    <pre class="prettyprint"><code>// <code>
 | 
						|
const metawiki = new Wikiapi('meta');
 | 
						|
let page_data = await metawiki.purge('Project:Sandbox');
 | 
						|
// </code></code></pre>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
    <h5>Parameters:</h5>
 | 
						|
    
 | 
						|
 | 
						|
<table class="params">
 | 
						|
    <thead>
 | 
						|
    <tr>
 | 
						|
        
 | 
						|
        <th>Name</th>
 | 
						|
        
 | 
						|
 | 
						|
        <th>Type</th>
 | 
						|
 | 
						|
        
 | 
						|
        <th>Attributes</th>
 | 
						|
        
 | 
						|
 | 
						|
        
 | 
						|
 | 
						|
        <th class="last">Description</th>
 | 
						|
    </tr>
 | 
						|
    </thead>
 | 
						|
 | 
						|
    <tbody>
 | 
						|
    
 | 
						|
 | 
						|
        <tr>
 | 
						|
            
 | 
						|
                <td class="name"><code>title</code></td>
 | 
						|
            
 | 
						|
 | 
						|
            <td class="type">
 | 
						|
            
 | 
						|
                
 | 
						|
<span class="param-type">Object</span>
 | 
						|
 | 
						|
 | 
						|
            
 | 
						|
            </td>
 | 
						|
 | 
						|
            
 | 
						|
                <td class="attributes">
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
                </td>
 | 
						|
            
 | 
						|
 | 
						|
            
 | 
						|
 | 
						|
            <td class="description last">page title</td>
 | 
						|
        </tr>
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
        <tr>
 | 
						|
            
 | 
						|
                <td class="name"><code>options</code></td>
 | 
						|
            
 | 
						|
 | 
						|
            <td class="type">
 | 
						|
            
 | 
						|
                
 | 
						|
<span class="param-type">Object</span>
 | 
						|
 | 
						|
 | 
						|
            
 | 
						|
            </td>
 | 
						|
 | 
						|
            
 | 
						|
                <td class="attributes">
 | 
						|
                
 | 
						|
                    <optional><br>
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
                </td>
 | 
						|
            
 | 
						|
 | 
						|
            
 | 
						|
 | 
						|
            <td class="description last">options to run this function</td>
 | 
						|
        </tr>
 | 
						|
 | 
						|
    
 | 
						|
    </tbody>
 | 
						|
</table>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<h5>Returns:</h5>
 | 
						|
 | 
						|
        
 | 
						|
<div class="param-desc">
 | 
						|
    Promise object represents {Object} page_data
 | 
						|
</div>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<dl class="param-type">
 | 
						|
    <dt>
 | 
						|
        Type
 | 
						|
    </dt>
 | 
						|
    <dd>
 | 
						|
        
 | 
						|
<span class="param-type">Promise</span>
 | 
						|
 | 
						|
 | 
						|
    </dd>
 | 
						|
</dl>
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
 | 
						|
 | 
						|
        
 | 
						|
            
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    <h4 class="name" id="query"><span class="type-signature"></span>query<span class="signature">(parameters, options<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Promise}</span></h4>
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<dl class="details">
 | 
						|
 | 
						|
    
 | 
						|
    <dt class="tag-source">Source:</dt>
 | 
						|
    <dd class="tag-source"><ul class="dummy"><li>
 | 
						|
        <a href="wikiapi.js.html">wikiapi.js</a>, <a href="wikiapi.js.html#line657">line 657</a>
 | 
						|
    </li></ul></dd>
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
</dl>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<div class="description usertext">
 | 
						|
    query MediaWiki API manually
 | 
						|
</div>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
    <h5>Example</h5>
 | 
						|
    
 | 
						|
        <p class="code-caption">query flow-parsoid-utils</p>
 | 
						|
    
 | 
						|
    <pre class="prettyprint"><code>// <code>
 | 
						|
const wiki = new Wikiapi('mediawiki');
 | 
						|
const results = await wiki.query({
 | 
						|
	action: "flow-parsoid-utils",
 | 
						|
	content: "<b>bold</b> &amp; <i>italic</i>",
 | 
						|
	title: "MediaWiki", from: "html", to: "wikitext"
 | 
						|
});
 | 
						|
// </code></code></pre>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
    <h5>Parameters:</h5>
 | 
						|
    
 | 
						|
 | 
						|
<table class="params">
 | 
						|
    <thead>
 | 
						|
    <tr>
 | 
						|
        
 | 
						|
        <th>Name</th>
 | 
						|
        
 | 
						|
 | 
						|
        <th>Type</th>
 | 
						|
 | 
						|
        
 | 
						|
        <th>Attributes</th>
 | 
						|
        
 | 
						|
 | 
						|
        
 | 
						|
 | 
						|
        <th class="last">Description</th>
 | 
						|
    </tr>
 | 
						|
    </thead>
 | 
						|
 | 
						|
    <tbody>
 | 
						|
    
 | 
						|
 | 
						|
        <tr>
 | 
						|
            
 | 
						|
                <td class="name"><code>parameters</code></td>
 | 
						|
            
 | 
						|
 | 
						|
            <td class="type">
 | 
						|
            
 | 
						|
                
 | 
						|
<span class="param-type">Object</span>
 | 
						|
 | 
						|
 | 
						|
            
 | 
						|
            </td>
 | 
						|
 | 
						|
            
 | 
						|
                <td class="attributes">
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
                </td>
 | 
						|
            
 | 
						|
 | 
						|
            
 | 
						|
 | 
						|
            <td class="description last">parameters to call MediaWiki API</td>
 | 
						|
        </tr>
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
        <tr>
 | 
						|
            
 | 
						|
                <td class="name"><code>options</code></td>
 | 
						|
            
 | 
						|
 | 
						|
            <td class="type">
 | 
						|
            
 | 
						|
                
 | 
						|
<span class="param-type">Object</span>
 | 
						|
 | 
						|
 | 
						|
            
 | 
						|
            </td>
 | 
						|
 | 
						|
            
 | 
						|
                <td class="attributes">
 | 
						|
                
 | 
						|
                    <optional><br>
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
                </td>
 | 
						|
            
 | 
						|
 | 
						|
            
 | 
						|
 | 
						|
            <td class="description last">options to run this function</td>
 | 
						|
        </tr>
 | 
						|
 | 
						|
    
 | 
						|
    </tbody>
 | 
						|
</table>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<h5>Returns:</h5>
 | 
						|
 | 
						|
        
 | 
						|
<div class="param-desc">
 | 
						|
    Promise object represents {Object} result of MediaWiki API
 | 
						|
</div>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<dl class="param-type">
 | 
						|
    <dt>
 | 
						|
        Type
 | 
						|
    </dt>
 | 
						|
    <dd>
 | 
						|
        
 | 
						|
<span class="param-type">Promise</span>
 | 
						|
 | 
						|
 | 
						|
    </dd>
 | 
						|
</dl>
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
 | 
						|
 | 
						|
        
 | 
						|
            
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    <h4 class="name" id="redirects_here"><span class="type-signature"></span>redirects_here<span class="signature">(title, options<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Promise}</span></h4>
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<dl class="details">
 | 
						|
 | 
						|
    
 | 
						|
    <dt class="tag-source">Source:</dt>
 | 
						|
    <dd class="tag-source"><ul class="dummy"><li>
 | 
						|
        <a href="wikiapi.js.html">wikiapi.js</a>, <a href="wikiapi.js.html#line1215">line 1215</a>
 | 
						|
    </li></ul></dd>
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
</dl>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<div class="description usertext">
 | 
						|
    Get all pages redirects to <code>title</code>.
 | 
						|
</div>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
    <h5>Example</h5>
 | 
						|
    
 | 
						|
        <p class="code-caption">Get all pages redirects to [[Wikipedia:Sandbox]]</p>
 | 
						|
    
 | 
						|
    <pre class="prettyprint"><code>// <code>
 | 
						|
const redirects_list = await enwiki.redirects_here('Wikipedia:Sandbox');
 | 
						|
// </code></code></pre>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
    <h5>Parameters:</h5>
 | 
						|
    
 | 
						|
 | 
						|
<table class="params">
 | 
						|
    <thead>
 | 
						|
    <tr>
 | 
						|
        
 | 
						|
        <th>Name</th>
 | 
						|
        
 | 
						|
 | 
						|
        <th>Type</th>
 | 
						|
 | 
						|
        
 | 
						|
        <th>Attributes</th>
 | 
						|
        
 | 
						|
 | 
						|
        
 | 
						|
 | 
						|
        <th class="last">Description</th>
 | 
						|
    </tr>
 | 
						|
    </thead>
 | 
						|
 | 
						|
    <tbody>
 | 
						|
    
 | 
						|
 | 
						|
        <tr>
 | 
						|
            
 | 
						|
                <td class="name"><code>title</code></td>
 | 
						|
            
 | 
						|
 | 
						|
            <td class="type">
 | 
						|
            
 | 
						|
                
 | 
						|
<span class="param-type">String</span>
 | 
						|
 | 
						|
 | 
						|
            
 | 
						|
            </td>
 | 
						|
 | 
						|
            
 | 
						|
                <td class="attributes">
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
                </td>
 | 
						|
            
 | 
						|
 | 
						|
            
 | 
						|
 | 
						|
            <td class="description last">page title</td>
 | 
						|
        </tr>
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
        <tr>
 | 
						|
            
 | 
						|
                <td class="name"><code>options</code></td>
 | 
						|
            
 | 
						|
 | 
						|
            <td class="type">
 | 
						|
            
 | 
						|
                
 | 
						|
<span class="param-type">Object</span>
 | 
						|
 | 
						|
 | 
						|
            
 | 
						|
            </td>
 | 
						|
 | 
						|
            
 | 
						|
                <td class="attributes">
 | 
						|
                
 | 
						|
                    <optional><br>
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
                </td>
 | 
						|
            
 | 
						|
 | 
						|
            
 | 
						|
 | 
						|
            <td class="description last">options to run this function</td>
 | 
						|
        </tr>
 | 
						|
 | 
						|
    
 | 
						|
    </tbody>
 | 
						|
</table>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<h5>Returns:</h5>
 | 
						|
 | 
						|
        
 | 
						|
<div class="param-desc">
 | 
						|
    Promise object represents {Array} redirect_list
 | 
						|
</div>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<dl class="param-type">
 | 
						|
    <dt>
 | 
						|
        Type
 | 
						|
    </dt>
 | 
						|
    <dd>
 | 
						|
        
 | 
						|
<span class="param-type">Promise</span>
 | 
						|
 | 
						|
 | 
						|
    </dd>
 | 
						|
</dl>
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
 | 
						|
 | 
						|
        
 | 
						|
            
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    <h4 class="name" id="redirects_root"><span class="type-signature"></span>redirects_root<span class="signature">(title, options<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Promise}</span></h4>
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<dl class="details">
 | 
						|
 | 
						|
    
 | 
						|
    <dt class="tag-source">Source:</dt>
 | 
						|
    <dd class="tag-source"><ul class="dummy"><li>
 | 
						|
        <a href="wikiapi.js.html">wikiapi.js</a>, <a href="wikiapi.js.html#line1178">line 1178</a>
 | 
						|
    </li></ul></dd>
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
</dl>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<div class="description usertext">
 | 
						|
    Get redirects target of <code>title</code>.
 | 
						|
</div>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
    <h5>Example</h5>
 | 
						|
    
 | 
						|
        <p class="code-caption">Get redirects target of [[WP:SB]]</p>
 | 
						|
    
 | 
						|
    <pre class="prettyprint"><code>// <code>
 | 
						|
const redirects_taregt = await enwiki.redirects_root('WP:SB', { get_page_data: true });
 | 
						|
// </code></code></pre>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
    <h5>Parameters:</h5>
 | 
						|
    
 | 
						|
 | 
						|
<table class="params">
 | 
						|
    <thead>
 | 
						|
    <tr>
 | 
						|
        
 | 
						|
        <th>Name</th>
 | 
						|
        
 | 
						|
 | 
						|
        <th>Type</th>
 | 
						|
 | 
						|
        
 | 
						|
        <th>Attributes</th>
 | 
						|
        
 | 
						|
 | 
						|
        
 | 
						|
 | 
						|
        <th class="last">Description</th>
 | 
						|
    </tr>
 | 
						|
    </thead>
 | 
						|
 | 
						|
    <tbody>
 | 
						|
    
 | 
						|
 | 
						|
        <tr>
 | 
						|
            
 | 
						|
                <td class="name"><code>title</code></td>
 | 
						|
            
 | 
						|
 | 
						|
            <td class="type">
 | 
						|
            
 | 
						|
                
 | 
						|
<span class="param-type">String</span>
 | 
						|
 | 
						|
 | 
						|
            
 | 
						|
            </td>
 | 
						|
 | 
						|
            
 | 
						|
                <td class="attributes">
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
                </td>
 | 
						|
            
 | 
						|
 | 
						|
            
 | 
						|
 | 
						|
            <td class="description last">page title</td>
 | 
						|
        </tr>
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
        <tr>
 | 
						|
            
 | 
						|
                <td class="name"><code>options</code></td>
 | 
						|
            
 | 
						|
 | 
						|
            <td class="type">
 | 
						|
            
 | 
						|
                
 | 
						|
<span class="param-type">Object</span>
 | 
						|
 | 
						|
 | 
						|
            
 | 
						|
            </td>
 | 
						|
 | 
						|
            
 | 
						|
                <td class="attributes">
 | 
						|
                
 | 
						|
                    <optional><br>
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
                </td>
 | 
						|
            
 | 
						|
 | 
						|
            
 | 
						|
 | 
						|
            <td class="description last">options to run this function</td>
 | 
						|
        </tr>
 | 
						|
 | 
						|
    
 | 
						|
    </tbody>
 | 
						|
</table>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<h5>Returns:</h5>
 | 
						|
 | 
						|
        
 | 
						|
<div class="param-desc">
 | 
						|
    Promise object represents {String} page title or {Object} page data
 | 
						|
</div>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<dl class="param-type">
 | 
						|
    <dt>
 | 
						|
        Type
 | 
						|
    </dt>
 | 
						|
    <dd>
 | 
						|
        
 | 
						|
<span class="param-type">Promise</span>
 | 
						|
 | 
						|
 | 
						|
    </dd>
 | 
						|
</dl>
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
 | 
						|
 | 
						|
        
 | 
						|
            
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    <h4 class="name" id="register_redirects"><span class="type-signature"></span>register_redirects<span class="signature">(page_title_list, options<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Promise}</span></h4>
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<dl class="details">
 | 
						|
 | 
						|
    
 | 
						|
    <dt class="tag-source">Source:</dt>
 | 
						|
    <dd class="tag-source"><ul class="dummy"><li>
 | 
						|
        <a href="wikiapi.js.html">wikiapi.js</a>, <a href="wikiapi.js.html#line1289">line 1289</a>
 | 
						|
    </li></ul></dd>
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
</dl>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<div class="description usertext">
 | 
						|
    register page alias. usually used for templates
 | 
						|
</div>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
    <h5>Example</h5>
 | 
						|
    
 | 
						|
        <p class="code-caption">Register template redirects and get tokens of the templates.</p>
 | 
						|
    
 | 
						|
    <pre class="prettyprint"><code>// <code>
 | 
						|
const wiki_session = new Wikiapi;
 | 
						|
// e.g., await wiki_session.register_redirects(['Section link', 'Broken anchors'], { namespace: 'Template' });
 | 
						|
await wiki_session.register_redirects([template_name_1, template_name_2, template_name_3], { namespace: 'Template' });
 | 
						|
 | 
						|
// ...
 | 
						|
 | 
						|
const page_data = await wiki_session.page(page_title);
 | 
						|
// {Array} parsed page content 頁面解析後的結構。
 | 
						|
const parsed = page_data.parse();
 | 
						|
 | 
						|
parsed.each('Template:' + template_name_1, function (token, index, parent) {
 | 
						|
	// ...
 | 
						|
});
 | 
						|
 | 
						|
parsed.each('template', function (token, index, parent) {
 | 
						|
	if (wiki_session.is_template(template_name_1, token)) {
 | 
						|
		// ...
 | 
						|
		return;
 | 
						|
	}
 | 
						|
	if (wiki_session.is_template(template_name_2, token)) {
 | 
						|
		// ...
 | 
						|
		return;
 | 
						|
	}
 | 
						|
 | 
						|
	// alternative method:
 | 
						|
	switch (wiki_session.redirect_target_of(token)) {
 | 
						|
		case wiki_session.redirect_target_of(template_name_1):
 | 
						|
			break;
 | 
						|
		case wiki_session.redirect_target_of(template_name_2):
 | 
						|
			break;
 | 
						|
		case wiki_session.redirect_target_of(template_name_3):
 | 
						|
			break;
 | 
						|
	}
 | 
						|
});
 | 
						|
// </code></code></pre>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
    <h5>Parameters:</h5>
 | 
						|
    
 | 
						|
 | 
						|
<table class="params">
 | 
						|
    <thead>
 | 
						|
    <tr>
 | 
						|
        
 | 
						|
        <th>Name</th>
 | 
						|
        
 | 
						|
 | 
						|
        <th>Type</th>
 | 
						|
 | 
						|
        
 | 
						|
        <th>Attributes</th>
 | 
						|
        
 | 
						|
 | 
						|
        
 | 
						|
 | 
						|
        <th class="last">Description</th>
 | 
						|
    </tr>
 | 
						|
    </thead>
 | 
						|
 | 
						|
    <tbody>
 | 
						|
    
 | 
						|
 | 
						|
        <tr>
 | 
						|
            
 | 
						|
                <td class="name"><code>page_title_list</code></td>
 | 
						|
            
 | 
						|
 | 
						|
            <td class="type">
 | 
						|
            
 | 
						|
                
 | 
						|
<span class="param-type">Array</span>
 | 
						|
|
 | 
						|
 | 
						|
<span class="param-type">String</span>
 | 
						|
 | 
						|
 | 
						|
            
 | 
						|
            </td>
 | 
						|
 | 
						|
            
 | 
						|
                <td class="attributes">
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
                </td>
 | 
						|
            
 | 
						|
 | 
						|
            
 | 
						|
 | 
						|
            <td class="description last">list of page titles</td>
 | 
						|
        </tr>
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
        <tr>
 | 
						|
            
 | 
						|
                <td class="name"><code>options</code></td>
 | 
						|
            
 | 
						|
 | 
						|
            <td class="type">
 | 
						|
            
 | 
						|
                
 | 
						|
<span class="param-type">Object</span>
 | 
						|
 | 
						|
 | 
						|
            
 | 
						|
            </td>
 | 
						|
 | 
						|
            
 | 
						|
                <td class="attributes">
 | 
						|
                
 | 
						|
                    <optional><br>
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
                </td>
 | 
						|
            
 | 
						|
 | 
						|
            
 | 
						|
 | 
						|
            <td class="description last">options to run this function.</td>
 | 
						|
        </tr>
 | 
						|
 | 
						|
    
 | 
						|
    </tbody>
 | 
						|
</table>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<h5>Returns:</h5>
 | 
						|
 | 
						|
        
 | 
						|
<div class="param-desc">
 | 
						|
    Promise object represents the operations are done.
 | 
						|
</div>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<dl class="param-type">
 | 
						|
    <dt>
 | 
						|
        Type
 | 
						|
    </dt>
 | 
						|
    <dd>
 | 
						|
        
 | 
						|
<span class="param-type">Promise</span>
 | 
						|
 | 
						|
 | 
						|
    </dd>
 | 
						|
</dl>
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
 | 
						|
 | 
						|
        
 | 
						|
            
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    <h4 class="name" id="search"><span class="type-signature"></span>search<span class="signature">(key, options<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Promise}</span></h4>
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<dl class="details">
 | 
						|
 | 
						|
    
 | 
						|
    <dt class="tag-source">Source:</dt>
 | 
						|
    <dd class="tag-source"><ul class="dummy"><li>
 | 
						|
        <a href="wikiapi.js.html">wikiapi.js</a>, <a href="wikiapi.js.html#line1144">line 1144</a>
 | 
						|
    </li></ul></dd>
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
</dl>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<div class="description usertext">
 | 
						|
    search pages include <code>key</code>
 | 
						|
</div>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
    <h5>Example</h5>
 | 
						|
    
 | 
						|
        <p class="code-caption">search pages include key: 霍金</p>
 | 
						|
    
 | 
						|
    <pre class="prettyprint"><code>// <code>
 | 
						|
const zhwikinews = new Wikiapi('zh.wikinews');
 | 
						|
const page_list = await zhwikinews.search('"霍金"');
 | 
						|
// </code></code></pre>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
    <h5>Parameters:</h5>
 | 
						|
    
 | 
						|
 | 
						|
<table class="params">
 | 
						|
    <thead>
 | 
						|
    <tr>
 | 
						|
        
 | 
						|
        <th>Name</th>
 | 
						|
        
 | 
						|
 | 
						|
        <th>Type</th>
 | 
						|
 | 
						|
        
 | 
						|
        <th>Attributes</th>
 | 
						|
        
 | 
						|
 | 
						|
        
 | 
						|
 | 
						|
        <th class="last">Description</th>
 | 
						|
    </tr>
 | 
						|
    </thead>
 | 
						|
 | 
						|
    <tbody>
 | 
						|
    
 | 
						|
 | 
						|
        <tr>
 | 
						|
            
 | 
						|
                <td class="name"><code>key</code></td>
 | 
						|
            
 | 
						|
 | 
						|
            <td class="type">
 | 
						|
            
 | 
						|
                
 | 
						|
<span class="param-type">String</span>
 | 
						|
 | 
						|
 | 
						|
            
 | 
						|
            </td>
 | 
						|
 | 
						|
            
 | 
						|
                <td class="attributes">
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
                </td>
 | 
						|
            
 | 
						|
 | 
						|
            
 | 
						|
 | 
						|
            <td class="description last">key to search</td>
 | 
						|
        </tr>
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
        <tr>
 | 
						|
            
 | 
						|
                <td class="name"><code>options</code></td>
 | 
						|
            
 | 
						|
 | 
						|
            <td class="type">
 | 
						|
            
 | 
						|
                
 | 
						|
<span class="param-type">Object</span>
 | 
						|
 | 
						|
 | 
						|
            
 | 
						|
            </td>
 | 
						|
 | 
						|
            
 | 
						|
                <td class="attributes">
 | 
						|
                
 | 
						|
                    <optional><br>
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
                </td>
 | 
						|
            
 | 
						|
 | 
						|
            
 | 
						|
 | 
						|
            <td class="description last">options to run this function.</td>
 | 
						|
        </tr>
 | 
						|
 | 
						|
    
 | 
						|
    </tbody>
 | 
						|
</table>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<h5>Returns:</h5>
 | 
						|
 | 
						|
        
 | 
						|
<div class="param-desc">
 | 
						|
    Promise object represents {Array} page_list.
 | 
						|
</div>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<dl class="param-type">
 | 
						|
    <dt>
 | 
						|
        Type
 | 
						|
    </dt>
 | 
						|
    <dd>
 | 
						|
        
 | 
						|
<span class="param-type">Promise</span>
 | 
						|
 | 
						|
 | 
						|
    </dd>
 | 
						|
</dl>
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
 | 
						|
 | 
						|
        
 | 
						|
            
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    <h4 class="name" id="site_name"><span class="type-signature"></span>site_name<span class="signature">(language<span class="signature-attributes">opt</span>, options<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {String}</span></h4>
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<dl class="details">
 | 
						|
 | 
						|
    
 | 
						|
    <dt class="tag-source">Source:</dt>
 | 
						|
    <dd class="tag-source"><ul class="dummy"><li>
 | 
						|
        <a href="wikiapi.js.html">wikiapi.js</a>, <a href="wikiapi.js.html#line1763">line 1763</a>
 | 
						|
    </li></ul></dd>
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
</dl>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<div class="description usertext">
 | 
						|
    Get site name / project name of this {Wikiapi}.
 | 
						|
</div>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
    <h5>Example</h5>
 | 
						|
    
 | 
						|
        <p class="code-caption">Get site name of {Wikiapi}.</p>
 | 
						|
    
 | 
						|
    <pre class="prettyprint"><code>// <code>
 | 
						|
console.log(Wikiapi.site_name('zh', { get_all_properties: true }));
 | 
						|
 | 
						|
const wiki = new Wikiapi('en');
 | 
						|
console.assert(wiki.site_name() === 'enwiki');
 | 
						|
console.log(wiki.site_name({ get_all_properties: true }));
 | 
						|
console.assert(wiki.site_name({ get_all_properties: true }).language === 'en');
 | 
						|
// </code></code></pre>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
    <h5>Parameters:</h5>
 | 
						|
    
 | 
						|
 | 
						|
<table class="params">
 | 
						|
    <thead>
 | 
						|
    <tr>
 | 
						|
        
 | 
						|
        <th>Name</th>
 | 
						|
        
 | 
						|
 | 
						|
        <th>Type</th>
 | 
						|
 | 
						|
        
 | 
						|
        <th>Attributes</th>
 | 
						|
        
 | 
						|
 | 
						|
        
 | 
						|
 | 
						|
        <th class="last">Description</th>
 | 
						|
    </tr>
 | 
						|
    </thead>
 | 
						|
 | 
						|
    <tbody>
 | 
						|
    
 | 
						|
 | 
						|
        <tr>
 | 
						|
            
 | 
						|
                <td class="name"><code>language</code></td>
 | 
						|
            
 | 
						|
 | 
						|
            <td class="type">
 | 
						|
            
 | 
						|
                
 | 
						|
<span class="param-type">String</span>
 | 
						|
 | 
						|
 | 
						|
            
 | 
						|
            </td>
 | 
						|
 | 
						|
            
 | 
						|
                <td class="attributes">
 | 
						|
                
 | 
						|
                    <optional><br>
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
                </td>
 | 
						|
            
 | 
						|
 | 
						|
            
 | 
						|
 | 
						|
            <td class="description last">language code of wiki session</td>
 | 
						|
        </tr>
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
        <tr>
 | 
						|
            
 | 
						|
                <td class="name"><code>options</code></td>
 | 
						|
            
 | 
						|
 | 
						|
            <td class="type">
 | 
						|
            
 | 
						|
                
 | 
						|
<span class="param-type">Object</span>
 | 
						|
 | 
						|
 | 
						|
            
 | 
						|
            </td>
 | 
						|
 | 
						|
            
 | 
						|
                <td class="attributes">
 | 
						|
                
 | 
						|
                    <optional><br>
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
                </td>
 | 
						|
            
 | 
						|
 | 
						|
            
 | 
						|
 | 
						|
            <td class="description last">options to run this function</td>
 | 
						|
        </tr>
 | 
						|
 | 
						|
    
 | 
						|
    </tbody>
 | 
						|
</table>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<h5>Returns:</h5>
 | 
						|
 | 
						|
        
 | 
						|
<div class="param-desc">
 | 
						|
    site name
 | 
						|
</div>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<dl class="param-type">
 | 
						|
    <dt>
 | 
						|
        Type
 | 
						|
    </dt>
 | 
						|
    <dd>
 | 
						|
        
 | 
						|
<span class="param-type">String</span>
 | 
						|
 | 
						|
 | 
						|
    </dd>
 | 
						|
</dl>
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
 | 
						|
 | 
						|
        
 | 
						|
            
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    <h4 class="name" id="SPARQL"><span class="type-signature"></span>SPARQL<span class="signature">(SPARQL, options<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Promise}</span></h4>
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<dl class="details">
 | 
						|
 | 
						|
    
 | 
						|
    <dt class="tag-source">Source:</dt>
 | 
						|
    <dd class="tag-source"><ul class="dummy"><li>
 | 
						|
        <a href="wikiapi.js.html">wikiapi.js</a>, <a href="wikiapi.js.html#line966">line 966</a>
 | 
						|
    </li></ul></dd>
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
</dl>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<div class="description usertext">
 | 
						|
    Query wikidata via SPARQL
 | 
						|
</div>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
    <h5>Examples</h5>
 | 
						|
    
 | 
						|
        <p class="code-caption">Get cats</p>
 | 
						|
    
 | 
						|
    <pre class="prettyprint"><code>// <code>
 | 
						|
const wikidata_item_list = await wiki.SPARQL(`
 | 
						|
SELECT ?item ?itemLabel WHERE {
 | 
						|
  ?item wdt:P31 wd:Q146.
 | 
						|
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
 | 
						|
}
 | 
						|
`);
 | 
						|
// </code></code></pre>
 | 
						|
 | 
						|
        <p class="code-caption">Get specific DOI</p>
 | 
						|
    
 | 
						|
    <pre class="prettyprint"><code>// <code>
 | 
						|
// for case-insensitive DOI
 | 
						|
const wikidata_item_list = await wiki.search('haswbstatement:' + JSON.stringify('P356=10.1371/journal.pone.0029797'), { namespace: 0 });
 | 
						|
//wikidata_item_list.map(item => item.title)
 | 
						|
 | 
						|
// for case-sensitive DOI
 | 
						|
const wikidata_item_list = await wiki.SPARQL(`
 | 
						|
SELECT ?doi ?item ?itemLabel WHERE {
 | 
						|
	VALUES ?doi { "10.1371/JOURNAL.PONE.0029797" }
 | 
						|
	?item wdt:P356 ?doi.
 | 
						|
	SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
 | 
						|
}`, {
 | 
						|
	// options.API_URL: custom SPARQL endpoint
 | 
						|
	API_URL: ''
 | 
						|
});
 | 
						|
//wikidata_item_list.id_list()
 | 
						|
// </code></code></pre>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
    <h5>Parameters:</h5>
 | 
						|
    
 | 
						|
 | 
						|
<table class="params">
 | 
						|
    <thead>
 | 
						|
    <tr>
 | 
						|
        
 | 
						|
        <th>Name</th>
 | 
						|
        
 | 
						|
 | 
						|
        <th>Type</th>
 | 
						|
 | 
						|
        
 | 
						|
        <th>Attributes</th>
 | 
						|
        
 | 
						|
 | 
						|
        
 | 
						|
 | 
						|
        <th class="last">Description</th>
 | 
						|
    </tr>
 | 
						|
    </thead>
 | 
						|
 | 
						|
    <tbody>
 | 
						|
    
 | 
						|
 | 
						|
        <tr>
 | 
						|
            
 | 
						|
                <td class="name"><code>SPARQL</code></td>
 | 
						|
            
 | 
						|
 | 
						|
            <td class="type">
 | 
						|
            
 | 
						|
                
 | 
						|
<span class="param-type">Object</span>
 | 
						|
 | 
						|
 | 
						|
            
 | 
						|
            </td>
 | 
						|
 | 
						|
            
 | 
						|
                <td class="attributes">
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
                </td>
 | 
						|
            
 | 
						|
 | 
						|
            
 | 
						|
 | 
						|
            <td class="description last">SPARQL to query. Please test it on <a href="https://query.wikidata.org/">Wikidata Query Service</a> first.</td>
 | 
						|
        </tr>
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
        <tr>
 | 
						|
            
 | 
						|
                <td class="name"><code>options</code></td>
 | 
						|
            
 | 
						|
 | 
						|
            <td class="type">
 | 
						|
            
 | 
						|
                
 | 
						|
<span class="param-type">Object</span>
 | 
						|
 | 
						|
 | 
						|
            
 | 
						|
            </td>
 | 
						|
 | 
						|
            
 | 
						|
                <td class="attributes">
 | 
						|
                
 | 
						|
                    <optional><br>
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
                </td>
 | 
						|
            
 | 
						|
 | 
						|
            
 | 
						|
 | 
						|
            <td class="description last">options to run this function</td>
 | 
						|
        </tr>
 | 
						|
 | 
						|
    
 | 
						|
    </tbody>
 | 
						|
</table>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<h5>Returns:</h5>
 | 
						|
 | 
						|
        
 | 
						|
<div class="param-desc">
 | 
						|
    Promise object represents {Array} query result of `SPARQL`.
 | 
						|
</div>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<dl class="param-type">
 | 
						|
    <dt>
 | 
						|
        Type
 | 
						|
    </dt>
 | 
						|
    <dd>
 | 
						|
        
 | 
						|
<span class="param-type">Promise</span>
 | 
						|
 | 
						|
 | 
						|
    </dd>
 | 
						|
</dl>
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
 | 
						|
 | 
						|
        
 | 
						|
            
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    <h4 class="name" id="tracking_revisions"><span class="type-signature"></span>tracking_revisions<span class="signature">(title, to_search, options<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Promise}</span></h4>
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<dl class="details">
 | 
						|
 | 
						|
    
 | 
						|
    <dt class="tag-source">Source:</dt>
 | 
						|
    <dd class="tag-source"><ul class="dummy"><li>
 | 
						|
        <a href="wikiapi.js.html">wikiapi.js</a>, <a href="wikiapi.js.html#line352">line 352</a>
 | 
						|
    </li></ul></dd>
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
</dl>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<div class="description usertext">
 | 
						|
    tracking revisions to lookup what revision had added / removed <code>to_search</code>.
 | 
						|
</div>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
    <h5>Parameters:</h5>
 | 
						|
    
 | 
						|
 | 
						|
<table class="params">
 | 
						|
    <thead>
 | 
						|
    <tr>
 | 
						|
        
 | 
						|
        <th>Name</th>
 | 
						|
        
 | 
						|
 | 
						|
        <th>Type</th>
 | 
						|
 | 
						|
        
 | 
						|
        <th>Attributes</th>
 | 
						|
        
 | 
						|
 | 
						|
        
 | 
						|
 | 
						|
        <th class="last">Description</th>
 | 
						|
    </tr>
 | 
						|
    </thead>
 | 
						|
 | 
						|
    <tbody>
 | 
						|
    
 | 
						|
 | 
						|
        <tr>
 | 
						|
            
 | 
						|
                <td class="name"><code>title</code></td>
 | 
						|
            
 | 
						|
 | 
						|
            <td class="type">
 | 
						|
            
 | 
						|
                
 | 
						|
<span class="param-type">String</span>
 | 
						|
 | 
						|
 | 
						|
            
 | 
						|
            </td>
 | 
						|
 | 
						|
            
 | 
						|
                <td class="attributes">
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
                </td>
 | 
						|
            
 | 
						|
 | 
						|
            
 | 
						|
 | 
						|
            <td class="description last">page title</td>
 | 
						|
        </tr>
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
        <tr>
 | 
						|
            
 | 
						|
                <td class="name"><code>to_search</code></td>
 | 
						|
            
 | 
						|
 | 
						|
            <td class="type">
 | 
						|
            
 | 
						|
                
 | 
						|
<span class="param-type">String</span>
 | 
						|
 | 
						|
 | 
						|
            
 | 
						|
            </td>
 | 
						|
 | 
						|
            
 | 
						|
                <td class="attributes">
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
                </td>
 | 
						|
            
 | 
						|
 | 
						|
            
 | 
						|
 | 
						|
            <td class="description last">filter / text to search. to_search(diff, revision, old_revision): `diff` 為從舊的版本 `old_revision` 改成 `revision` 時的差異。</td>
 | 
						|
        </tr>
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
        <tr>
 | 
						|
            
 | 
						|
                <td class="name"><code>options</code></td>
 | 
						|
            
 | 
						|
 | 
						|
            <td class="type">
 | 
						|
            
 | 
						|
                
 | 
						|
<span class="param-type">Object</span>
 | 
						|
 | 
						|
 | 
						|
            
 | 
						|
            </td>
 | 
						|
 | 
						|
            
 | 
						|
                <td class="attributes">
 | 
						|
                
 | 
						|
                    <optional><br>
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
 | 
						|
                
 | 
						|
                </td>
 | 
						|
            
 | 
						|
 | 
						|
            
 | 
						|
 | 
						|
            <td class="description last">options to run this function</td>
 | 
						|
        </tr>
 | 
						|
 | 
						|
    
 | 
						|
    </tbody>
 | 
						|
</table>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<h5>Returns:</h5>
 | 
						|
 | 
						|
        
 | 
						|
<div class="param-desc">
 | 
						|
    Promise object represents {Object} newer_revision,
 | 
						|
         newer_revision.page: page_data
 | 
						|
</div>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<dl class="param-type">
 | 
						|
    <dt>
 | 
						|
        Type
 | 
						|
    </dt>
 | 
						|
    <dd>
 | 
						|
        
 | 
						|
<span class="param-type">Promise</span>
 | 
						|
 | 
						|
 | 
						|
    </dd>
 | 
						|
</dl>
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
 | 
						|
 | 
						|
        
 | 
						|
            
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    <h4 class="name" id="upload"><span class="type-signature"></span>upload<span class="signature">(file_data)</span><span class="type-signature"> → {Promise}</span></h4>
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<dl class="details">
 | 
						|
 | 
						|
    
 | 
						|
    <dt class="tag-source">Source:</dt>
 | 
						|
    <dd class="tag-source"><ul class="dummy"><li>
 | 
						|
        <a href="wikiapi.js.html">wikiapi.js</a>, <a href="wikiapi.js.html#line1396">line 1396</a>
 | 
						|
    </li></ul></dd>
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
</dl>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<div class="description usertext">
 | 
						|
    Upload specified local file to the target wiki.
 | 
						|
</div>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
    <h5>Examples</h5>
 | 
						|
    
 | 
						|
        <p class="code-caption"><span id="example__Upload file / media">Upload file / media</span></p>
 | 
						|
    
 | 
						|
    <pre class="prettyprint"><code>// <code>
 | 
						|
const wiki = new Wikiapi;
 | 
						|
await wiki.login('user', 'password', 'test');
 | 
						|
// Upload a local file directly:
 | 
						|
//let result = await wiki.upload({ file_path: '/local/file/path', comment: '', text: '' || {description: '', ...} });
 | 
						|
let result = await wiki.upload({
 | 
						|
	file_path: '/local/file/path', comment: '',
 | 
						|
	filename: 'Will set via .file_path or .media_url if not settled.',
 | 
						|
	description: '', date: new Date() || '2021-01-01', source_url: 'https://github.com/kanasimi/wikiapi', author: '[[User:user]]', permission: '{{cc-by-sa-2.5}}', other_versions: '', other_fields: '',
 | 
						|
	license: ['{{cc-by-sa-2.5}}'], categories: ['[[Category:test images]]'],
 | 
						|
	bot: 1, tags: "tag1|tag2",
 | 
						|
	// To overwrite existing file
 | 
						|
	ignorewarnings: 1,
 | 
						|
});
 | 
						|
// Upload file from URL:
 | 
						|
result = await wiki.upload({ media_url: 'https://media.url/name.jpg', comment: '', text: '' });
 | 
						|
// </code></code></pre>
 | 
						|
 | 
						|
        <p class="code-caption">Upload file and then update content of file page</p>
 | 
						|
    
 | 
						|
    <pre class="prettyprint"><code>// <code>
 | 
						|
const wiki = new Wikiapi;
 | 
						|
await wiki.login('user', 'password', 'test');
 | 
						|
 | 
						|
const variable_Map = new CeL.wiki.Variable_Map();
 | 
						|
variable_Map.set('description', '...');
 | 
						|
//variable_Map.set('date', '...');
 | 
						|
// ...
 | 
						|
//variable_Map.set('other_fields', '...');
 | 
						|
 | 
						|
let result = await wiki.upload({
 | 
						|
	file_path: '/local/file/path',
 | 
						|
	// The <code>comment</code> will only show in the file page when updating file. It is read-only and cannot be modified.
 | 
						|
	comment: '',
 | 
						|
 | 
						|
	// <code>CeL.wiki.Variable_Map</code> is used to update content when update pages or files. It will insert comments around the value, prevent others from accidentally editing the text that will be overwritten.
 | 
						|
	// <code>description</code> till <code>other_fields</code> will be auto-setted as values assigned above.
 | 
						|
	// The code to do the conversion is in <code>wiki_API.upload</code> @ https://github.com/kanasimi/CeJS/blob/master/application/net/wiki/edit.js
 | 
						|
	// There are some examples: https://github.com/kanasimi/wikibot/blob/master/routine/20181016.import_earthquake_shakemap.js https://github.com/kanasimi/wikibot/blob/master/routine/20190629.import_hurricane_track_maps.js
 | 
						|
	// More examples to use <code>CeL.wiki.Variable_Map</code>: https://github.com/kanasimi/wikibot/blob/master/routine/20191129.check_language_convention.js
 | 
						|
	variable_Map,
 | 
						|
	// When set .variable_Map, after successful update, the content of file page will be auto-updated too.
 | 
						|
 | 
						|
	// To overwrite existing file
 | 
						|
	ignorewarnings: 1,
 | 
						|
});
 | 
						|
// </code></code></pre>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
    <h5>Parameters:</h5>
 | 
						|
    
 | 
						|
 | 
						|
<table class="params">
 | 
						|
    <thead>
 | 
						|
    <tr>
 | 
						|
        
 | 
						|
        <th>Name</th>
 | 
						|
        
 | 
						|
 | 
						|
        <th>Type</th>
 | 
						|
 | 
						|
        
 | 
						|
 | 
						|
        
 | 
						|
 | 
						|
        <th class="last">Description</th>
 | 
						|
    </tr>
 | 
						|
    </thead>
 | 
						|
 | 
						|
    <tbody>
 | 
						|
    
 | 
						|
 | 
						|
        <tr>
 | 
						|
            
 | 
						|
                <td class="name"><code>file_data</code></td>
 | 
						|
            
 | 
						|
 | 
						|
            <td class="type">
 | 
						|
            
 | 
						|
                
 | 
						|
<span class="param-type">Object</span>
 | 
						|
 | 
						|
 | 
						|
            
 | 
						|
            </td>
 | 
						|
 | 
						|
            
 | 
						|
 | 
						|
            
 | 
						|
 | 
						|
            <td class="description last">Upload configurations.<br />
 | 
						|
Warning: When you are update a file, only the file content will changed. The <code>comment</code> will only show in the file page. The <code>text</code>, ... till <code>categories</code> will <em>all ignored</em>. If you want to update the content of file page, please consider <code>Variable_Map</code> as mentioned in the sample code.<br />
 | 
						|
{<br />
 | 
						|
<ul>
 | 
						|
<li><code>file_path</code>: string - Local path.</li>
 | 
						|
<li><code>media_url</code>: string - URL path. Alternative to <code>file_path</code>.</li>
 | 
						|
<li><code>comment</code>: string - Upload comment.</li>
 | 
						|
 | 
						|
<li><code>text</code>: string or {Object} - Either {String}wikitext to fill the file's page,<br />
 | 
						|
 or {Object}parameters of <a href="https://commons.wikimedia.org/wiki/Template:Information" target="_blank">{{Information}}</a>:<br />
 | 
						|
{<br />
 | 
						|
<ul>
 | 
						|
<li><code>description</code>: string - File description.</li>
 | 
						|
<li><code>date</code>: date string - YYYY-MM-DD, e.g., <code>new Date()</code> || <code>'2021-01-01'</code>.</li>
 | 
						|
<li><code>source_url</code>: string - Source where the file comes from, typically an URL.</li>
 | 
						|
<li><code>author</code>: string - Author's name or username in wikicode, e.g., URL or <code>'[[User:Yoda|Yoda]]'</code>.</li>
 | 
						|
<li><code>permission</code>: string - License and other usage limitations and warnings, e.g., <code>'{{cc-by-sa-2.5}}'</code>.</li>
 | 
						|
<li><code>other_versions</code>: string - Wikicode links to files with very similar content or derived files.</li>
 | 
						|
<li><code>other_fields</code>: string - Additional table fields added on the bottom of the template.</li>
 | 
						|
</ul>
 | 
						|
}
 | 
						|
</li>
 | 
						|
 | 
						|
<li><code>license</code>: array of strings - License under which the file is uploaded, e.g., <code>['{{cc-by-sa-2.5}}']</code>.</li>
 | 
						|
<li><code>additional_text</code>: string - Additional wikitext to place before <code>categories</code>.</li>
 | 
						|
<li><code>categories</code>: array of strings - Categories for this file, e.g., <code>['[[Category:test images]]']</code>.</li>
 | 
						|
 | 
						|
<li><code>ignorewarnings</code>: boolean - Set to 1 will overwrite existing files.</li>
 | 
						|
</ul>
 | 
						|
}<br />
 | 
						|
<br />
 | 
						|
See <a href="https://github.com/kanasimi/CeJS/blob/master/application/net/wiki/edit.js" target="_blank">edit.js</a> and search for <q>file_data</q> for other <code>file_data</code> options.</td>
 | 
						|
        </tr>
 | 
						|
 | 
						|
    
 | 
						|
    </tbody>
 | 
						|
</table>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<h5>Returns:</h5>
 | 
						|
 | 
						|
        
 | 
						|
<div class="param-desc">
 | 
						|
    Promise object represents {String} result of MediaWiki API
 | 
						|
</div>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
<dl class="param-type">
 | 
						|
    <dt>
 | 
						|
        Type
 | 
						|
    </dt>
 | 
						|
    <dd>
 | 
						|
        
 | 
						|
<span class="param-type">Promise</span>
 | 
						|
 | 
						|
 | 
						|
    </dd>
 | 
						|
</dl>
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
 | 
						|
 | 
						|
        
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
</article>
 | 
						|
 | 
						|
</section>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
    
 | 
						|
    
 | 
						|
</div>
 | 
						|
 | 
						|
<br class="clear">
 | 
						|
 | 
						|
<footer>
 | 
						|
    Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.10</a> on Tue Sep 20 2022 04:45:46 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
 | 
						|
</footer>
 | 
						|
 | 
						|
<script>prettyPrint();</script>
 | 
						|
<script src="scripts/polyfill.js"></script>
 | 
						|
<script src="scripts/linenumber.js"></script>
 | 
						|
 | 
						|
 | 
						|
 | 
						|
</body>
 | 
						|
</html> |