Skip to main content

Installation

npm install @xpoz/xpoz
Requires Node.js 18+.

Get an Access Key

Sign up and get your token at xpoz.ai/get-token.

Create a Client

import { XpozClient } from "@xpoz/xpoz";

// Pass access key directly
const client = new XpozClient({ apiKey: "your-api-key" });
await client.connect();

// Or use the XPOZ_API_KEY environment variable
const client = new XpozClient();
await client.connect();

Configuration Options

OptionTypeDefaultDescription
apiKeystringprocess.env.XPOZ_API_KEYAccess key for authentication
serverUrlstringhttps://mcp.xpoz.ai/mcpMCP server URL
timeoutMsnumber300000Operation timeout in milliseconds
const client = new XpozClient({
  apiKey: "your-api-key",
  serverUrl: "https://mcp.xpoz.ai/mcp",
  timeoutMs: 600_000, // 10 minutes
});
await client.connect();

Your First Call

import { XpozClient } from "@xpoz/xpoz";

const client = new XpozClient({ apiKey: "your-api-key" });
await client.connect();

// Get a Twitter user profile
const user = await client.twitter.getUser("elonmusk");
console.log(`${user.name}${user.followersCount?.toLocaleString()} followers`);

// Search for posts
const results = await client.twitter.searchPosts("artificial intelligence", {
  startDate: "2025-01-01",
});
for (const post of results.data) {
  console.log(post.text, post.likeCount);
}

await client.close();

Connection Lifecycle

You must call connect() before making any calls and close() when done.

Manual connect/close

const client = new XpozClient({ apiKey: "your-api-key" });
await client.connect();
try {
  const results = await client.twitter.searchPosts("AI");
} finally {
  await client.close();
}
With TypeScript 5.2+ or Node.js 18.2+ (with --experimental-vm-modules), you can use Symbol.asyncDispose to auto-close the client:
await using client = new XpozClient({ apiKey: "your-api-key" });
await client.connect();

const user = await client.twitter.getUser("elonmusk");
// client.close() is called automatically when the block exits

Field Selection

All methods accept a fields option. Requesting fewer fields significantly improves response time.
const results = await client.twitter.searchPosts("AI", {
  fields: ["id", "text", "likeCount", "retweetCount", "createdAtDate"],
});

const user = await client.twitter.getUser("elonmusk", {
  fields: ["id", "username", "name", "followersCount", "description"],
});
Use fields to request only the data you need. This reduces response time and memory usage, especially for large result sets.

Query Syntax

The query parameter on searchPosts, getUsersByKeywords, and similar methods supports Lucene-style full-text search:
// Exact phrase
await client.twitter.searchPosts('"machine learning"');

// Boolean operators
await client.twitter.searchPosts('"deep learning" AND python');
await client.twitter.searchPosts("tensorflow OR pytorch");
await client.twitter.searchPosts("climate AND policy");

// Grouping
await client.twitter.searchPosts('(AI OR "artificial intelligence") AND ethics');
Do not use from:, lang:, since:, or until: in the query string. Use the dedicated parameters (authorUsername, language, startDate, endDate) instead.

Environment Variables

VariableDescriptionDefault
XPOZ_API_KEYAccess key for authentication
XPOZ_SERVER_URLMCP server URLhttps://mcp.xpoz.ai/mcp

Next Steps