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

ai-api-generator-nestjs

v1.1.2

Published

AI-powered API generator for NestJS - Generate REST APIs from natural language with MongoDB integration

Readme

ai-api-generator-nestjs

AI-powered API generator for NestJS - Generate REST APIs from natural language with MongoDB integration.

Installation

npm install ai-api-generator-nestjs

Quick Start

1. Import the Module

// app.module.ts
import { Module } from '@nestjs/common';
import { MongooseModule } from '@nestjs/mongoose';
import { AiApiGeneratorModule } from 'ai-api-generator-nestjs';

@Module({
  imports: [
    MongooseModule.forRoot('mongodb://localhost:27017/mydb'),
    AiApiGeneratorModule.forRoot({
      ai: {
        provider: 'openai',
        apiKey: process.env.OPENAI_API_KEY,
        model: 'gpt-4',
      },
      basePath: '/ai-api-generator',     // UI served here
      apiPrefix: 'ai-api-generator',      // API endpoints prefix
    }),
  ],
})
export class AppModule {}

2. Setup the UI

// main.ts
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import { AiApiGeneratorUI } from 'ai-api-generator-nestjs';

async function bootstrap() {
  const app = await NestFactory.create(AppModule);

  // Setup the AI API Generator UI (similar to Swagger)
  AiApiGeneratorUI.setup('/ai-api-generator', app);

  await app.listen(3000);
}
bootstrap();

3. Access the UI

Open your browser and navigate to http://localhost:3000/ai-api-generator

Configuration Options

Module Options

interface AiApiGeneratorModuleOptions {
  ai: {
    provider: 'openai' | 'anthropic';
    apiKey: string;
    model?: string;        // Default: 'gpt-4'
    baseUrl?: string;      // Custom API endpoint
    temperature?: number;  // Default: 0.7
    maxTokens?: number;    // Default: 2000
  };
  basePath?: string;       // Default: '/ai-api-generator'
  apiPrefix?: string;      // Default: 'ai-api-generator'
  connectionName?: string; // Mongoose connection name (for multi-db setups)
  metadataCollection?: string; // Default: 'ai_api_metadata'
  cache?: {
    enabled?: boolean;     // Default: true
    type?: 'memory' | 'redis';
    host?: string;         // Redis host
    port?: number;         // Redis port
    ttl?: number;          // Cache TTL in seconds
  };
  ui?: {
    enabled?: boolean;     // Default: true
    title?: string;        // Custom UI title
  };
}

Async Configuration

AiApiGeneratorModule.forRootAsync({
  imports: [ConfigModule],
  useFactory: (configService: ConfigService) => ({
    ai: {
      provider: 'openai',
      apiKey: configService.get('OPENAI_API_KEY'),
      model: configService.get('OPENAI_MODEL'),
    },
  }),
  inject: [ConfigService],
})

UI Options

AiApiGeneratorUI.setup('/ai-api-generator', app, {
  apiPrefix: '/api/v1/ai-generator',  // Custom API prefix
  title: 'My API Generator',          // Custom title
  customCss: 'body { font-family: Arial; }',
  customJs: 'console.log("Custom JS loaded");',
});

API Endpoints

Once configured, the following endpoints are available:

| Endpoint | Method | Description | |----------|--------|-------------| | /{prefix}/generate | POST | Generate API from natural language | | /{prefix} | GET | List all APIs | | /{prefix} | POST | Create a new API | | /{prefix}/:id | GET | Get API by ID | | /{prefix}/:id | PUT | Update API | | /{prefix}/:id | DELETE | Delete API | | /{prefix}/:id/execute | POST | Execute API | | /{prefix}/:id/clone | POST | Clone API | | /{prefix}/database-schema | GET | Get database schema | | /{prefix}/database-schema/collections | GET | List collections |

Features

  • Natural Language API Generation: Describe your API in plain English
  • MongoDB Integration: Automatically generates MongoDB queries
  • Schema Introspection: Reads your database schema for accurate query generation
  • OpenAPI Export: Generate OpenAPI 3.0 specifications
  • API Execution: Test APIs directly from the UI
  • Redis Caching: Optional schema caching with Redis
  • Swagger-like UI: Pre-built React interface for managing APIs

Requirements

  • Node.js >= 18.0.0
  • NestJS >= 10.0.0
  • MongoDB >= 7.0
  • Redis (optional, for caching)

License

MIT