Official JavaScript/TypeScript SDK for the Karma Common API.
npm install @karmalicious/karma-api-js
# or
yarn add @karmalicious/karma-api-jsimport { 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()- 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
All API requests require an API key. You can generate API keys through the Karma Merchant Dashboard.
const config = new Configuration({
basePath: 'https://common-api.karmalicious.com',
headers: {
'X-API-Key': 'your_api_key_here'
}
})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)
}
}This SDK is written in TypeScript and provides full type definitions for all API endpoints and models.
import { InventoryItem, CreateOrderRequest } from '@karmalicious/karma-api-js'
const item: InventoryItem = {
id: 123,
title: 'Burger',
basePrice: 9900, // prices in cents
// ... fully typed!
}// 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_...' }
})Full API documentation is available at:
- Production: https://common-api.karmalicious.com/docs
- Development: https://common-api-dev.karmalicious.com/docs
MIT
For support, email dev@karmalicious.com or visit our GitHub repository.