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

@railtownai/railengine

v0.0.5

Published

JavaScript/TypeScript SDK for Railtown AI Rail Engine - Retrieval

Readme

@railtownai/railengine

JavaScript/TypeScript SDK for Railtown AI Rail Engine - Retrieval package. This package provides a simple interface for reading and searching data from Rail Engine.

Installation

npm install @railtownai/railengine

Requirements

  • Node.js 20+
  • TypeScript 5.0+ (optional, but recommended)

Quick Start

Basic Usage

import { RailEngine } from "@railtownai/railengine";

// ENGINE_PAT and ENGINE_ID are read from environment variables automatically

// Initialize client
const client = new RailEngine();

// Get storage document by EventId
const document = await client.getStorageDocumentByEventId({
  eventId: "event-id"
});
console.log(document);

Using Environment Variables

import { RailEngine } from "@railtownai/railengine";

const client = new RailEngine();

// Use client.engineId if you need it
const results = client.searchVectorStore(client.engineId, "VectorStore1", "query");
for await (const result of results) {
  console.log(result);
}

Zod Schema Support

You can provide a Zod schema during client initialization to automatically validate retrieved data:

import { z } from "zod";
import { RailEngine } from "@railtownai/railengine";

const FoodDiaryItemSchema = z.object({
  food_name: z.string(),
  calories: z.number(),
  carbs: z.number(),
  proteins: z.number(),
  fats: z.number()
});

type FoodDiaryItem = z.infer<typeof FoodDiaryItemSchema>;

// Initialize with schema
const client = new RailEngine({
  schema: FoodDiaryItemSchema
});

// Results automatically validated against FoodDiaryItemSchema
const results = client.searchVectorStore({
  vectorStore: "VectorStore1",
  query: "apple"
});
for await (const item of results) {
  // item is FoodDiaryItem
  console.log(item.food_name, item.calories);
}

API Methods

Embeddings API

searchVectorStore

Search a vector store using semantic similarity.

Example:

const results = client.searchVectorStore({
  engineId: "engine-id", // Optional, defaults to process.env.ENGINE_ID
  vectorStore: "VectorStore1",
  query: "apple"
});
for await (const result of results) {
  console.log(result);
}

Storage API

getStorageDocumentByEventId

Get a single storage document by EventId.

Example:

const document = await client.getStorageDocumentByEventId({
  eventId: "event-id",
  engineId: "engine-id" // Optional, defaults to process.env.ENGINE_ID
});
if (document) {
  console.log(document);
}

getStorageDocumentByCustomerKey

Get storage documents by CustomerKey with automatic pagination.

Example:

const documents = client.getStorageDocumentByCustomerKey({
  customerKey: "doc-123",
  engineId: "engine-id", // Optional, defaults to process.env.ENGINE_ID
  pageSize: 50
});

for await (const doc of documents) {
  console.log(doc);
}

queryStorageByJsonPath

Query storage documents using JSONPath.

const documents = client.queryStorageByJsonPath(
  engineId: string,
  jsonPathQuery: string,
  options?: {
    filterFn?: (item: T | Record<string, unknown>) => boolean;
    schema?: z.ZodSchema<unknown>;
  }
): AsyncIterable<T | Record<string, unknown>>

Example:

const documents = await client.queryStorageByJsonPath({
  engineId: "engine-id",
  jsonPathQuery: "$.status:active"
});
for await (const doc of documents) {
  console.log(doc);
}

listStorageDocuments

List storage documents with automatic pagination.

Example:

// List all documents
const documents = await client.listStorageDocuments({
  engineId: "engine-id"
});

// List documents filtered by customerKey
const filtered = await client.listStorageDocuments({
  engineId: "engine-id",
  customerKey: "doc-123"
});

for await (const doc of documents) {
  console.log(doc);
}

Indexing API

searchIndex

Search Railengine Index.

Example:

const results = client.searchIndex("engine-id", { search: "example query" });

for await (const result of results) {
  console.log(result);
}

License

MIT.