@dineator/sdk
v1.0.13
Published
Official JavaScript/TypeScript SDK for the Dineator Restaurant Management API
Maintainers
Readme
@dineator/sdk
Official JavaScript & TypeScript SDK for the Dineator Restaurant Management API.
Installation
npm install @dineator/sdk
# or
yarn add @dineator/sdkCDN (browser)
<script src="https://unpkg.com/@dineator/[email protected]/dist/dineator.min.js"></script>Quick Start
import { Dineator } from '@dineator/sdk';
const client = new Dineator({
apiUrl: 'https://api.dineator.com',
});
// 1. Login (automatically stores the token)
const { accessToken, refreshToken } = await client.auth.login({
email: '[email protected]',
password: 'SecurePassword123!',
});
// 2. Get the public menu (no auth needed)
const menu = await client.menu.getPublic('my-restaurant-slug');
// 3. Place a customer order
const order = await client.orders.placePublic('my-restaurant-slug', {
orderType: 'DINE_IN',
tableId: 'table-uuid',
customerName: 'Jane Doe',
items: [{ menuItemId: 'item-uuid', quantity: 2 }],
});API Reference
new Dineator(config)
| Option | Type | Description |
|---|---|---|
| apiUrl | string | Base URL — https://api.dineator.com for production |
| token | string? | Optional initial JWT token |
const client = new Dineator({
apiUrl: 'https://api.dineator.com',
token: 'your-jwt-token', // optional — can be set later via client.setToken()
});client.auth
| Method | Auth | Description |
|---|---|---|
| auth.login(body) | None | Authenticate; sets token automatically |
| auth.register(body) | None | Create a tenant + admin account |
| auth.refresh(refreshToken) | None | Refresh access token |
| auth.me() | Bearer | Get current user profile |
| auth.logout() | Bearer | Invalidate refresh token |
| auth.forgotPassword(body) | None | Send password reset email |
| auth.resetPassword(body) | None | Reset password with token |
| auth.sendMagicLink(body) | None | Send magic link email |
| auth.verifyMagicLink(body) | None | Verify magic link, get tokens |
client.menu
| Method | Auth | Description |
|---|---|---|
| menu.getPublic(slug) | None | Full public menu |
| menu.listCategories() | Bearer | List categories |
| menu.createCategory(body) | Bearer | Create category |
| menu.updateCategory(id, body) | Bearer | Update category |
| menu.deleteCategory(id) | Bearer | Delete category |
| menu.listItems() | Bearer | List menu items |
| menu.createItem(body) | Bearer | Create item |
| menu.updateItem(id, body) | Bearer | Update item |
| menu.deleteItem(id) | Bearer | Delete item |
| menu.createModifierGroup(itemId, body) | Bearer | Add modifier group |
| menu.updateModifierGroup(itemId, groupId, body) | Bearer | Update modifier group |
| menu.deleteModifierGroup(itemId, groupId) | Bearer | Delete modifier group |
| menu.createModifier(itemId, groupId, body) | Bearer | Add modifier |
| menu.updateModifier(itemId, groupId, modifierId, body) | Bearer | Update modifier |
| menu.deleteModifier(itemId, groupId, modifierId) | Bearer | Delete modifier |
client.orders
| Method | Auth | Description |
|---|---|---|
| orders.placePublic(slug, body) | None | Customer-facing order placement |
| orders.trackPublic(orderId) | None | Track order status |
| orders.appendItems(orderId, body) | None | Add items to existing order |
| orders.placeAdmin(body) | Bearer | Staff POS order (bypasses business hours) |
| orders.list() | Bearer | List all orders |
| orders.listKitchen() | Bearer | Kitchen display orders |
| orders.updateStatus(id, body) | Bearer | Update order status |
| orders.updateItems(id, body) | Bearer | Modify order items |
| orders.splitBill(id, body) | Bearer | Split bill into two orders |
Order Status Flow:
PENDING → CONFIRMED → PREPARING → READY → DELIVERED → COMPLETED
client.reservations
| Method | Auth | Description |
|---|---|---|
| reservations.create(slug, body) | None | Create a reservation |
| reservations.checkAvailability(slug, params) | None | Check time slot availability |
| reservations.getPortalData(slug) | None | Booking widget data |
| reservations.list() | Bearer | List all reservations |
| reservations.updateStatus(id, body) | Bearer | Confirm/cancel/complete |
client.tables · client.floors
Standard CRUD operations for physical restaurant layout management.
client.analytics
| Method | Auth | Description |
|---|---|---|
| analytics.getDashboard({ range }) | Bearer (Manager+) | KPIs for 1d, 7d, 30d, 90d |
| analytics.export({ range, format }) | Bearer (Manager+) | Export as csv or json |
| analytics.refreshSnapshot() | Bearer (Admin+) | Trigger snapshot refresh |
client.theme
| Method | Auth | Description |
|---|---|---|
| theme.get(restaurantId) | None | Get theme config |
| theme.update(restaurantId, body) | Bearer (Admin+) | Update theme tokens |
| theme.reset(restaurantId) | Bearer (Admin+) | Reset to defaults |
| theme.applyTemplate(restaurantId, body) | Bearer (Admin) | Apply Super Admin template |
| theme.generateAi(body) | Bearer (Super Admin) | AI-generated theme tokens |
| theme.generateVariants(body) | Bearer (Super Admin) | Generate 3–5 AI theme variants |
| theme.refineVariant(body) | Bearer (Super Admin) | Refine variant with feedback |
client.promotions
| Method | Auth | Description |
|---|---|---|
| promotions.getActiveOffers(restaurantId) | None | Active offers |
| promotions.validateCoupon(restaurantId, body) | None | Validate coupon at checkout |
| promotions.listCoupons() | Bearer | List coupons |
| promotions.createCoupon(body) | Bearer | Create coupon |
| promotions.updateCoupon(id, body) | Bearer | Update coupon |
| promotions.deleteCoupon(id) | Bearer | Delete coupon |
| promotions.listOffers() | Bearer | List offers |
| promotions.createOffer(body) | Bearer | Create offer |
| promotions.updateOffer(id, body) | Bearer | Update offer |
| promotions.deleteOffer(id) | Bearer | Delete offer |
client.qr
| Method | Auth | Description |
|---|---|---|
| qr.list() | Bearer | List QR codes |
| qr.generate(body) | Bearer | Generate QR code |
| qr.delete(id) | Bearer | Delete QR code |
Error Handling
All errors throw a DineatorError:
import { Dineator, DineatorError } from '@dineator/sdk';
try {
await client.orders.placePublic('slug', { /* invalid body */ });
} catch (err) {
if (err instanceof DineatorError) {
console.log(err.status); // 422
console.log(err.code); // "VALIDATION_ERROR"
console.log(err.message); // Human-readable description
}
}| Status | Code | Meaning |
|---|---|---|
| 400 | VALIDATION_ERROR | Request body schema failed |
| 401 | UNAUTHORIZED | Missing or expired token |
| 403 | FORBIDDEN | Insufficient role/permission |
| 404 | NOT_FOUND | Resource not found |
| 409 | CONFLICT | Unique constraint (e.g. duplicate slug) |
| 422 | UNPROCESSABLE | Business rule violation |
| 429 | RATE_LIMITED | Too many requests |
| 500 | INTERNAL_ERROR | Server error |
Rate Limits
| Endpoint | Limit | Window |
|---|---|---|
| POST /auth/login | 10 requests | 15 min |
| POST /auth/register | 5 requests | 1 hour |
| POST /auth/magic-link | 5 requests | 15 min |
| All other endpoints | 200 requests | 15 min |
Implement exponential backoff on 429 RATE_LIMITED responses.
TypeScript
Full TypeScript support is built in — no @types package needed.
import type { MenuItem, Order, ThemeConfig } from '@dineator/sdk';All request bodies and responses are typed.
Links
- API Docs (Swagger): api.dineator.com/api/docs
- Developer Portal: dineator.com/developer/docs
- GitHub: github.com/dineator/js-sdk
License
MIT © Dineator Engineering
