API Key Management
Location API Keys
Each restaurant location has its own API key for accessing the public API endpoints. These keys are provided when your location is set up through the Crave merchant dashboard. Your location credentials will be provided in this format:API Access Tiers
The Crave API has different access levels:API Type | Subscription Required | Features Included |
---|---|---|
Storefront APIs | Any paid Crave subscription | Menu browsing, cart management, payment processing, basic customer data |
Admin APIs | Enterprise tier only | Order management, menu editing, analytics, webhooks |
Contact hello@craveup.com for location setup and API key provisioning.
Authentication Methods
1. API Key Header
The most common method for public API access:2. JavaScript/React Integration
3. Environment Variables
Store API keys securely using environment variables:Rate Limiting
The Crave.js API implements rate limiting to ensure fair usage and system stability:Default Limits
- 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
Rate Limit Headers
Every API response includes rate limit information:Handling Rate Limits
Security Best Practices
1. API Key Security
Do’s:
- Store API keys in environment variables
- Use different keys for development/staging/production
- Rotate keys regularly
- Monitor API key usage
Don’ts:
- Never commit API keys to version control
- Don’t expose API keys in client-side code
- Avoid hardcoding keys in your application
- Don’t share keys across different environments
2. CORS Configuration
Configure CORS properly for frontend integration:3. HTTPS in Production
Always use HTTPS in production:4. Input Validation
Validate all inputs on both client and server:Error Handling
Common Error Codes
Code | Description | Action |
---|---|---|
401 | Invalid API key | Check API key validity |
403 | Insufficient permissions | Verify endpoint access |
429 | Rate limit exceeded | Implement retry logic |
500 | Server error | Check API status |
Error Response Format
Comprehensive Error Handling
Next Steps
- Deployment Guide - Deploy your API securely
- Examples & Use Cases - Real-world implementations
- Payment Security - Handle payments securely
- Monitoring & Logging - Track API usage and performance