npm package: @karmalicious/karma-api-js
Description: Official JavaScript/TypeScript SDK for Karma Common API
Author: Karma Dev Team
Latest version: 0.1.0

# @karmalicious/karma-api-js

Official JavaScript/TypeScript SDK for the Karma Common API.

## Installation

```bash
npm install @karmalicious/karma-api-js
# or
yarn add @karmalicious/karma-api-js
```

## Quick Start

```typescript
import { Configuration, InventoryApi } from '@karmalicious/karma-api-js'

// Initialize configuration
const config = new Configuration({
  basePath: 'https://common-api.karmalicious.com',
  apiKey: 'karma_live_your_api_key_here',
  headers: {
    'X-API-Key': 'karma_live_your_api_key_here'
  }
})

// Create API instances
const inventoryApi = new InventoryApi(config)

// Use the API
async function getInventory() {
  try {
    const response = await inventoryApi.getInventoryItems({
      locationId: 100,
      page: 1,
      limit: 50
    })
    console.log(response)
  } catch (error) {
    console.error('Error fetching inventory:', error)
  }
}

getInventory()
```

## Available APIs

- **InventoryApi** - Menu items, products, and modifiers
- **OrdersApi** - Customer orders and order management
- **SchedulesApi** - Operating hours and special schedules
- **ChannelsApi** - Sales channels (dine-in, takeaway, delivery)
- **MenuLayoutsApi** - Menu structure and organization
- **WebhooksApi** - Webhook subscriptions and event notifications
- **ApiKeysApi** - Authentication keys and permissions
- **VariantGroupsApi** - Product options and modifiers
- **CustomTagsApi** - Labels and categorization
- **CoursingsApi** - Multi-course meal sequencing
- **AlertsApi** - System notifications and warnings
- **TablesApi** - Restaurant table management
- **TableGroupsApi** - Table grouping and floor plans
- **LocationMapsApi** - Floor plans and seating layouts
- **TabsApi** - Customer tabs and running bills
- **TerminalsApi** - Payment terminal management
- **VouchersApi** - Discount vouchers and promotions
- **ArticlesApi** - Changelog and release notes

## Authentication

All API requests require an API key. You can generate API keys through the Karma Merchant Dashboard.

```typescript
const config = new Configuration({
  basePath: 'https://common-api.karmalicious.com',
  headers: {
    'X-API-Key': 'your_api_key_here'
  }
})
```

## Error Handling

```typescript
import { ResponseError } from '@karmalicious/karma-api-js'

try {
  const response = await inventoryApi.getInventoryItems({ locationId: 100 })
} catch (error) {
  if (error instanceof ResponseError) {
    const errorBody = await error.response.json()
    console.error('API Error:', errorBody)
  } else {
    console.error('Unexpected error:', error)
  }
}
```

## TypeScript Support

This SDK is written in TypeScript and provides full type definitions for all API endpoints and models.

```typescript
import { InventoryItem, CreateOrderRequest } from '@karmalicious/karma-api-js'

const item: InventoryItem = {
  id: 123,
  title: 'Burger',
  basePrice: 9900, // prices in cents
  // ... fully typed!
}
```

## Environments

```typescript
// Production
const prodConfig = new Configuration({
  basePath: 'https://common-api.karmalicious.com',
  headers: { 'X-API-Key': 'karma_live_...' }
})

// Development
const devConfig = new Configuration({
  basePath: 'https://common-api-dev.karmalicious.com',
  headers: { 'X-API-Key': 'karma_dev_...' }
})

// Local
const localConfig = new Configuration({
  basePath: 'http://localhost:8080',
  headers: { 'X-API-Key': 'karma_dev_...' }
})
```

## Documentation

Full API documentation is available at:
- Production: https://common-api.karmalicious.com/docs
- Development: https://common-api-dev.karmalicious.com/docs

## License

MIT

## Support

For support, email dev@karmalicious.com or visit our [GitHub repository](https://github.com/karmadev/karma-api-js).