Setup & Configuration
Get the Bagisto API up and running in just a few minutes. Choose the installation method that works best for your setup.
Prerequisites
Before installing, ensure you have:
- Bagisto v2.0 or higher installed
- PHP 8.2+
- Composer 2.0+
- Laravel 11.x
- MySQL 8.0+
Installation Methods
Method 1: Quick Start (Composer Installation – Recommended)
The fastest way to get started:
# 1. Install the Bagisto API package
composer require bagisto/bagisto-api
# 2. Run the installer
php artisan bagisto-api:install
# 3. Run database migrations
php artisan migrate
# 4. Clear and rebuild caches
php artisan optimize:clear
php artisan optimize
# 5. Create your first API key
php artisan bagisto-api:generate-key --name="Default Store"Your APIs are now ready! Access them at:
- REST API Docs:
https://your-domain.com/api/docs - GraphQL Playground:
https://your-domain.com/graphql
Method 2: Manual Installation
Use this method if you need more control over the setup.
Step 1: Download and Extract
- Download the BagistoApi package from GitHub
- Extract it to:
packages/Webkul/BagistApi/
Step 2: Register Service Provider
Edit bootstrap/providers.php:
<?php
return [
// ...existing providers...
Webkul\BagistApi\Providers\BagistApiServiceProvider::class,
// ...rest of providers...
];Step 3: Update Autoloading
Edit composer.json and update the autoload section:
{
"autoload": {
"psr-4": {
"Webkul\\BagistApi\\": "packages/Webkul/BagistApi/src",
}
}
}Step 4: Install Dependencies
# Install required packages
composer require api-platform/laravel:^4.1
composer require api-platform/graphql:^4.2Step 5: Run the installation
php artisan bagisto-api:installStep 6: Run database migrations
php artisan migrateStep 7: Clear caches
php artisan optimize:clear
php artisan optimizeStep 8: Create your first API key
php artisan bagisto-api:generate-key --name="Default Store"Step 9: Environment Setup (Update in the .env)
STOREFRONT_DEFAULT_RATE_LIMIT=100 STOREFRONT_CACHE_TTL=60 STOREFRONT_KEY_PREFIX=storefront_key_ STOREFRONT_PLAYGROUND_KEY=pk_storefront_vxLIYv5PIp7jkujPNGLFQoDvIdsh2RMF API_PLAYGROUND_AUTO_INJECT_STOREFRONT_KEY=true
Access Points
Once verified, access the APIs at:
- REST API Documentation:
https://your-domain.com/api - REST API (Shop):
https://your-domain.com/api/shop/* - REST API (Admin):
https://your-domain.com/api/admin/* - GraphQL Endpoint:
https://your-domain.com/graphql - GraphQL Playground:
https://your-domain.com/graphqli
Troubleshooting
Provider Not Found
Error: Class 'Webkul\BagistApi\Providers\BagistApiServiceProvider' not found
Solution:
composer dump-autoload
php artisan cache:clear
php artisan config:clear404 Errors on API Endpoints
Error: API endpoints return 404 Not Found
Solutions:
- Ensure routes are published:
php artisan vendor:publish --tag=routes - Clear route cache:
php artisan route:clear - Check
.htaccessfile is present in your web root - Verify
APP_URLin.envmatches your domain
Permission Denied Errors
Error: Permission denied on file operations
Solution:
# Set proper permissions
chmod -R 775 storage bootstrap/cache
chmod -R 755 public
# If using Docker/VM
chown -R www-data:www-data storage bootstrapDatabase Connection Errors
Error: SQLSTATE[HY000]: General error: 1030 Got error
Solutions:
- Verify database credentials in
.env - Run migrations:
php artisan migrate - Check database encoding:
utf8mb4 - Ensure sufficient disk space
Rate Limiting Issues
Error: 429 Too Many Requests
Solutions:
- Check rate limit configuration:
php artisan config:show bagisto-api - Update rate limit in
.env:BAGISTO_API_RATE_LIMIT=200 - Clear rate limit cache:
php artisan cache:forget rate_limit
CORS Errors in Browser
Error: Access to XMLHttpRequest blocked by CORS policy
Solutions:
- Verify CORS is configured in
config/cors.php - Check
FRONTEND_URLenvironment variable - Ensure
supports_credentialsis set properly - Clear browser cache
Performance Optimization
Ensure the application is running in a production environment and that APP_DEBUG is set to false.
# Clear cached configuration and other optimized files
php artisan optimize:clear
# Rebuild and optimize caches
php artisan optimizeWhat's Next?
Ready to start using the APIs?
- 🔐 Authentication Guide - Learn about authentication methods
- 🔗 REST API Guide - Explore REST API endpoints
- ⚡ GraphQL API Guide - Discover GraphQL capabilities
- 🔑 API Key Management - Generate and manage API keys

