Skip to content

Wiki Plugin

The Wiki Plugin enables your agent to retrieve blockchain knowledge from IQ.Wiki

Installation

Terminal window
npm i @iqai/agent @iqai/plugin-wiki

Basic Setup

Here’s a complete example of setting up an agent with the Wiki plugin:

import { AgentBuilder, ModelProviderName } from "@iqai/agent";
import { createWikiPlugin } from "@iqai/plugin-wiki";
async function main() {
// Initialize Wiki plugin
const wikiPlugin = await createWikiPlugin();
// Create agent with plugin
const agent = new AgentBuilder()
.withModelProvider(
ModelProviderName.OPENAI,
process.env.OPENAI_API_KEY
)
.withPlugin(wikiPlugin)
.build();
await agent.start();
}
main().catch(console.error);

Available Operations

  • Wiki Retrieval: Get specific wiki articles by ID
  • Latest User Wiki: Get latest wiki created by user
  • Time-Filtered User Wikis: Get wikis created by user ID within a time range

Usage Examples

OperationExample Query
Get WikiShow me the wiki for bitcoin
Latest User WikiGet latest wiki of user 0x8AF7a19a26d8FBC48dEfB35AEfb15Ec8c407f889
Latest User Wiki (added timeframe)Get wiki of user 0x8AF7a19a26d8FBC48dEfB35AEfb15Ec8c407f889 in last 24 hours

Getting a wiki

Query:

Get me wiki on ai meme hub

The agent will process this to:

{
"id": "ai-meme-hub",
}

Getting latest user wiki

Query:

Get me latest wiki by 0x9130241234123434

The agent will process this to:

{
"id": "0x9130241234123434"
}

Getting time-filtered user wikis

Query:

Get me wikis by 0x9130241234123434 in last 24 hours

The agent will process this to:

{
"id": "0x9130241234123434",
"timeFrameSeconds": "86400"
}

Error Handling

Always implement proper error handling when using the plugin:

try {
const wikiPlugin = await createWikiPlugin();
} catch (error) {
console.error('Failed to initialize Wiki plugin:', error);
}

Best Practices

βœ” ID Validation: Ensure wiki IDs are correctly formatted βœ” User Address Format: Use complete Ethereum addresses βœ” Time Filtering: Specify clear time periods for filtered results βœ” Error Handling: Implement robust error handling for all operations

Common Issues and Troubleshooting

  • Wiki Not Found: Verify the wiki ID exists on IQ.Wiki
  • User Not Found: Ensure the Ethereum address is correct
  • No Recent Wikis: The user may not have created wikis in the specified time period
  • API Connection: Check your network connection if requests fail