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 these merchant-side features (available through the Crave merchant dashboard):- Order Management: View or modify existing orders
- Menu Management: Create or edit menus
- 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.,
1299
for $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
1. Obtain API Key
Contact your merchant partner to obtain an API key for their location.2. Set Up Environment
Important: Always use the production API URL (https://api.cravejs.com
) in your environment variables.
3. Make Your First Request
4. Explore the API
Start with these common operations:- Get Location Info - Basic location details
- Get Menu - Browse available products
- Create Cart - Start a new order
- Add Items - Add products to cart
- Create Payment Intent - Process payment
Integration Examples
Basic Storefront Flow
Error Handling Example
Available Endpoints
Cart Management
- POST
/locations/{locationId}/carts
- Create a new cart - GET
/locations/{locationId}/carts/{cartId}
- Get cart details - DELETE
/locations/{locationId}/carts/{cartId}
- Delete a cart - PUT
/locations/{locationId}/carts/{cartId}/validate-and-update
- Validate and update order - PUT
/locations/{locationId}/carts/{cartId}/gratuity
- Update gratuity
Cart Items
- POST
/locations/{locationId}/carts/{cartId}/cart-item
- Add item to cart - PATCH
/locations/{locationId}/carts/{cartId}/cart-item/{itemId}/quantity
- Update cart item quantity
Customer Authentication
- POST
/login-customer
- Login or register customer - POST
/verify-otp
- Verify OTP - GET
/customer
- Get customer details - DELETE
/customer/logout
- Logout customer
Customer Data
- GET
/customer/saved-payments
- Get customer saved payments - DELETE
/customer/saved-payments/{paymentId}
- Delete saved payment method - GET
/orders
- Get customer orders (placeholder implementation) - GET
/addresses
- Get customer addresses (placeholder implementation)
Note: Customer authentication and data endpoints are implemented but may require additional configuration for production deployment. The/orders
and/addresses
endpoints currently return placeholder responses while full functionality is under development.
Location & Menu
- GET
/locations/{locationSlugOrId}
- Get location basic info - GET
/locations/{locationId}/menus
- Get location menus - GET
/locations/{locationId}/time-intervals
- Get order time intervals - GET
/locations/{locationId}/gratuity
- Get gratuity configuration - GET
/locations/{locationId}/redirect
- Redirect to storefront URL
Products
- GET
/locations/{locationId}/products
- Get products by location - GET
/locations/{locationId}/products/popular
- Get popular products - GET
/locations/{locationId}/products/{productId}
- Get product details
Discounts
- POST
/locations/{locationId}/discounts/apply-discount
- Apply discount code - DELETE
/locations/{locationId}/discounts/apply-discount
- Remove discount code
Payments
- GET
/stripe/payment-intent
- Generate Stripe payment intent (requires locationId and cartId parameters)
Next Steps
- Core Concepts - Understand the data model
- Quick Start Guide - Build your first integration
- API Reference - Detailed endpoint documentation
- Integration Guides - Practical examples
Support
For API support and questions:- Email: hello@craveup.com
- Documentation: This API reference
- Status: Check API status at status.craveup.com