bagisto/bagisto-api
Comprehensive REST and GraphQL APIs for Bagisto e-commerce, exposing shop and admin endpoints via API Platform. Requires PHP 8.3+ and Bagisto 2.4.7. Quick Composer install plus an artisan command gets API docs, GraphiQL playgrounds, and storefront rate limiting running fast.
Comprehensive REST and GraphQL APIs for seamless e-commerce integration and extensibility.
api-platform/laravel and api-platform/graphql (~4.3.8), which bring in the remaining api-platform/* components at a matching version, installed automatically via composer requireThe fastest way to get started:
composer require bagisto/bagisto-api
php artisan bagisto-api-platform:install
Your APIs are now ready! Access them at:
https://your-domain.com/apihttps://your-domain.com/api/shop/docshttps://your-domain.com/api/admin/docshttps://your-domain.com/api/graphiqlhttps://your-domain.com/api/admin/graphiqlUse this method if you need more control over the setup.
packages/Webkul/BagistoApi/Edit bootstrap/providers.php:
<?php
return [
// ...existing providers...
Webkul\BagistoApi\Providers\BagistoApiServiceProvider::class,
// ...rest of providers...
];
Edit composer.json and update the autoload section:
{
"autoload": {
"psr-4": {
"Webkul\\BagistoApi\\": "packages/Webkul/BagistoApi/src"
}
}
}
composer require \
api-platform/laravel:~4.3.8 \
api-platform/graphql:~4.3.8
php artisan bagisto-api-platform:install
STOREFRONT_DEFAULT_RATE_LIMIT=100
STOREFRONT_CACHE_TTL=60
STOREFRONT_KEY_PREFIX=storefront_key_
STOREFRONT_PLAYGROUND_KEY=pk_storefront_xxxxxxxxxxxxxxxxxxxxxxxxxx
API_PLAYGROUND_AUTO_INJECT_STOREFRONT_KEY=true
Once verified, access the APIs at:
Generate schema files for the shop and admin APIs — OpenAPI JSON (REST) and GraphQL SDL — to import into Postman, a client/code generator, or a mock server without calling a live server:
php artisan bagisto-api-platform:export-schema
The files are written to schema/generated/:
| File | Contents |
|---|---|
openapi-shop.json / openapi-admin.json |
OpenAPI for each REST surface |
shop.graphql / admin.graphql |
GraphQL SDL for each surface |
graphql-operations-shop.json / -admin.json |
Every root GraphQL field mapped to its resource tag |
Each spec is scoped to its own surface: the storefront spec contains no admin path, schema, or tag, and the admin spec contains no storefront one. The command refuses to write a schema that leaks another surface, references a definition it does not include, carries an unused definition, or contains a storefront key.
Options:
--path=<dir> — write to a different directory--transport=all|rest|graphql — limit to one transport (default all)Re-running overwrites those six files and nothing else. schema/tools/build-collection.php turns the exported specs into the Postman collections; it takes the target directory as an argument:
php schema/tools/build-collection.php /path/to/bagisto-api-collection/collections
Ready-to-import Postman collections for both API surfaces live in their own repository:
github.com/bagisto/bagisto-api-collection
Import a collection and its environment there, fill in your store URL and a key, and every endpoint is ready to send — REST and GraphQL, for both the storefront and the admin API. That repository is the one to point clients and integrators at; this package holds the schemas the collections are generated from.
Admin endpoints (/api/admin/* and /api/admin/graphql) require an integration-token Bearer header:
Authorization: Bearer id|generated-token
To generate a token:
All, Custom, or Same as Web) / optional IP allowlist / rate limits / expiry, and save as a draft.Each token is scoped to a single admin user and inherits that admin's role permissions — so tokens can never do more than their owner could in the admin UI. To issue tokens to multiple admins, create one token per admin (each admin can hold only one active token at a time).
Tokens can be revoked at any time from the same page or via the signed link in the lifecycle notification email sent to the token owner.
CHANGELOG.mdFor issues and questions, please visit:
The Bagisto API Platform is open-source software licensed under the MIT license.
How can I help you explore Laravel packages today?