Overview
Crave’s API supports multiple integration patterns depending on your technical requirements, timeline, and existing infrastructure. This guide outlines the different approaches available.API Capabilities
Core Restaurant Operations
The Crave API handles standard restaurant ordering operations:- Menu Management: Product catalog with categories, modifiers, pricing, and availability tracking
- Cart Processing: Session-based cart management with tax calculations and validation
- Payment Processing: Stripe integration for payment intent creation and confirmation
- Order Management: Order creation, status tracking, and fulfillment workflow
- Multi-Location Support: Location-specific menus, hours, and configuration
- Customer Management: User authentication, profiles, and order history
API Architecture
REST-based: Standard HTTP methods (GET, POST, PUT, DELETE) with JSON payloads Authentication: API key-based authentication with rate limiting (200 requests per 10 minutes) Base URL:https://api.cravejs.com/api/v1
Response Format: Consistent JSON structure with error handling
Technical Requirements
Subscription Model: Paid subscription required for API access- Storefront APIs: Available with standard subscription
- Admin APIs: Enterprise tier subscription required
Implementation Considerations
Security: API keys must be handled server-side to prevent exposure in client-side code Rate Limiting: 200 requests per 10 minutes per IP address with automatic backoff Error Handling: Standard HTTP status codes with detailed error responses Caching: Recommended for menu data and location information to reduce API calls Payment Flow: Requires Stripe integration for payment processingIntegration Approaches
1. Custom Frontend with Direct API Integration
Build your own frontend application that calls Crave’s API directly. Architecture:- Custom user experiences
- Existing React/Vue/Angular applications
- Teams with strong frontend capabilities
- Projects requiring unique workflows
- API key must be handled server-side
- Rate limiting applies per IP address
- Error handling is your responsibility
- Payment processing requires Stripe integration
2. Server-Side Proxy Pattern
Create a backend service that proxies requests to Crave’s API. Architecture:- Additional business logic layer
- Data transformation requirements
- Caching and performance optimization
- Security-sensitive applications
- Additional server infrastructure required
- More complex deployment
- Better security (API keys on server)
- Enables caching and data transformation
3. Hybrid Approach with Starter Template
Use Crave’s starter template as a foundation and customize it. Architecture:- Rapid development
- Standard ordering experiences
- Teams new to Crave
- MVP and proof-of-concept projects
- Pre-built components and patterns
- Faster time to market
- Limited customization initially
- Next.js based (React required)
Technical Implementation Details
Authentication Patterns
Client-Side (Not Recommended):Error Handling Patterns
Basic Error Handling:Caching Patterns
Memory Cache:Technology Stack Considerations
Frontend Frameworks
React/Next.js:Backend Options
Node.js/Express:Security Considerations
API Key Management
Environment Variables:CORS Configuration
Performance Optimization
Request Batching
Progressive Loading
Choosing Your Approach
Decision Matrix
Factor | Direct API | Server Proxy | Starter Template |
---|---|---|---|
Development Speed | Medium | Slow | Fast |
Customization | High | High | Medium |
Security | Medium | High | Medium |
Performance | Medium | High | Medium |
Complexity | Medium | High | Low |
Recommendations
Use Direct API Integration when:- You have existing frontend infrastructure
- You need maximum customization
- Your team has strong API integration experience
- You can handle server-side proxy setup
- You need additional business logic
- You require caching and performance optimization
- Security is a primary concern
- You have backend development resources
- You need to launch quickly
- You’re building a standard ordering experience
- Your team is new to Crave
- You’re creating an MVP or proof of concept
Next Steps
- Authentication Guide - Set up API keys
- Quick Start Tutorial - Build your first integration
- API Reference - Detailed endpoint documentation
- Stripe Integration - Payment processing setup