Best Practices
Tips for building reliably with BareCommerceCore.
API Key Security
- Keep it secret. Don't commit API keys to Git. Use environment variables.
- Rotate regularly. Delete old keys and create new ones periodically.
- Use minimal scopes. Only request the permissions you need.
- Monitor usage. Check "Last Used" in your API keys dashboard to catch abuse.
Error Handling
Always handle errors gracefully:
try {
const response = await fetch(url, options);
if (!response.ok) {
const error = await response.json();
console.error(`API Error: ${error.error.code}`, error.error.details);
}
const data = await response.json();
return data;
} catch (error) {
console.error('Network error:', error);
}Pagination
For list endpoints, use pagination:
const response = await fetch(
`https://api.barecommercecore.com/api/stores/${storeId}/products?limit=50&offset=0`,
{ headers }
);
const { items, total } = await response.json();Testing
Before deploying:
- Test with real data — Use your actual store
- Test error cases — What happens when an order fails?
- Test edge cases — What if a product has no image?
- Load test — Can your integration handle 100 orders/minute?
Debugging
When something breaks:
- Check API responses — Print the full response and error details
- Verify credentials — Is the API key correct? Is it active?
- Check store ID — Are you using the right store?
- Review field names — Use our API reference
- Ask in Discord — We're here to help
Going Live
Checklist before production:
- API key is stored securely (environment variable)
- Error handling is implemented
- Webhook signatures are verified
- Inventory sync is working
- Order creation is tested
- Load testing is complete
Getting Help
- API Reference — Detailed endpoint documentation
- Integration Guides — Tool-specific setup
- Discord Community (opens in a new tab) — Real-time help
Happy building! 🚀