Overview
Storefront applications use API key authentication to access the Crave API. This is a simple, secure way to authenticate your requests without complex session management.Getting Your API Key
Developer Dashboard (Recommended)
- Visit dashboard.craveup.com/developers
- Sign up or log in to your Crave developer account
- Navigate to API Keys in the developer section
- Create a new API key with appropriate permissions
- Copy and securely store your API key
- Note your Location ID from the dashboard
Alternative Methods
- Merchant Partnership: Contact your merchant partner directly
- API Generation: Admin API endpoints (Enterprise tier only - contact support for beta access)
- Support: Email hello@craveup.com for assistance
Environment Setup
Add these environment variables to your.env.local
:
Making Authenticated Requests
Include your API key in theX-API-Key
header:
API Client Helper
Create a simple API client for consistency:Rate 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
Error Handling
Common error responses:Security Best Practices
- Never expose API keys in client-side code
- Use environment variables for key storage
- Use HTTPS in production
- Implement proper error handling