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

shruti-ai-sdk

v1.1.3

Published

JavaScript SDK for interacting with shrutiAI API

Readme

shrutiAI JavaScript SDK

A comprehensive JavaScript/TypeScript SDK for interacting with the shrutiAI API through the /chat-tool endpoint. This SDK provides a simple and intuitive interface for managing users, posts, analytics, and more using a unified chat-tool interface.

Features

  • 🚀 Full TypeScript Support - Complete type definitions for better development experience
  • 🔧 Easy to Use - Simple and intuitive API design
  • 🛡️ Error Handling - Comprehensive error handling with custom exception classes
  • 📊 Analytics Support - Built-in analytics and reporting capabilities
  • 🧪 Well Tested - Comprehensive test suite with high coverage
  • 📦 Modern Build - ES2020+ support with CommonJS output

Installation

npm install shruti-ai-sdk

Quick Start

import { ShrutiAIClient } from 'shruti-ai-sdk';

// Initialize the client
const client = new ShrutiAIClient({
  apiKey: 'your-api-key-here',
  baseUrl: 'https://api.shrutiai.com/v1', // optional
  timeout: 30000 // optional, default: 30000ms
});

// Get users
const users = await client.getUsers(10, 0);

// Create a new user
const newUser = await client.createUser('John Doe', '[email protected]');

// Get posts
const posts = await client.getPosts();

// Check API health
const health = await client.healthCheck();

API Reference

Chat-Tool Endpoint

This SDK uses a unified /chat-tool endpoint where different functionalities are accessed through different tool names and payloads:

  • User Management: get_users, get_user, create_user, update_user, delete_user
  • Post Management: get_posts, create_post
  • Analytics: get_analytics
  • Utility: health_check, get_api_info

Each request follows this structure:

{
  "tool": "tool_name",
  "payload": {
    // tool-specific data
  }
}

Client Initialization

const client = new ShrutiAIClient({
  apiKey: string,        // Required: Your API key
  baseUrl?: string,      // Optional: Base URL (default: https://api.shrutiai.com/v1)
  timeout?: number       // Optional: Request timeout in ms (default: 30000)
});

User Management

Get Users

// Get users with pagination
const users = await client.getUsers(limit, offset);

// Example
const users = await client.getUsers(10, 0); // Get first 10 users

Get User by ID

const user = await client.getUser('user-id');

Create User

const user = await client.createUser(name, email, additionalData);

// Example
const user = await client.createUser('John Doe', '[email protected]', {
  role: 'admin',
  department: 'Engineering'
});

Update User

const updatedUser = await client.updateUser('user-id', updateData);

// Example
const user = await client.updateUser('user-id', {
  name: 'John Updated',
  role: 'manager'
});

Delete User

const success = await client.deleteUser('user-id');

Posts Management

Get Posts

// Get all posts
const posts = await client.getPosts();

// Get posts with limit
const posts = await client.getPosts(undefined, 20);

// Get posts by user
const userPosts = await client.getPosts('user-id', 10);

Create Post

const post = await client.createPost(title, content, userId);

// Example
const post = await client.createPost(
  'My First Post',
  'This is the content of my post',
  'user-id'
);

Analytics

Get Analytics

const analytics = await client.getAnalytics(startDate, endDate);

// Example
const analytics = await client.getAnalytics('2023-01-01', '2023-01-31');

Utility Methods

Health Check

const health = await client.healthCheck();
// Returns: { status: 'healthy', timestamp: '2023-01-01T00:00:00Z' }

API Info

const info = await client.getApiInfo();
// Returns: { name: 'shrutiAI API', version: '1.0.0', description: '...' }

Error Handling

The SDK provides comprehensive error handling with custom exception classes:

import {
  ShrutiAIError,
  AuthenticationError,
  RateLimitError,
  NotFoundError,
  ValidationError
} from 'shruti-ai-sdk';

try {
  const users = await client.getUsers();
} catch (error) {
  if (error instanceof AuthenticationError) {
    console.log('Invalid API key');
  } else if (error instanceof RateLimitError) {
    console.log('Rate limit exceeded');
  } else if (error instanceof NotFoundError) {
    console.log('Resource not found');
  } else if (error instanceof ValidationError) {
    console.log('Invalid request data');
  } else if (error instanceof ShrutiAIError) {
    console.log('API error:', error.message);
  } else {
    console.log('Unexpected error:', error.message);
  }
}

TypeScript Support

The SDK is written in TypeScript and provides complete type definitions:

import { ShrutiAIClient, User, Post, AnalyticsData } from 'shruti-ai-sdk';

const client = new ShrutiAIClient({ apiKey: 'your-key' });

// All methods are fully typed
const users: User[] = await client.getUsers();
const posts: Post[] = await client.getPosts();
const analytics: AnalyticsData = await client.getAnalytics('2023-01-01', '2023-01-31');

Development

Prerequisites

  • Node.js 14.0.0 or higher
  • npm or yarn

Setup

  1. Clone the repository

  2. Install dependencies:

    npm install
  3. Build the project:

    npm run build
  4. Run tests:

    npm test
  5. Run tests with coverage:

    npm run test:coverage

Available Scripts

  • npm run build - Compile TypeScript to JavaScript
  • npm test - Run the test suite
  • npm run test:watch - Run tests in watch mode
  • npm run test:coverage - Run tests with coverage report
  • npm run dev - Compile TypeScript in watch mode

Project Structure

Javascript/
├── src/
│   ├── index.ts          # Main entry point
│   ├── client.ts         # Main client class
│   └── exceptions.ts     # Exception classes
├── tests/
│   ├── setup.ts          # Test setup
│   ├── exceptions.test.ts # Exception tests
│   ├── client.test.ts    # Client tests
│   ├── integration.test.ts # Integration tests
│   └── complete-test.js  # Complete test runner
├── dist/                 # Compiled JavaScript (generated)
├── package.json
├── tsconfig.json
├── jest.config.js
└── README.md

Testing

The SDK includes a comprehensive test suite:

Run All Tests

npm test

Run Specific Test Files

# Test exceptions
npm test exceptions.test.ts

# Test client
npm test client.test.ts

# Test integration
npm test integration.test.ts

Run Complete Test Suite

node tests/complete-test.js

Test Coverage

npm run test:coverage

Examples

Basic Usage

import { ShrutiAIClient } from 'shruti-ai-sdk';

const client = new ShrutiAIClient({ apiKey: 'your-api-key' });

async function main() {
  try {
    // Get all users
    const users = await client.getUsers();
    console.log('Users:', users);

    // Create a new user
    const newUser = await client.createUser('Jane Doe', '[email protected]');
    console.log('Created user:', newUser);

    // Get posts
    const posts = await client.getPosts();
    console.log('Posts:', posts);

    // Check API health
    const health = await client.healthCheck();
    console.log('API Health:', health);

  } catch (error) {
    console.error('Error:', error.message);
  }
}

main();

Advanced Usage with Error Handling

import { 
  ShrutiAIClient, 
  AuthenticationError, 
  RateLimitError 
} from 'shruti-ai-sdk';

const client = new ShrutiAIClient({ apiKey: 'your-api-key' });

async function handleUsers() {
  try {
    const users = await client.getUsers(50, 0);
    return users;
  } catch (error) {
    if (error instanceof AuthenticationError) {
      console.error('Authentication failed. Please check your API key.');
    } else if (error instanceof RateLimitError) {
      console.error('Rate limit exceeded. Please try again later.');
    } else {
      console.error('Unexpected error:', error.message);
    }
    throw error;
  }
}

Contributing

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature-name
  3. Make your changes
  4. Add tests for your changes
  5. Run the test suite: npm test
  6. Commit your changes: git commit -am 'Add feature'
  7. Push to the branch: git push origin feature-name
  8. Submit a pull request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Support

For support and questions:

  • Create an issue on GitHub
  • Check the documentation
  • Review the test files for usage examples

Changelog

v1.1.1

  • IMPROVEMENT: Fixed test files to work with real SDK
  • Removed hardcoded mocks from test files
  • Added proper installation test files
  • Improved error handling in test scenarios
  • Better documentation for package users

v1.1.0

  • BREAKING CHANGE: Updated to use /chat-tool endpoint
  • All API calls now use unified chat-tool interface
  • Updated request/response structure
  • Added new payload interfaces for better type safety
  • Updated base URL to https://api.shrutiai.com/v1

v1.0.1

  • Initial release
  • Complete TypeScript support
  • Comprehensive test suite
  • Full API coverage
  • Error handling
  • Documentation