open-index/open-npm huggingface dataset:
npm package: @invoiceleaf/typescript-sdk
Description: Official TypeScript SDK for the InvoiceLeaf public API
Latest version: 0.1.0

# InvoiceLeaf TypeScript SDK

![License](https://img.shields.io/github/license/InvoiceLeaf/typescript-sdk)
![Node](https://img.shields.io/badge/node-%3E%3D18-339933?logo=node.js&logoColor=white)
![TypeScript](https://img.shields.io/badge/TypeScript-ready-3178C6?logo=typescript&logoColor=white)
![Last Commit](https://img.shields.io/github/last-commit/InvoiceLeaf/typescript-sdk)

Official TypeScript SDK for the InvoiceLeaf public REST API.

## Features

- OpenAPI-aligned request/response models
- API key and bearer-token authentication support
- Typed service clients for all public InvoiceLeaf endpoint groups
- Browser and Node.js compatible API client

## Installation

```bash
npm install @invoiceleaf/typescript-sdk
```

If you are testing directly from GitHub before npm availability:

```bash
npm install github:InvoiceLeaf/typescript-sdk
```

## Quick Start

```ts
import { InvoiceLeafClient } from '@invoiceleaf/typescript-sdk';

const client = new InvoiceLeafClient({
  accessToken: process.env.INVOICELEAF_ACCESS_TOKEN,
  baseUrl: 'https://api.invoiceleaf.com/v1/',
});

const me = await client.profiles.getCurrentUser();
const spaces = await client.spaces.list({ page: 1, limit: 20 });

console.log(me.email);
console.log(spaces.items?.length ?? 0);
```

## Authentication

```ts
import { InvoiceLeafClient } from '@invoiceleaf/typescript-sdk';

const apiKeyClient = new InvoiceLeafClient({
  apiKey: process.env.INVOICELEAF_API_KEY,
});

const tokenClient = new InvoiceLeafClient({
  accessToken: process.env.INVOICELEAF_ACCESS_TOKEN,
});
```

## Available Services

- `accounting`
- `barcodes`
- `categories`
- `companies`
- `documents`
- `exports`
- `invoiceSeries`
- `organizations`
- `paymentMethods`
- `profiles`
- `reminders`
- `spaces`
- `spaceMembers`
- `statistics`
- `tags`

## Error Handling

```ts
import { ApiError, InvoiceLeafClient } from '@invoiceleaf/typescript-sdk';

const client = new InvoiceLeafClient({ apiKey: process.env.INVOICELEAF_API_KEY });

try {
  await client.spaces.list();
} catch (error) {
  if (error instanceof ApiError) {
    console.error(error.status, error.code, error.message);
  }
}
```

## Development

```bash
npm install
npm run typecheck
npm run build
```

Regenerate OpenAPI types from the backend spec:

```bash
npm run generate:openapi
```