The REST API provides programmatic access to all Vvveb data entities via standard HTTP methods.
Enabling
The API is enabled by default (defined('REST') || define('REST', true) in env.php) and accessible at /rest/. To disable it, define REST as false before the default applies.
For setup details, CORS and headless usage see REST API Setup.
Authentication
The auth mode is selected by config/rest.php (auth.mode): token (default) or http. In token mode send a Bearer token - an Authorization: Bearer <token> / Bearer header or a _token query parameter - validated with Admin::auth($token) using any admin user's API token. In http mode use HTTP Basic Auth (PHP_AUTH_USER/PHP_AUTH_PW) validated with Admin::login(). An authenticated admin session (cookie) also works. Permissions come from the admin's rest role rules (resource + action).
# HTTP Basic Auth
curl --user demo:demo 'https://demo.vvveb.com/rest/posts/hello-world-1'
# Bearer token
curl -H 'Authorization: Bearer mytoken' 'https://demo.vvveb.com/rest/posts/hello-world-1'
Admin endpoints require an authenticated admin with the appropriate role permissions. Front-end endpoints (products, posts) are publicly readable.
Endpoints
All endpoints follow the pattern: /rest/{resource} or /rest/{resource}/{id}. The full list of resources is defined in config/rest-routes.php; most database entities are exposed automatically.
Content
| Method | Endpoint | Description |
|---|---|---|
| GET | /rest/posts |
List posts (paginated) |
| GET | /rest/posts/{slug} or /rest/posts/#post_id# |
Get single post by slug or id |
| GET | /rest/posts/#post_id#/comment |
Post comments |
| GET | /rest/posts/#post_id#/revision |
Post revisions |
| GET | /rest/taxonomies |
List taxonomies (categories, tags, ...) |
| GET | /rest/taxonomy_items |
List taxonomy items |
| GET | /rest/menus |
List menus |
| GET | /rest/menu-items |
List menu items |
Products
| Method | Endpoint | Description |
|---|---|---|
| GET | /rest/products |
List products |
| GET | /rest/products/{slug} or /rest/products/#product_id# |
Get single product by slug or id |
| GET | /rest/attributes |
Product attributes |
| GET | /rest/attribute_groups |
Attribute groups |
| GET | /rest/options / /rest/option_value |
Product options and option values |
| GET | /rest/manufacturers |
Manufacturers |
| GET | /rest/vendors |
Vendors |
| GET | /rest/digital_assets |
Digital (downloadable) assets |
Users & Orders
| Method | Endpoint | Description |
|---|---|---|
| GET | /rest/users |
List users (admin) |
| GET | /rest/orders |
List orders (admin) |
| GET | /rest/orders/{id} |
Get single order |
| GET | /rest/subscriptions |
List subscriptions |
| GET | /rest/coupons |
List coupons |
| GET | /rest/user_addresses |
User addresses |
| GET | /rest/user_wishlists |
User wishlists |
| GET | /rest/vouchers |
Vouchers |
Cart
| Method | Endpoint | Description |
|---|---|---|
| GET | /rest/cart |
Get current cart |
| POST | /rest/cart/{product_id} |
Add item to cart |
| DELETE | /rest/cart/{key} |
Remove item from cart |
System
| Method | Endpoint | Description |
|---|---|---|
| GET | /rest/settings |
List settings (admin) |
| GET | /rest/sites |
List sites |
| GET | /rest/languages |
List languages |
| GET | /rest/currencies |
List currencies |
| GET | /rest/countries |
List countries |
| GET | /rest/regions |
List regions |
| GET | /rest/roles |
List roles |
| GET | /rest/media |
List media files |
| GET | /rest/plugins / /rest/themes |
Installed plugins/themes |
Example Requests
# List products
curl -b cookies.txt http://localhost/rest/products
# Get single product
curl -b cookies.txt http://localhost/rest/products/42
# Add to cart
curl -b cookies.txt -X POST http://localhost/rest/cart/42
# List posts with pagination
curl -b cookies.txt "http://localhost/rest/posts?start=0&limit=10"
Response Format
All responses are JSON:
{
"product": [
{
"product_id": 1,
"name": "Product Name",
"price": "29.99",
"image": "/media/product-image.jpg",
"url": "/product/product-name"
}
],
"total": 100
}
Configuration
REST-specific configuration in config/rest.php (plain-array config):
return [
'auth' => ['mode' => 'token'], // or 'http' for HTTP Basic Auth
'session' => ['driver' => 'request'],
'email' => ['driver' => 'mail'],
'cache' => ['driver' => 'file', 'servers' => [], /* ... */],
// ...
];
Routes are defined in config/rest-routes.php (/rest/{resource} patterns mapping to default / default/crud/index / cart/cart modules with per-route methods and schema).
Extending
Plugins can add custom REST endpoints by:
- Creating controllers in
plugins/{plugin}/app/controller/(front-end) orplugins/{plugin}/admin/controller/(admin) - Adding routes via
Routes::addRoute()in the plugin'sapp()method or via theRoutes::initevent - Registering new resources