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

keirolabs

v0.1.4

Published

Official JavaScript SDK for KeiroLabs API - Search, Research, and Web Crawling

Downloads

32

Readme

KeiroLabs JavaScript SDK


Installation

npm install keirolabs

Requirements: Node.js >= 14.0.0


Quick Start

const { Keiro } = require('keirolabs');

const client = new Keiro("your-api-key");

async function main() {
  // Search
  const result = await client.search("machine learning trends 2024");
  console.log(result.data);
  console.log(`Credits remaining: ${result.creditsRemaining}`);
}

main();

Get your API key: https://www.keirolabs.cloud/


TypeScript Support

Full TypeScript support with type definitions included:

import { Keiro, SearchResult, KeiroAuthError } from 'keirolabs';

const client = new Keiro(process.env.KEIRO_API_KEY!);

const result: SearchResult = await client.search("TypeScript best practices");

API Methods

| Method | Description | Credits | |--------|-------------|---------| | search(query) | Neural search | 1 | | searchPro(query) | Advanced search | Variable | | searchEngine(query) | Search engine | Variable | | answer(query) | AI-powered answers | 5 | | research(query) | Topic research | Variable | | researchPro(query) | Advanced research | Variable | | webCrawler(url) | Extract web data | Variable | | healthCheck() | Server status | Free | | validateApiKey() | Key validation | Free |


Usage Examples

Basic Search

const result = await client.search("Python best practices");

console.log(`Found ${result.data.length} results`);
console.log(`Credits: ${result.creditsRemaining}`);

result.data.forEach(item => {
  console.log(item.title);
  console.log(item.url);
});

Generate Answers

const answer = await client.answer("What is reinforcement learning?");
console.log(answer.data);
console.log(`Credits: ${answer.creditsRemaining}`);

Research Topics

const research = await client.research("climate change solutions");
console.log(research.data);

Web Crawler

const data = await client.webCrawler("https://example.com/article");
console.log(data.data.content);
console.log(data.data.title);

Error Handling

const { 
  Keiro, 
  KeiroAuthError, 
  KeiroRateLimitError,
  KeiroValidationError,
  KeiroConnectionError 
} = require('keirolabs');

const client = new Keiro(process.env.KEIRO_API_KEY);

try {
  const result = await client.search("query");
} catch (error) {
  if (error instanceof KeiroAuthError) {
    console.log("Invalid API key");
  } else if (error instanceof KeiroRateLimitError) {
    console.log("Out of credits");
  } else if (error instanceof KeiroValidationError) {
    console.log(`Invalid parameters: ${error.message}`);
  } else if (error instanceof KeiroConnectionError) {
    console.log("Network error");
  } else {
    console.log(`Error: ${error.message}`);
  }
}

Exception Types

| Exception | Description | |-----------|-------------| | KeiroError | Base exception class | | KeiroAuthError | Invalid API key | | KeiroRateLimitError | Out of credits | | KeiroValidationError | Invalid parameters | | KeiroConnectionError | Network issues | | KeiroAPIError | General API errors |


Configuration

Simple Initialization

const client = new Keiro("your-api-key");

With Options

const client = new Keiro({
  apiKey: "your-api-key",
  timeout: 60000,  // 60 seconds
  baseUrl: "http://localhost:8000/api"  // For local development
});

Environment Variables (Recommended)

require('dotenv').config();

const client = new Keiro(process.env.KEIRO_API_KEY);

Create .env file:

KEIRO_API_KEY=your-api-key-here

Dynamic Base URL

const client = new Keiro(process.env.KEIRO_API_KEY);
client.setBaseUrl("https://custom-api.example.com/api");

Advanced Examples

Batch Processing

const queries = ["Python", "JavaScript", "TypeScript"];

const results = await Promise.all(
  queries.map(query => client.search(query))
);

results.forEach((result, index) => {
  console.log(`Query: ${queries[index]}`);
  console.log(`Results: ${result.data.length}`);
  console.log(`Credits: ${result.creditsRemaining}\n`);
});

Error Handling with Retry

async function searchWithRetry(query, maxRetries = 3) {
  for (let attempt = 1; attempt <= maxRetries; attempt++) {
    try {
      return await client.search(query);
    } catch (error) {
      if (error instanceof KeiroRateLimitError) {
        throw error;  // Don't retry on rate limit
      }
      if (attempt === maxRetries) throw error;
      
      console.log(`Attempt ${attempt} failed, retrying...`);
      await new Promise(r => setTimeout(r, 1000 * attempt));
    }
  }
}

API Types

interface SearchResult {
  data: any;
  creditsRemaining: number;
}

interface HealthCheckResult {
  status: string;
  environment: string;
  database?: string;
  service?: string;
}

interface ValidateApiKeyResult {
  valid: boolean;
  message: string;
  server_status: string;
  environment: string;
}

Links

| Resource | URL | |----------|-----| | Homepage | https://www.keirolabs.cloud/ | | npm | https://www.npmjs.com/package/keirolabs | | Python SDK | https://pypi.org/project/keirolabs | | Support | [email protected] |


License

MIT License - see LICENSE file for details.