### Login to HuijiWiki Source: https://context7.com/yueecui/huijiwiki-api/llms.txt Provides examples for authenticating with a HuijiWiki site using username and password. It covers logging in with regular accounts, bot accounts, and handling login success or failure. ```typescript import { HuijiWiki } from 'huijiwiki-api'; const wiki = new HuijiWiki('danteng', 'your-auth-key'); // Login with regular account or bot account const success = await wiki.apiLogin('username', 'password'); if (success) { console.log('Login successful'); } else { const error = wiki.getLastErrorMessage(); console.error('Login failed:', error); } // Bot accounts use format: username@botname await wiki.apiLogin('User@BotName', 'bot-password'); ``` -------------------------------- ### Custom API Requests Source: https://context7.com/yueecui/huijiwiki-api/llms.txt Execute custom MediaWiki API requests using GET, POST, or an auto-detected method. ```APIDOC ## Custom API Requests ### Description Execute custom MediaWiki API requests. ### Method GET, POST, or auto-detected based on action. ### Endpoint `/api/v1/` (and other MediaWiki API endpoints) ### Parameters #### Path Parameters None #### Query Parameters - **action** (string) - Required - The API action to perform (e.g., 'query', 'parse'). - **meta** (string) - Optional - Metadata to query. - **siprop** (string) - Optional - Site info properties to retrieve. - **text** (string) - Required for 'parse' action - The text to parse. - **prop** (string) - Optional - Properties to retrieve for 'parse' action. - **list** (string) - Optional - Data list to query. - **rclimit** (number) - Optional - Limit for recent changes. #### Request Body Applicable for POST requests with complex data. ### Request Example ```typescript import { HuijiWiki } from 'huijiwiki-api'; const wiki = new HuijiWiki('your-wiki-prefix', 'your-auth-key'); // GET request const siteInfo = await wiki.get({ action: 'query', meta: 'siteinfo', siprop: 'general|namespaces' }); console.log('Wiki name:', siteInfo.query.general.sitename); // POST request const parseResult = await wiki.post({ action: 'parse', text: '{{Template:Example}}', prop: 'text' }); console.log('Parsed HTML:', parseResult.parse.text['*']); // Auto-detect method based on action const queryResult = await wiki.request({ action: 'query', list: 'recentchanges', rclimit: 10 }); queryResult.query.recentchanges.forEach(change => { console.log(`${change.title} by ${change.user}`); }); ``` ### Response #### Success Response (200) Response structure varies based on the API action performed. #### Response Example ```json { "query": { "general": { "sitename": "Example Wiki" }, "namespaces": {...} } } ``` ``` -------------------------------- ### Execute Custom MediaWiki API Requests Source: https://context7.com/yueecui/huijiwiki-api/llms.txt Perform custom GET, POST, or auto-detected API requests to a MediaWiki instance. Requires a HuijiWiki instance initialized with wiki prefix and auth key. Outputs are parsed JSON responses from the API. ```typescript import { HuijiWiki } from 'huijiwiki-api'; const wiki = new HuijiWiki('your-wiki-prefix', 'your-auth-key'); // GET request const siteInfo = await wiki.get({ action: 'query', meta: 'siteinfo', siprop: 'general|namespaces' }); console.log('Wiki name:', siteInfo.query.general.sitename); // POST request const parseResult = await wiki.post({ action: 'parse', text: '{{Template:Example}}', prop: 'text' }); console.log('Parsed HTML:', parseResult.parse.text['*']); // Auto-detect method based on action const queryResult = await wiki.request({ action: 'query', list: 'recentchanges', rclimit: 10 }); queryResult.query.recentchanges.forEach(change => { console.log(`${change.title} by ${change.user}`); }); ``` -------------------------------- ### Edit HuijiWiki Page Source: https://context7.com/yueecui/huijiwiki-api/llms.txt Illustrates how to create or update wiki page content using the HuijiWiki API. It includes examples for simple edits, edits with options like bot status and summaries, and handling edit errors. ```typescript import { HuijiWiki } from 'huijiwiki-api'; const wiki = new HuijiWiki('your-wiki-prefix', 'your-auth-key'); await wiki.apiLogin('username', 'password'); // Simple edit const result = await wiki.editPage('Page Title', 'Page content here'); if (result.error) { console.error('Edit failed:', result.error.info); } else { console.log('Edit successful:', result.edit); } // Edit with options await wiki.editPage('Page Title', 'Content', { isBot: true, summary: 'Updated page via API' }); // Non-bot edit with custom summary await wiki.editPage('User Page', 'My content', { isBot: false, summary: 'Manual update' }); ``` -------------------------------- ### Get HuijiWiki Page Content Source: https://context7.com/yueecui/huijiwiki-api/llms.txt Shows how to retrieve raw wikitext content from pages on a HuijiWiki site. It covers fetching a single page by title, multiple pages by titles, and a page by its unique ID. ```typescript import { HuijiWiki } from 'huijiwiki-api'; const wiki = new HuijiWiki('your-wiki-prefix', 'your-auth-key'); // Get single page by title const page = await wiki.getPageRawTextByTitle('Main Page'); if (page) { console.log('Page ID:', page.pageId); console.log('Page Title:', page.pageTitle); console.log('Content:', page.content); console.log('Content Model:', page.contentmodel); } else { console.log('Page not found'); } // Get multiple pages by titles const pages = await wiki.getPageRawTextByTitles(['Page1', 'Page2', 'Page3']); for (const title in pages) { console.log(`${title}: ${pages[title].content}`); } // Get page by ID const pageById = await wiki.getPageRawTextByPageId(12345); console.log(pageById.content); ``` -------------------------------- ### Initialize HuijiWiki Instance Source: https://context7.com/yueecui/huijiwiki-api/llms.txt Demonstrates how to create a new HuijiWiki instance for interacting with a specific wiki site. It shows basic initialization, options for logging and custom caching, and setting a custom user agent. ```typescript import { HuijiWiki, LOG_LEVEL } from 'huijiwiki-api'; // Basic initialization const wiki = new HuijiWiki('your-wiki-prefix', 'your-auth-key'); // With logging and custom cache const wikiWithOptions = new HuijiWiki('your-wiki-prefix', 'your-auth-key', { logLevel: LOG_LEVEL.INFO, cache: customCacheInstance // Optional custom cache implementation }); // Set custom user agent wiki.setUserAgent('MyBot/1.0.0'); ``` -------------------------------- ### Query HuijiWiki Pages by Namespace Source: https://context7.com/yueecui/huijiwiki-api/llms.txt Demonstrates how to list all pages within a specific namespace on a HuijiWiki site. It includes handling pagination for large numbers of pages and iterating through results. ```typescript import { HuijiWiki } from 'huijiwiki-api'; const wiki = new HuijiWiki('your-wiki-prefix', 'your-auth-key'); // Get pages from namespace 0 (main namespace) let continueToken = ''; const allPages = []; do { const result = await wiki.getPageListByNamespace(0, { limit: 500, continue: continueToken }); allPages.push(...result.pages); continueToken = result.continue; console.log(`Retrieved ${result.pages.length} pages`); } while (continueToken); console.log(`Total pages: ${allPages.length}`); allPages.forEach(page => { console.log(`- ${page.title} (ID: ${page.pageid})`); }); ``` -------------------------------- ### HuijiTabx - Import from Excel Source: https://context7.com/yueecui/huijiwiki-api/llms.txt Create HuijiTabx data from Excel files, automatically inferring data types. ```APIDOC ## HuijiTabx - Import from Excel ### Description Create HuijiTabx data from Excel files. Data types are automatically inferred from column headers. ### Method Static method `HuijiTabx.newFromXlsxFile`. ### Endpoint N/A (Client-side file processing) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```typescript import { HuijiTabx } from 'huijiwiki-api'; // Load from Excel file (automatically infers data types) const tabx = HuijiTabx.newFromXlsxFile( '/path/to/data.xlsx', 'Character stats database', 'https://example.com/source' ); console.log(`Loaded ${tabx.data.length} rows`); // Access typed data interface Character { Name: string; Level: number; Tags: string[]; // Array fields end with [] in Excel headers } const characters = tabx.data as Character[]; characters.forEach(char => { console.log(`${char.Name} - Level ${char.Level}`); console.log('Tags:', char.Tags.join(', ')); }); // Change main key if needed tabx.setMainKeyName('Name'); ``` ### Response #### Success Response (200) A `HuijiTabx` instance populated with data from the Excel file. #### Response Example ```typescript // Example of a HuijiTabx instance structure after loading from Excel { mainKeyName: 'Name', data: [ { Name: 'Character A', Level: 10, Tags: ['Melee'] }, { Name: 'Character B', Level: 15, Tags: ['Ranged', 'Magic'] } ], // ... other properties like schema, license, description, sources } ``` ``` -------------------------------- ### Local Cache Operations with HuijiWiki API (TypeScript) Source: https://context7.com/yueecui/huijiwiki-api/llms.txt Demonstrates using the HuijiWiki API's local cache for page content retrieval and edits. The cache is automatically populated when reading pages and managed during edit, delete, and move operations. It also shows how to compare content before editing to avoid redundant updates. ```typescript import { HuijiWiki } from 'huijiwiki-api'; const wiki = new HuijiWiki('your-wiki-prefix', 'your-auth-key'); // Cache is automatically populated when reading pages await wiki.getPageRawTextByTitle('Main Page'); // Compare content before editing to avoid unnecessary updates const newContent = 'Updated page content'; const hasChanged = !wiki.compareContent('Main Page', newContent); if (hasChanged) { await wiki.editPage('Main Page', newContent); console.log('Page updated'); } else { console.log('Content unchanged, skipping edit'); } // Cache is automatically managed during edit/delete/move operations await wiki.editPage('Page', 'Content'); // Updates cache await wiki.deletePage('Page'); // Removes from cache await wiki.movePage('Old', 'New'); // Updates cache keys ``` -------------------------------- ### HuijiTabx - Load Structured Data Source: https://context7.com/yueecui/huijiwiki-api/llms.txt Load and access structured tabular data from wiki pages or JSON objects using HuijiTabx. ```APIDOC ## HuijiTabx - Load Structured Data ### Description Work with tabular data in HuijiTabx format, loading from wiki pages or JSON. ### Method Static methods of the HuijiTabx class. ### Endpoint N/A (Client-side data manipulation) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **jsonData** (object) - Required for `newFromJson` - JSON object representing the tabular data. ### Request Example ```typescript import { HuijiTabx, HuijiWiki } from 'huijiwiki-api'; // Load from wiki page const wiki = new HuijiWiki('your-wiki-prefix', 'your-auth-key'); const tabx = await HuijiTabx.newFromWiki(wiki, 'Data:Characters'); console.log('Main key field:', tabx.mainKeyName); console.log('Total rows:', tabx.data.length); // Access data tabx.data.forEach(row => { console.log(row); }); // Get specific row by key const character = tabx.getRow('Kafka'); if (character) { console.log('Character found:', character); } // Load from JSON const jsonData = { license: 'CC0-1.0', schema: { fields: [ { name: 'id', type: 'string', title: { en: 'ID' } }, { name: 'name', type: 'string', title: { en: 'Name' } }, { name: 'level', type: 'number', title: { en: 'Level' } } ] }, data: [ ['001', 'Item A', 5], ['002', 'Item B', 10] ] }; const tabxFromJson = HuijiTabx.newFromJson(jsonData); ``` ### Response #### Success Response (200) A `HuijiTabx` instance containing the loaded data. #### Response Example ```typescript // Example of a HuijiTabx instance structure (internal representation) { mainKeyName: 'id', data: [ { id: '001', name: 'Item A', level: 5 }, { id: '002', name: 'Item B', level: 10 } ], // ... other properties like schema, license etc. } ``` ``` -------------------------------- ### Semantic MediaWiki Query Source: https://context7.com/yueecui/huijiwiki-api/llms.txt Execute Semantic MediaWiki (SMW) queries to retrieve structured data. Supports basic SMW syntax and complex property queries. ```APIDOC ## Semantic MediaWiki Query ### Description Execute SMW queries to retrieve structured data from the wiki. This allows for complex data filtering and retrieval based on semantic properties. ### Method GET (implied by library function) ### Endpoint Not directly exposed, accessed via library functions `getPageListBySMW` and `apiAsk`. ### Parameters #### Query Parameters for `getPageListBySMW` - **query** (string) - Required - The SMW query string (e.g., `[[Category:Characters]][[Level::>50]]`). - **options** (object) - Optional - Configuration for the query. - **limit** (number) - Maximum number of results to return. - **offset** (number) - Starting offset for results. #### Query Parameters for `apiAsk` - **query** (string) - Required - The SMW query string, potentially including property retrieval (e.g., `[[Category:Items]][[Rarity::5]]|?Name|?Description|?Price`). ### Request Example ```typescript // Basic SMW query const query = '[[Category:Characters]][[Level::>50]]'; const result = await wiki.getPageListBySMW(query, { limit: 100, offset: 0 }); // Complex SMW query with property retrieval const complexQuery = '[[Category:Items]][[Rarity::5]]|?Name|?Description|?Price'; const items = await wiki.apiAsk(complexQuery); ``` ### Response #### Success Response (200) for `getPageListBySMW` - **pages** (array) - An array of page objects, each containing `title` and `ns`. #### Success Response (200) for `apiAsk` - **query.results** (object) - An object where keys are page names and values are objects containing the requested properties and their values. #### Response Example for `getPageListBySMW` ```json { "pages": [ { "title": "Character X", "ns": 0 }, { "title": "Character Y", "ns": 0 } ] } ``` #### Response Example for `apiAsk` ```json { "query": { "results": { "Item Name 1": { "Name": "Example Item", "Description": "A sample item.", "Price": "100 coins" } } } } ``` ``` -------------------------------- ### Query Pages by Category Source: https://context7.com/yueecui/huijiwiki-api/llms.txt Retrieve all pages that belong to a specific category. Supports pagination and limiting results. ```APIDOC ## Query Pages by Category ### Description Retrieve all pages within a specific category. Supports pagination and limiting the number of results returned. ### Method GET (implied by library function) ### Endpoint Not directly exposed, accessed via library function `getPageListByCategory`. ### Parameters #### Query Parameters - **category** (string) - Required - The name of the category to query. - **options** (object) - Optional - Configuration for the query. - **limit** (number) - Maximum number of pages to return. - **continue** (string) - Continuation token for paginated results. ### Request Example ```typescript // Get first 500 pages in 'Characters' category const result = await wiki.getPageListByCategory('Characters', { limit: 500 }); // Paginated query for 'Items' category let token = ''; do { const batch = await wiki.getPageListByCategory('Items', { limit: 100, continue: token }); processBatch(batch.pages); token = batch.continue; } while (token); ``` ### Response #### Success Response (200) - **pages** (array) - An array of page objects, each containing `title` and `ns`. - **continue** (string) - Continuation token for paginated results, if more pages are available. #### Response Example ```json { "pages": [ { "title": "Character A", "ns": 0 }, { "title": "Character B", "ns": 0 } ], "continue": "token_for_next_page" } ``` ``` -------------------------------- ### Upload File to Wiki Source: https://context7.com/yueecui/huijiwiki-api/llms.txt Upload images or files to the wiki. Supports uploading from a file path or directly from a buffer. Requires authentication. Requires the 'huijiwiki-api' library. ```typescript import { HuijiWiki } from 'huijiwiki-api'; const wiki = new HuijiWiki('your-wiki-prefix', 'your-auth-key'); await wiki.apiLogin('username', 'password'); // Upload image from file path const result = await wiki.uploadImage( '/path/to/image.png', 'Filename.png', { comment: 'Uploaded via API', text: '[[Category:Images]]\nImage description here' } ); if (result.error) { if (result.error.code === 'fileexists-no-change') { console.log('File already exists with same content'); } else { console.error('Upload failed:', result.error.info); } } else { console.log('Upload successful:', result.upload.filename); } // Upload buffer directly import { readFileSync } from 'fs'; const buffer = readFileSync('/path/to/file.pdf'); await wiki.apiUpload(buffer, 'Document.pdf', { comment: 'Document upload', text: 'File description' }); ``` -------------------------------- ### HuijiTabx: Import Data from Excel Source: https://context7.com/yueecui/huijiwiki-api/llms.txt Create HuijiTabx data structures by importing from Excel files. The function automatically infers data types from the Excel file. Supports specifying a source URL for the Excel file. Allows typed access to imported data. ```typescript import { HuijiTabx } from 'huijiwiki-api'; // Load from Excel file (automatically infers data types) const tabx = HuijiTabx.newFromXlsxFile( '/path/to/data.xlsx', 'Character stats database', 'https://example.com/source' ); console.log(`Loaded ${tabx.data.length} rows`); // Access typed data interface Character { Name: string; Level: number; Tags: string[]; // Array fields end with [] in Excel headers } const characters = tabx.data as Character[]; characters.forEach(char => { console.log(`${char.Name} - Level ${char.Level}`); console.log('Tags:', char.Tags.join(', ')); }); // Change main key if needed tabx.setMainKeyName('Name'); ``` -------------------------------- ### Semantic MediaWiki Query Source: https://context7.com/yueecui/huijiwiki-api/llms.txt Execute SMW queries to retrieve structured data from the wiki. Supports basic and complex queries with property filtering and selection. Requires the 'huijiwiki-api' library. ```typescript import { HuijiWiki } from 'huijiwiki-api'; const wiki = new HuijiWiki('your-wiki-prefix', 'your-auth-key'); // Query with SMW syntax const query = '[[Category:Characters]][[Level::>50]]'; const result = await wiki.getPageListBySMW(query, { limit: 100, offset: 0 }); console.log(`Found ${result.pages.length} pages`); result.pages.forEach(page => { console.log(`${page.title} (namespace: ${page.ns})`); }); // Complex SMW query with properties const complexQuery = '[[Category:Items]][[Rarity::5]]|?Name|?Description|?Price'; const items = await wiki.apiAsk(complexQuery); for (const resultSet of items.query.results) { for (const pageName in resultSet) { console.log('Item:', pageName); console.log('Data:', resultSet[pageName]); } } ``` -------------------------------- ### Upload File Source: https://context7.com/yueecui/huijiwiki-api/llms.txt Upload images or other files to the wiki. Supports uploading from a file path or a buffer. ```APIDOC ## Upload File ### Description Upload images or files to the wiki. The API supports uploading from a local file path or directly from a data buffer. Includes options for file comments and wiki text. ### Method POST (implied by library function) ### Endpoint Not directly exposed, accessed via library functions `uploadImage` and `apiUpload`. ### Parameters #### Parameters for `uploadImage` - **filePath** (string) - Required - The local path to the file to upload. - **fileName** (string) - Required - The desired name for the file on the wiki. - **options** (object) - Optional - Additional upload parameters. - **comment** (string) - A brief description of the upload. - **text** (string) - Wiki text to be saved with the file (e.g., categories, description). #### Parameters for `apiUpload` - **buffer** (Buffer) - Required - The file content as a Buffer. - **fileName** (string) - Required - The desired name for the file on the wiki. - **options** (object) - Optional - Additional upload parameters (same as above). ### Request Example ```typescript // Upload from file path const result = await wiki.uploadImage( '/path/to/image.png', 'Filename.png', { comment: 'Uploaded via API', text: '[[Category:Images]]' } ); // Upload from buffer import { readFileSync } from 'fs'; const buffer = readFileSync('/path/to/file.pdf'); await wiki.apiUpload(buffer, 'Document.pdf', { comment: 'Document upload' }); ``` ### Response #### Success Response (200) - **upload.filename** (string) - The name of the uploaded file. #### Error Response - **error.code** (string) - Error code (e.g., 'fileexists-no-change'). - **error.info** (string) - Detailed error message. #### Response Example (Success) ```json { "upload": { "filename": "Filename.png" } } ``` #### Response Example (File Exists) ```json { "error": { "code": "fileexists-no-change", "info": "File "Filename.png" already exists and is the same as the uploaded file." } } ``` ``` -------------------------------- ### HuijiTabx: Load Structured Data from Wiki or JSON Source: https://context7.com/yueecui/huijiwiki-api/llms.txt Load and interact with tabular data in HuijiTabx format. Data can be loaded from a wiki page using a HuijiWiki instance or directly from a JSON object. Provides access to data rows, main key field, and individual rows by key. ```typescript import { HuijiTabx, HuijiWiki } from 'huijiwiki-api'; // Load from wiki page const wiki = new HuijiWiki('your-wiki-prefix', 'your-auth-key'); const tabx = await HuijiTabx.newFromWiki(wiki, 'Data:Characters'); console.log('Main key field:', tabx.mainKeyName); console.log('Total rows:', tabx.data.length); // Access data tabx.data.forEach(row => { console.log(row); }); // Get specific row by key const character = tabx.getRow('Kafka'); if (character) { console.log('Character found:', character); } // Load from JSON const jsonData = { license: 'CC0-1.0', schema: { fields: [ { name: 'id', type: 'string', title: { en: 'ID' } }, { name: 'name', type: 'string', title: { en: 'Name' } }, { name: 'level', type: 'number', title: { en: 'Level' } } ] }, data: [ ['001', 'Item A', 5], ['002', 'Item B', 10] ] }; const tabxFromJson = HuijiTabx.newFromJson(jsonData); ``` -------------------------------- ### Query Pages by Category Source: https://context7.com/yueecui/huijiwiki-api/llms.txt Retrieve all pages within a specific category. Supports pagination for large category member lists. Requires the 'huijiwiki-api' library. ```typescript import { HuijiWiki } from 'huijiwiki-api'; const wiki = new HuijiWiki('your-wiki-prefix', 'your-auth-key'); // Get category members const result = await wiki.getPageListByCategory('Characters', { limit: 500 }); result.pages.forEach(page => { console.log(`${page.title} (ns: ${page.ns})`); }); // Paginated category query let token = ''; do { const batch = await wiki.getPageListByCategory('Items', { limit: 100, continue: token }); processBatch(batch.pages); token = batch.continue; } while (token); ``` -------------------------------- ### Move Pages Source: https://context7.com/yueecui/huijiwiki-api/llms.txt Rename or move wiki pages to a new title. Supports moving associated talk pages and subpages. ```APIDOC ## Move Pages ### Description Rename wiki pages by moving them to a new title. This operation can optionally include moving the associated talk page, all subpages, and control whether a redirect is created at the old title. ### Method POST (implied by library function) ### Endpoint Not directly exposed, accessed via library function `movePage`. ### Parameters #### Parameters for `movePage` - **fromTitle** (string) - Required - The current title of the page to move. - **toTitle** (string) - Required - The new title for the page. - **options** (object) - Optional - Additional move parameters. - **reason** (string) - The reason for the move, recorded in logs. - **movetalk** (boolean) - If true, move the associated talk page as well. - **movesubpages** (boolean) - If true, move all subpages of the current page. - **noredirect** (boolean) - If true, do not create a redirect page at the old title. ### Request Example ```typescript // Simple page move const result = await wiki.movePage('Old Title', 'New Title', { reason: 'Renaming' }); // Move with options await wiki.movePage('Old Title', 'New Title', { reason: 'Reorganizing', movetalk: true, movesubpages: true, noredirect: true }); ``` ### Response #### Success Response (200) - **move.from** (string) - The original title of the page. - **move.to** (string) - The new title of the page. #### Error Response - **error.code** (string) - Error code. - **error.info** (string) - Detailed error message. #### Response Example (Success) ```json { "move": { "from": "Old Title", "to": "New Title" } } ``` ``` -------------------------------- ### HuijiTabx - Export Data Source: https://context7.com/yueecui/huijiwiki-api/llms.txt Export HuijiTabx data to various formats including Excel, raw JSON, and directly to a wiki page. ```APIDOC ## HuijiTabx - Export Data ### Description Export tabular data managed by HuijiTabx to different formats such as Excel, raw HuijiTabx JSON, or save directly to a wiki page. ### Method Instance methods of a `HuijiTabx` object. ### Endpoint N/A (Client-side file/API operations) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```typescript import { HuijiTabx } from 'huijiwiki-api'; const tabx = HuijiTabx.newFromXlsxFile('/path/to/input.xlsx'); // Export back to Excel with autofilter tabx.saveAsXlsx('/path/to/output.xlsx'); // Export as raw HuijiTabx JSON format const rawData = tabx.exportRaw(); console.log('License:', rawData.license); console.log('Description:', rawData.description.en); console.log('Fields:', rawData.schema.fields); console.log('Data rows:', rawData.data.length); // Save to wiki import { HuijiWiki } from 'huijiwiki-api'; const wiki = new HuijiWiki('your-wiki-prefix', 'your-auth-key'); await wiki.apiLogin('username', 'password'); const jsonString = JSON.stringify(rawData, null, 2); await wiki.editPage('Data:Characters', jsonString, { summary: 'Updated character data via API' }); ``` ### Response #### Success Response (200) - **saveAsXlsx**: Void (saves file to disk). - **exportRaw**: Object (HuijiTabx JSON structure). - **editPage** (via HuijiWiki): Void (or API response from wiki edit). #### Response Example ```json // Example of rawData from exportRaw(): { "license": "CC0-1.0", "schema": { "fields": [ { "name": "Name", "type": "string", "title": { "en": "Name" } }, { "name": "Level", "type": "number", "title": { "en": "Level" } } ] }, "data": [ ["Character A", 10], ["Character B", 15] ], "description": {"en": "Character data"}, "sources": ["https://example.com/source"] } ``` ``` -------------------------------- ### Delete and Undelete Pages Source: https://context7.com/yueecui/huijiwiki-api/llms.txt Remove wiki pages permanently or restore previously deleted pages. Requires appropriate permissions. ```APIDOC ## Delete and Undelete Pages ### Description Allows for the deletion of wiki pages and the restoration of pages that have been previously deleted. These operations typically require administrative privileges. ### Method POST (implied by library function) ### Endpoint Not directly exposed, accessed via library functions `deletePage` and `undeletePage`. ### Parameters #### Parameters for `deletePage` - **title** (string) - Required - The title of the page to delete. - **reason** (string) - Optional - The reason for deleting the page, which will be recorded in the logs. #### Parameters for `undeletePage` - **title** (string) - Required - The title of the page to undelete. - **reason** (string) - Optional - The reason for restoring the page. ### Request Example ```typescript // Delete a page const deleteResult = await wiki.deletePage('Page to Delete', 'Reason for deletion'); // Undelete a page const undeleteResult = await wiki.undeletePage('Deleted Page', 'Restore reason'); ``` ### Response #### Success Response (200) for `deletePage` - **delete.title** (string) - The title of the deleted page. #### Success Response (200) for `undeletePage` - **undelete.title** (string) - The title of the restored page. - **undelete.revisions** (array) - An array of restored revision IDs. #### Error Response - **error.code** (string) - Error code. - **error.info** (string) - Detailed error message. #### Response Example (Delete Success) ```json { "delete": { "title": "Page to Delete" } } ``` #### Response Example (Undelete Success) ```json { "undelete": { "title": "Deleted Page", "revisions": [12345, 12346] } } ``` ``` -------------------------------- ### Move Wiki Pages Source: https://context7.com/yueecui/huijiwiki-api/llms.txt Rename or move wiki pages to different titles. Supports moving talk pages and subpages, and controlling redirect creation. Requires authentication. Requires the 'huijiwiki-api' library. ```typescript import { HuijiWiki } from 'huijiwiki-api'; const wiki = new HuijiWiki('your-wiki-prefix', 'your-auth-key'); await wiki.apiLogin('username', 'password'); // Simple move const result = await wiki.movePage('Old Title', 'New Title', { reason: 'Renaming for clarity' }); if (result.error) { console.error('Move failed:', result.error.info); } else { console.log('Moved from:', result.move.from); console.log('Moved to:', result.move.to); } // Move with options await wiki.movePage('Old Title', 'New Title', { reason: 'Reorganizing namespace', movetalk: true, // Also move talk page movesubpages: true, // Move all subpages noredirect: true // Don't create redirect at old title }); ``` -------------------------------- ### HuijiTabx: Export Data to Excel, JSON, or Wiki Source: https://context7.com/yueecui/huijiwiki-api/llms.txt Export HuijiTabx data into various formats, including Excel files with autofilter, raw HuijiTabx JSON, or directly to a wiki page. Requires appropriate authentication for saving to a wiki. ```typescript import { HuijiTabx } from 'huijiwiki-api'; const tabx = HuijiTabx.newFromXlsxFile('/path/to/input.xlsx'); // Export back to Excel with autofilter tabx.saveAsXlsx('/path/to/output.xlsx'); // Export as raw HuijiTabx JSON format const rawData = tabx.exportRaw(); console.log('License:', rawData.license); console.log('Description:', rawData.description.en); console.log('Fields:', rawData.schema.fields); console.log('Data rows:', rawData.data.length); // Save to wiki import { HuijiWiki } from 'huijiwiki-api'; const wiki = new HuijiWiki('your-wiki-prefix', 'your-auth-key'); await wiki.apiLogin('username', 'password'); const jsonString = JSON.stringify(rawData, null, 2); await wiki.editPage('Data:Characters', jsonString, { summary: 'Updated character data via API' }); ``` -------------------------------- ### Purge Page Cache Source: https://context7.com/yueecui/huijiwiki-api/llms.txt Clear the cache for one or more wiki pages to ensure the latest content is displayed. Can target pages by title or ID. ```APIDOC ## Purge Page Cache ### Description Clear the server-side cache for specified wiki pages. This forces the wiki to re-render the pages from their source content, ensuring that any recent edits are reflected immediately. ### Method POST (implied by library function) ### Endpoint Not directly exposed, accessed via library functions `purgePage` and `apiPurge`. ### Parameters #### Parameters for `purgePage` - **titles** (array of strings) - Required - An array of page titles to purge. #### Parameters for `apiPurge` - **options** (object) - Required - Configuration for purging. - **pageids** (array of numbers) - Purge pages by their IDs. - **titles** (array of strings) - Purge pages by their titles. - **namespaces** (array of numbers) - Purge all pages within specified namespaces. ### Request Example ```typescript // Purge pages by title const result = await wiki.purgePage(['Main Page', 'Template:Infobox']); // Purge pages by ID await wiki.apiPurge({ pageids: [123, 456] }); ``` ### Response #### Success Response (200) - **purge** (array) - An array of objects, each indicating a successfully purged page with its `title` and `ns`. #### Error Response - **error.code** (string) - Error code. - **error.info** (string) - Detailed error message. #### Response Example (Success) ```json { "purge": [ { "title": "Main Page", "ns": 0 }, { "title": "Template:Infobox", "ns": 10 } ] } ``` ``` -------------------------------- ### Delete and Undelete Wiki Pages Source: https://context7.com/yueecui/huijiwiki-api/llms.txt Remove wiki pages from the wiki or restore previously deleted pages. Requires administrative privileges for deletion. Requires the 'huijiwiki-api' library. ```typescript import { HuijiWiki } from 'huijiwiki-api'; const wiki = new HuijiWiki('your-wiki-prefix', 'your-auth-key'); await wiki.apiLogin('admin-username', 'admin-password'); // Delete a page const deleteResult = await wiki.deletePage('Page to Delete', 'Reason for deletion'); if (deleteResult.error) { console.error('Delete failed:', deleteResult.error.info); } else { console.log('Deleted:', deleteResult.delete.title); } // Undelete a page const undeleteResult = await wiki.undeletePage('Deleted Page', 'Restore reason'); if (undeleteResult.error) { console.error('Undelete failed:', undeleteResult.error.info); } else { console.log('Restored:', undeleteResult.undelete.title); console.log('Revisions restored:', undeleteResult.undelete.revisions); } ``` -------------------------------- ### Purge Wiki Page Cache Source: https://context7.com/yueecui/huijiwiki-api/llms.txt Clear the cache for one or more wiki pages to force re-rendering. Can purge pages by title or by page ID. Requires the 'huijiwiki-api' library. ```typescript import { HuijiWiki } from 'huijiwiki-api'; const wiki = new HuijiWiki('your-wiki-prefix', 'your-auth-key'); // Purge single or multiple pages const result = await wiki.purgePage(['Main Page', 'Template:Infobox', 'Help:Contents']); if (result.error) { console.error('Purge failed:', result.error.info); } else { result.purge.forEach(page => { console.log(`Purged: ${page.title} (ns: ${page.ns})`); }); } // Purge by page IDs await wiki.apiPurge({ pageids: [123, 456, 789] }); ``` -------------------------------- ### HuijiTabx - Modify Data Source: https://context7.com/yueecui/huijiwiki-api/llms.txt Add, update, and delete rows in HuijiTabx data, and modify metadata like description and sources. ```APIDOC ## HuijiTabx - Modify Data ### Description Add, update, and delete rows in tabular data managed by HuijiTabx. Also allows setting metadata like description and sources. ### Method Instance methods of a `HuijiTabx` object. ### Endpoint N/A (Client-side data manipulation) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```typescript import { HuijiTabx } from 'huijiwiki-api'; const tabx = HuijiTabx.newFromXlsxFile('/path/to/data.xlsx'); // Add new row const newRow = { ID: '005', Name: 'New Character', Level: 80, Tags: ['Fire', 'DPS'] }; if (tabx.addRow(newRow)) { console.log('Row added successfully'); } // Update existing row const updatedRow = { ID: '005', Name: 'New Character', Level: 90, // Level increased Tags: ['Fire', 'DPS', 'Elite'] }; if (tabx.updateRow('005', updatedRow)) { console.log('Row updated successfully'); } // Delete row if (tabx.deleteRow('005')) { console.log('Row deleted successfully'); } // Set metadata tabx.setDesciption('Updated character database'); tabx.setSources('https://example.com/v2/source'); ``` ### Response #### Success Response (200) Boolean indicating success for add, update, and delete operations. Metadata changes are typically void. #### Response Example ```json // For addRow, updateRow, deleteRow: true ``` ``` -------------------------------- ### HuijiTabx: Modify Tabular Data Source: https://context7.com/yueecui/huijiwiki-api/llms.txt Modify HuijiTabx data by adding, updating, or deleting rows. Rows can be added with new data, updated with modified data using a row identifier, or deleted. Metadata like description and sources can also be set. ```typescript import { HuijiTabx } from 'huijiwiki-api'; const tabx = HuijiTabx.newFromXlsxFile('/path/to/data.xlsx'); // Add new row const newRow = { ID: '005', Name: 'New Character', Level: 80, Tags: ['Fire', 'DPS'] }; if (tabx.addRow(newRow)) { console.log('Row added successfully'); } // Update existing row const updatedRow = { ID: '005', Name: 'New Character', Level: 90, // Level increased Tags: ['Fire', 'DPS', 'Elite'] }; if (tabx.updateRow('005', updatedRow)) { console.log('Row updated successfully'); } // Delete row if (tabx.deleteRow('005')) { console.log('Row deleted successfully'); } // Set metadata tabx.setDesciption('Updated character database'); tabx.setSources('https://example.com/v2/source'); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.