What is the Crave Storefront API?
The Crave Storefront API is a RESTful API designed specifically for building customer-facing online ordering experiences. It provides all the functionality needed to create custom storefronts, mobile apps, or other ordering interfaces.Base URL
All API requests should be made to the production API:Note: There is no local development server for the Crave API. All storefront applications connect directly to the production API using your API key.
Authentication
All API requests require authentication using an API key in the request header:API Capabilities
What You Can Do
The Storefront API enables you to:- Browse Menus: Get location information, menus, and products
- Manage Carts: Create and manage shopping carts with automatic pricing
- Process Payments: Create payment intents and handle checkout
- Configure Orders: Set delivery addresses, tips, and order times
- Apply Discounts: Apply and remove discount codes
What You Cannot Do
The Storefront API does not provide:- Order Management: View or modify existing orders (merchant-only)
- Menu Management: Create or edit menus (merchant-only)
- Customer Accounts: Persistent customer accounts or order history
- Real-time Updates: Live order tracking or status updates
- Admin Functions: Analytics, reporting, or merchant settings
API Structure
Location-Scoped Operations
All operations are scoped to a specific location (restaurant):Resource Groups
The API is organized into logical resource groups:- Locations: Restaurant location information and settings
- Menus: Menu categories and products
- Products: Individual menu items with pricing and modifiers
- Carts: Shopping cart management and pricing
- Cart Items: Add, update, and remove items from carts
- Customers: Basic customer information for orders
- Payments: Payment processing through Stripe
- Discounts: Discount codes and promotions
Request/Response Format
Request Format
All requests use JSON format:Response Format
All responses return JSON with consistent structure:HTTP Status Codes
The API uses standard HTTP status codes:- 200 OK: Request successful
- 201 Created: Resource created successfully
- 400 Bad Request: Invalid request data
- 401 Unauthorized: Invalid or missing API key
- 403 Forbidden: Merchant subscription required
- 404 Not Found: Resource not found
- 429 Too Many Requests: Rate limit exceeded
- 500 Internal Server Error: Server error
Rate Limiting
- Limit: 200 requests per 10 minutes per IP address
- Headers:
X-RateLimit-Remaining: Requests remaining in current windowX-RateLimit-Reset: When the rate limit resets (Unix timestamp)
- Exceeded: Returns 429 status with retry information
Data Types
Common Types
- ID: MongoDB ObjectId string (e.g.,
"64a7b8c9d1e2f3a4b5c6d7e8") - Slug: URL-friendly string (e.g.,
"downtown-pizza") - Price: Integer in cents (e.g.,
1299for $12.99) - Timestamp: ISO 8601 format (e.g.,
"2024-01-15T14:30:00Z") - Time: 24-hour format (e.g.,
"14:30")
Location Identifiers
Location IDs can be either:- ObjectId:
64a7b8c9d1e2f3a4b5c6d7e8 - Slug:
downtown-pizza
Error Handling
Common Errors
Best Practices
- Always check status codes: Don’t assume success
- Handle rate limits: Implement exponential backoff
- Parse error responses: Extract error details for debugging
- Implement retries: For temporary failures (5xx errors)
Getting Started
- Generate a storefront – Run
npx craveup initto clone a template and install dependencies. - Add credentials – Populate
.env.localwith your API key, location ID, and base URL (https://api.craveup.com/api/v1). - Call the API – Use the
@craveup/storefront-sdkor issue direct requests withfetch,axios, or your language of choice. - Explore endpoints – Start with:
Integration Examples
Basic Storefront Flow
Error Handling Example
Next Steps
- Core Concepts – Understand the data model
- CLI Quickstart – Scaffold and configure a storefront
- Storefront SDK – Consume the API with TypeScript
- Build a Custom Storefront – End-to-end walkthrough
Support
For API support and questions:- Email: [email protected]
- Documentation: This API reference
- Status: Check API status at status.craveup.com