npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@elizaos/api-client

v1.6.5

Published

Type-safe API client for ElizaOS server

Readme

@elizaos/api-client

Type-safe API client for ElizaOS server.

Installation

bun add @elizaos/api-client

Usage

import { ElizaClient } from '@elizaos/api-client';

// Create client instance
const client = ElizaClient.create({
  baseUrl: 'http://localhost:3000',
  apiKey: 'your-api-key', // optional
});

// List all agents
const { agents } = await client.agents.listAgents();

// Create a new agent
const agent = await client.agents.createAgent({
  name: 'My Agent',
  description: 'A helpful assistant',
});

// Send a message
const message = await client.messaging.postMessage(channelId, 'Hello, world!');

// Create a session for user-agent conversation
const session = await client.sessions.createSession({
  agentId: agent.id,
  userId: 'user-123',
  metadata: { platform: 'web' },
});

// Send a message in the session
const sessionMessage = await client.sessions.sendMessage(session.sessionId, {
  content: 'Hello, agent!',
});

// Upload media
const upload = await client.media.uploadAgentMedia(agentId, {
  file: myFile,
  filename: 'image.png',
});

// Quick one-off message with automatic polling (Jobs API)
const response = await client.jobs.ask('user-123', 'What is Bitcoin?');
console.log('Agent response:', response);

API Domains

Agents

  • CRUD operations for agents
  • Agent lifecycle management (start/stop)
  • World management
  • Plugin panels and logs

Messaging

  • Message submission and management
  • Channel operations
  • Server management
  • Message search

Sessions

  • Create and manage user-agent conversation sessions
  • Send and retrieve messages within sessions
  • Session metadata and lifecycle management
  • Automatic cleanup of inactive sessions

Jobs

  • One-off messaging with automatic response handling
  • Simple request/response pattern for agent interactions
  • Automatic polling with customizable strategies
  • Job status tracking and health metrics

Example:

// Simple ask pattern - returns the response directly
const response = await client.jobs.ask('user-id', 'What is Bitcoin?');

// Create and poll manually for more control
const result = await client.jobs.createAndPoll({
  userId: 'user-id',
  content: 'Complex analysis query',
  agentId: 'specific-agent-id', // Optional
  timeoutMs: 60000, // Optional
});

if (result.success) {
  console.log('Response:', result.job.result?.message.content);
  console.log('Processing time:', result.job.result?.processingTimeMs, 'ms');
}

// Poll with exponential backoff for long-running queries
const backoffResult = await client.jobs.createAndPollWithBackoff({
  userId: 'user-id',
  content: 'Long running task',
}, {
  initialInterval: 500,
  maxInterval: 5000,
  multiplier: 1.5,
});

// Get job status manually
const job = await client.jobs.getJob('job-id');
console.log('Status:', job.status);

// List all jobs
const { jobs } = await client.jobs.list({ 
  status: JobStatus.COMPLETED,
  limit: 10 
});

// Check health metrics
const health = await client.jobs.health();
console.log('Success rate:', health.metrics.successRate);

Memory

  • Agent memory management
  • Room operations
  • World management

Audio

  • Speech processing
  • Text-to-speech
  • Audio transcription

Media

  • File uploads for agents and channels

Server

  • Health checks and status
  • Runtime debugging
  • Log management

System

  • Environment configuration

Error Handling

import { ApiError } from '@elizaos/api-client';

try {
  await client.agents.getAgent(agentId);
} catch (error) {
  if (error instanceof ApiError) {
    console.error(`Error ${error.code}: ${error.message}`);
    if (error.details) {
      console.error('Details:', error.details);
    }
  }
}

TypeScript Support

This package is written in TypeScript and provides full type definitions for all API endpoints, request parameters, and responses.