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

cipher-ai

v1.0.1

Published

TypeScript SDK for the CIPHER trading engine REST API

Readme

cipher-ai

TypeScript SDK for the CIPHER trading engine REST API.

Installation

npm install cipher-ai

Quick Start

import { CipherClient } from 'cipher-ai';

const client = new CipherClient({
  baseUrl: 'http://localhost:8000',
  apiKey: 'cipher_sk_your_api_key'
});

// Create a trading signal
const signal = await client.createSignal({
  symbol: 'BTC',
  model_version: 1
});

console.log(signal.signal); // 'BUY', 'SELL', or 'HOLD'
console.log(signal.confidence); // 0.85

API Reference

Constructor

const client = new CipherClient(options?: CipherClientOptions);

Options:

  • baseUrl (optional): API base URL. Default: http://localhost:8000
  • apiKey (optional): API key for authentication

Trading Endpoints

createSignal

Create a trading signal.

const signal = await client.createSignal({
  symbol: 'BTC',
  model_version: 1
});

// Returns: SignalResponse
// {
//   symbol: 'BTC',
//   signal: 'BUY',
//   confidence: 0.85,
//   price: 45000,
//   timestamp: '2024-01-01T00:00:00Z',
//   model_version: 1,
//   model_episode: 10,
//   reasoning: ['Strong uptrend'],
//   knowledge_context: ['Market analysis']
// }

getStatus

Get system status.

const status = await client.getStatus();

// Returns: StatusResponse
// {
//   model: 'LSTM',
//   status: 'running',
//   latest_model_version: 5,
//   min_model_version: 1,
//   episode: 100,
//   win_rate: 0.75,
//   balance: 10000,
//   total_return: 0.25,
//   last_trained: '2024-01-01T00:00:00Z',
//   knowledge_chunks: 50,
//   uptime_hours: 24
// }

getPerformance

Get performance metrics.

const performance = await client.getPerformance();

// Returns: PerformanceResponse
// {
//   total_return_pct: 25.5,
//   win_rate: 0.75,
//   sharpe_ratio: 1.5,
//   max_drawdown_pct: 5.2,
//   total_trades: 100,
//   avg_trade_duration_hours: 2.5,
//   knowledge_usage_rate: 0.8
// }

getHistory

Get trade history.

const history = await client.getHistory(20);

// Returns: HistoryResponse
// {
//   trades: [
//     {
//       symbol: 'BTC',
//       signal: 'BUY',
//       confidence: 0.85,
//       price: 45000,
//       timestamp: '2024-01-01T00:00:00Z',
//       model_version: 1,
//       model_episode: 10,
//       pnl: 100
//     }
//   ],
//   count: 1
// }

getModels

Get model versions.

const models = await client.getModels();

// Returns: ModelsResponse
// {
//   min_version: 1,
//   latest_version: 5,
//   versions: [
//     {
//       version: 5,
//       episode: 100,
//       win_rate: 0.75,
//       timestamp: '2024-01-01T00:00:00Z',
//       active: true
//     }
//   ]
// }

getModelStatus

Get model status (no authentication required).

const modelStatus = await client.getModelStatus();

// Returns: ModelStatusResponse
// {
//   episode: 100,
//   timestamp: '2024-01-01T00:00:00Z',
//   running: true,
//   cumulative_pnl: 1000,
//   best_pnl: 1500,
//   win_rate: 0.75,
//   best_win_rate: 0.8,
//   total_wins: 75,
//   total_losses: 25,
//   symbol: 'BTC',
//   symbols: ['BTC', 'ETH'],
//   lstm_loss: 0.05
// }

API Key Management

getKeyUsage

Get API key usage statistics.

const usage = await client.getKeyUsage(
  '[email protected]',
  'your_admin_secret',
  30 // days (optional, default: 30)
);

// Returns: KeyUsageResponse
// {
//   usage: [
//     {
//       key_hash: 'abc123...',
//       requests: 150,
//       last_used: '2024-01-01T00:00:00Z'
//     }
//   ],
//   days: 30
// }

Error Handling

All API methods throw a CipherError on non-2xx responses.

import { CipherClient, CipherError } from 'cipher-ai';

try {
  const signal = await client.createSignal({
    symbol: 'BTC',
    model_version: 1
  });
} catch (error) {
  if (error instanceof CipherError) {
    console.error('Status:', error.status);
    console.error('Message:', error.message);
    
    if (error.status === 401) {
      console.error('Invalid API key');
    } else if (error.status === 429) {
      console.error('Rate limit exceeded');
    }
  }
}

Development

Setup

# Clone the repository
git clone https://github.com/getcipherAI/cipher-ai.git
cd cipher-ai

# Install dependencies
npm install

# Run tests
npm test

# Build the package
npm run build

Scripts

  • npm run build - Build the package (CJS + ESM)
  • npm test - Run tests in watch mode
  • npm run test:run - Run tests once
  • npm run typecheck - Type-check without emitting files

Requirements

  • Node.js >= 18
  • TypeScript 5.3+

License

MIT