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 🙏

© 2025 – Pkg Stats / Ryan Hefner

nocodb-api-types

v1.1.1

Published

Generate TypeScript types from NocoDB metadata

Readme

NocoDB API Types Generator

A lightweight utility to automatically generate TypeScript interfaces from your NocoDB project metadata. Keep your frontend or backend code type-safe and in sync with your NocoDB schema.

Features

  • 🚀 Automatic Type Generation: Connects to your NocoDB instance and fetches all tables and columns.
  • 🔌 Typed Axios Client: Generates a fully typed Axios client for your project, enabling autocomplete and type safety for API calls.
  • 📦 Type Mapping: Intelligently maps NocoDB types (Text, Number, Boolean, etc.) to TypeScript types.
  • 🛠 CLI Support: Easy-to-use command line interface.
  • 🔒 Secure: Uses environment variables for configuration.

Installation

You can install this package as a dev dependency in your project:

npm install --save-dev nocodb-api-types

Configuration

Create a .env file in the root of your project (or ensure these variables are set in your environment):

NOCODB_URL=https://your-nocodb-instance.com
XC_TOKEN=your_api_token

Note: You can generate an API token (XC-Token) from your NocoDB account settings.

Usage

CLI

Add a script to your package.json:

{
  "scripts": {
    "nc-generate": "nc-generate"
  }
}

Then run:

npm run nc-generate

You can optionally specify the output directory:

npm run nc-generate -- ./my-client-folder

This will generate types and client files in the nc-client directory by default, or the directory you specified.

Generated Client Usage

The generator creates a typed client for each of your NocoDB bases. You can import it and use it to interact with your data.

Backend Usage (with XC-Token):

Assuming you have a base named "My Store":

// Import the generated client
import { MyStoreClient } from './nc-client/my-store-client';

// Initialize the client with XC-Token (for backend)
const db = new MyStoreClient({
  baseURL: process.env.NOCODB_URL,
  xcToken: process.env.XC_TOKEN
});

Frontend Usage (with XC-Auth):

If you are using the client in a frontend application where you have a user's auth token:

 // Initialize the client with XC-Auth (for frontend)
const db = new MyStoreClient({
  baseURL: process.env.NOCODB_URL,
  xcAuth: 'user_auth_token_here' 
});

Data Operations:

// List records
const products = await db.Products.list({ limit: 10 });
console.log(products.list);

// Get a single record
const product = await db.Products.get(1);

// Create a record
await db.Products.create({
  Name: 'New Product',
  Price: 99.99
});

// Update a record
await db.Products.update(1, { Price: 89.99 });

// Delete a record
await db.Products.delete(1);

Development

Setup

  1. Clone the repository.
  2. Install dependencies: npm install.
  3. Create a test.env file for integration testing.

Testing

Run integration tests (requires test.env):

npm run test:integration

Build

Build the project for production/npm:

npm run build

Support the developer

They say developers turn coffee into code. I'm experimenting with a new runtime environment: turning beer into features! 🍺

If this tool saved you time, consider fueling the next release with a cold one:

Buy me a beer 🍺

License

ISC