icelist-sdk
v0.1.0
Published
JavaScript/TypeScript client library for the ICE List Wiki API
Maintainers
Readme
ICE List Wiki JavaScript/TypeScript SDK
JavaScript/TypeScript client library for the ICE List Wiki API.
Installation
npm install @icelist/sdk
# or
yarn add @icelist/sdkQuick Start
TypeScript
import { IceListClient } from "@icelist/sdk";
const client = new IceListClient();
// Search for content
const results = await client.search("Timothy Donahue");
results.forEach((result) => {
console.log(`${result.title}: ${result.snippet}`);
});
// Get a specific page
const page = await client.getPage("Main_Page");
console.log(page.title);
console.log(page.extract);
// Get full page content
const content = await client.getPageContent("Main_Page");
console.log(content.wikitext);
console.log(content.html);
// List category members
const agents = await client.getCategoryMembers("Agents", 50);
agents.forEach((agent) => {
console.log(agent.title);
});
// Get recent changes
const changes = await client.getRecentChanges(10);
changes.forEach((change) => {
console.log(`${change.title} - ${change.timestamp}`);
});JavaScript (CommonJS)
const { IceListClient } = require("@icelist/sdk");
const client = new IceListClient();
async function main() {
const results = await client.search("agents");
console.log(results);
}
main();Browser
<script type="module">
import { IceListClient } from "https://cdn.skypack.dev/@icelist/sdk";
const client = new IceListClient();
const results = await client.search("incidents");
console.log(results);
</script>API Reference
new IceListClient(options?)
Create a new client instance.
Options:
baseUrl?: string- Base URL of the wiki (default:https://wiki.icelist.is)userAgent?: string- Custom user agent stringtimeout?: number- Request timeout in milliseconds (default: 30000)
client.search(query, limit?): Promise<SearchResult[]>
Search for pages matching a query.
Returns: Array of search results with title, snippet, timestamp, etc.
client.getPage(title): Promise<PageInfo>
Get basic information about a page.
Returns: Page metadata including title, extract, and URL.
client.getPageContent(title): Promise<PageContent>
Get full page content in both wikitext and HTML.
Returns: Object with wikitext and rendered HTML.
client.getCategoryMembers(category, limit?, namespace?): Promise<CategoryMember[]>
List all pages in a category.
Returns: Array of pages in the category.
client.getRecentChanges(limit?): Promise<RecentChange[]>
Get recent changes to the wiki.
Returns: Array of recent changes with metadata.
Error Handling
import {
IceListClient,
IceListAPIError,
PageNotFoundError,
NetworkError,
InvalidParameterError,
} from "@icelist/sdk";
const client = new IceListClient();
try {
const page = await client.getPage("NonexistentPage");
} catch (error) {
if (error instanceof PageNotFoundError) {
console.log(`Page not found: ${error.title}`);
} else if (error instanceof IceListAPIError) {
console.log(`API error: ${error.code} - ${error.message}`);
}
}Development
# Install dependencies
npm install
# Build
npm run build
# Run tests
npm test
# Run tests with coverage
npm run test:coverage
# Lint
npm run lint
# Format
npm run formatRequirements
- Node.js 14+
- TypeScript 4+ (for TypeScript projects)
License
MIT License
