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 🙏

© 2026 – Pkg Stats / Ryan Hefner

agentindex-sdk

v1.0.1

Published

Official SDK for Agent Index - The discovery layer for x402 AI agents

Readme

agentindex-sdk

The official SDK for Agent Index — the discovery layer for x402 AI agents.

npm version TypeScript

Installation

npm install agentindex-sdk
# or
yarn add agentindex-sdk
# or
pnpm add agentindex-sdk

Quick Start

import { AgentIndex } from '@agentindex/sdk';

const client = new AgentIndex();

// Search for crypto price agents
const results = await client.search({ query: 'crypto price' });
console.log(results.results);

// Get trending agents
const trending = await client.trending();
console.log(trending.trending);

API Reference

Constructor

const client = new AgentIndex({
  baseUrl: 'https://api.theagentindex.app', // default
  timeout: 10000, // default, in milliseconds
});

Methods

search(options) — Search for agents

const results = await client.search({
  query: 'weather forecast',      // required
  category: 'weather',            // optional: crypto, defi, ai, weather, news, oracle
  maxPrice: 0.05,                 // optional: max USD per call
  limit: 20,                      // optional: default 10, max 50
});

// Returns: { count: number, results: Agent[] }

trending() — Get trending agents

const trending = await client.trending();
// Returns: { trending: Agent[], period: string }

health() — Check API status

const health = await client.health();
// Returns: { status: 'ok' | 'degraded' | 'down', timestamp: string }

recommend(options) — AI-powered recommendations

Premium endpoint — requires x402 payment ($0.005/call)

const recommendations = await client.recommend({
  useCase: 'I need real-time crypto prices for my trading bot',
  maxPrice: 0.02,
  limit: 5,
});

analytics(options) — Endpoint analytics

Premium endpoint — requires x402 payment ($0.01/call)

const analytics = await client.analytics({
  target: 'crypto',       // category or agent ID
  period: '7d',           // 24h, 7d, or 30d
});

// Returns: { totalCalls, uniqueCallers, revenue, topEndpoints, period }

Types

interface Agent {
  id: string;
  url: string;
  domain: string;
  description: string;
  priceUsd: number;
  category: string;
  health: 'healthy' | 'degraded' | 'down' | 'unknown';
  tier: 'A' | 'B' | 'C' | 'D';
  score: number;
  metadata?: Record<string, unknown>;
}

Framework Integrations

LangChain

import { AgentIndex, createLangChainTool } from '@agentindex/sdk';

// Create a tool for your LangChain agent
const tool = createLangChainTool();

// Use in your agent
const tools = [tool];

Quick Search Helper

import { searchAgents } from '@agentindex/sdk';

// One-liner search
const agents = await searchAgents('crypto prices', { category: 'defi' });

MCP Server

For Claude, Cursor, and other MCP-compatible clients:

npm install -g agent-index-mcp

Add to Claude Desktop config:

{
  "mcpServers": {
    "agent-index": {
      "command": "npx",
      "args": ["agent-index-mcp"]
    }
  }
}

Then ask Claude: "Search Agent Index for weather APIs"

Examples

Find the cheapest crypto price API

import { AgentIndex } from '@agentindex/sdk';

const client = new AgentIndex();

const results = await client.search({
  query: 'crypto price',
  category: 'crypto',
  maxPrice: 0.01,
  limit: 10,
});

// Sort by price
const cheapest = results.results.sort((a, b) => a.priceUsd - b.priceUsd);
console.log(`Cheapest: ${cheapest[0].url} at $${cheapest[0].priceUsd}/call`);

Filter by health status

const results = await client.search({ query: 'weather' });

const healthy = results.results.filter(a => a.health === 'healthy');
console.log(`${healthy.length} healthy agents found`);

Build an agent that finds and uses other agents

import { AgentIndex } from '@agentindex/sdk';

async function findBestAgent(capability: string) {
  const client = new AgentIndex();
  
  const results = await client.search({ query: capability, limit: 5 });
  
  // Pick the best one (highest score + healthy)
  const best = results.results
    .filter(a => a.health === 'healthy')
    .sort((a, b) => b.score - a.score)[0];
  
  if (!best) throw new Error(`No healthy agent found for: ${capability}`);
  
  return best;
}

// Your AI agent can now dynamically find tools
const weatherAgent = await findBestAgent('weather forecast');
console.log(`Using: ${weatherAgent.url}`);

Error Handling

import { AgentIndex, AgentIndexError } from '@agentindex/sdk';

const client = new AgentIndex();

try {
  const results = await client.search({ query: 'test' });
} catch (error) {
  if (error instanceof AgentIndexError) {
    console.error(`API Error: ${error.message}`);
    console.error(`Status: ${error.statusCode}`);
  }
}

Rate Limits

  • Free tier: 100 requests/minute
  • Premium endpoints: Unlimited (pay-per-call via x402)

For higher limits, contact us or use premium endpoints.

Support

License

MIT © 402 Agent Inc