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

@spaceinvoices/js-sdk

v13.14.0

Published

Official JavaScript/TypeScript SDK for the Space Invoices API

Readme

@spaceinvoices/js-sdk

Official JavaScript/TypeScript SDK for the Space Invoices API.

Installation

npm install @spaceinvoices/js-sdk
# or
bun add @spaceinvoices/js-sdk

Usage

Lean SDK (Recommended)

import SpaceInvoices from '@spaceinvoices/js-sdk/sdk';

const sdk = new SpaceInvoices({ accessToken: 'your-api-key' });

// List invoices for an entity
const invoices = await sdk.invoices.list({ entity_id: 'ent_123' });

// Create an invoice. SDK fields match the REST API's snake_case contract.
const invoice = await sdk.invoices.create(
  {
    is_draft: false,
    currency_code: 'EUR',
    date: '2024-01-15',
    items: [{ name: 'Service', quantity: 1, gross_price: 100, taxes: [] }]
  },
  {
    entity_id: 'ent_123',
    request_id: 'order_123:create-invoice'
  }
);

Individual API Modules

import { initSDK, invoices, customers } from '@spaceinvoices/js-sdk/sdk';

// Initialize once at app startup
initSDK({ accessToken: 'your-api-key' });

// Use individual modules anywhere
const result = await invoices.list();

Configuration Options

const sdk = new SpaceInvoices({
  accessToken: 'your-api-key',
  // Optional: custom API base URL
  basePath: 'https://eu.spaceinvoices.com',
  // Optional: callback for 401 responses
  onUnauthorized: (response) => {
    console.log('Token expired, refreshing...');
  }
});

Dynamic Token

const sdk = new SpaceInvoices({
  accessToken: async () => {
    // Fetch token from your auth system
    return await getAccessToken();
  }
});

Features

  • Full TypeScript Support - Complete type definitions for all API methods
  • Lean SDK Entry - Import from /sdk to exclude optional Zod schemas
  • ESM & CJS - Works in Node.js, browsers, and modern bundlers
  • Zod Schemas - Optional Zod schemas for form validation

Version 4

Version 4 removes deprecated compatibility type aliases and legacy generated client declarations. Use canonical generated types such as CreateInvoice, CreateCustomerBody, and InvoiceList. Request and response fields retain the API's snake_case names; the SDK does not expose camelCase field variants.

Upload and file metadata responses use secure_url and public_id. The former secureUrl and publicId fields remain as deprecated response aliases for API compatibility; new SDK integrations should use only the snake_case fields.

Zod Schemas

For form validation, import Zod schemas from the package root. This loads the complete generated schema catalog; applications that do not need runtime validation should use the lean /sdk entry shown above.

import { zod } from '@spaceinvoices/js-sdk';

// Validate invoice creation data
const result = zod.invoices.CreateInvoiceBody.safeParse(formData);
if (!result.success) {
  console.log(result.error.issues);
}

// Available schemas follow PascalCase naming:
// - zod.invoices.CreateInvoiceBody
// - zod.customers.CreateCustomerBody
// - zod.items.CreateItemBody
// - etc.

Documentation

Development

# Generate SDK (deterministic by default from apps/api/openapi.json)
bun run generate

# Or generate from a live API explicitly
OPENAPI_TARGET=http://localhost:3000/openapi.json bun run generate

# If OpenAPI examples changed, refresh docs artifacts too
cd ../../apps/docs && bun run generate

# Build for distribution
bun run build

License

MIT