Appearance
FluentCart REST API
FluentCart provides a comprehensive REST API that allows developers to interact with all e-commerce functionality programmatically. The API is built on WordPress's REST API foundation with FluentCart-specific endpoints and authentication.
API Overview
The FluentCart REST API provides programmatic access to:
- Order Management - Create, read, update, and manage orders
- Customer Management - Handle customer data and relationships
- Product Management - Manage products, variations, and pricing
- Payment Processing - Handle payments and transactions
- Subscription Management - Manage recurring subscriptions
- Coupon System - Apply and manage discount coupons
- File Management - Handle file uploads and downloads
- Settings Management - Configure store and module settings
Base URL
All API endpoints are prefixed with the WordPress REST API base URL:
https://yoursite.com/wp-json/fluent-cart/v2/
Authentication
FluentCart uses WordPress's built-in authentication system with additional policy-based authorization:
1. WordPress Authentication
- Cookie Authentication - For logged-in users
- Application Passwords - For external applications
- OAuth - For third-party integrations
2. Policy-Based Authorization
FluentCart implements a policy system for fine-grained access control:
- AdminPolicy - Super admin access
- OrderPolicy - Order management permissions
- CustomerPolicy - Customer management permissions
- ProductPolicy - Product management permissions
- CouponPolicy - Coupon management permissions
Authentication Example
php
// Using WordPress Application Passwords
$headers = [
'Authorization' => 'Basic ' . base64_encode('username:application_password'),
'Content-Type' => 'application/json'
];
$response = wp_remote_get('https://yoursite.com/wp-json/fluent-cart/v1/orders', [
'headers' => $headers
]);
Response Format
All API responses follow a consistent JSON format:
Success Response
json
{
"success": true,
"data": {
// Response data
},
"message": "Operation completed successfully"
}
Error Response
json
{
"success": false,
"error": {
"code": "error_code",
"message": "Error description"
}
}
Pagination
List endpoints support pagination using WordPress's standard pagination parameters:
page
- Page number (default: 1)per_page
- Items per page (default: 10, max: 100)
Pagination Response
json
{
"data": [...],
"pagination": {
"current_page": 1,
"per_page": 10,
"total": 100,
"total_pages": 10
}
}
Core Endpoints
Orders API
GET /orders
- List ordersPOST /orders
- Create orderGET /orders/{id}
- Get order detailsPUT /orders/{id}
- Update orderDELETE /orders/{id}
- Delete orderPOST /orders/{id}/mark-as-paid
- Mark order as paidPOST /orders/{id}/refund
- Refund orderPUT /orders/{id}/statuses
- Update order statuses
View Orders API Documentation →
Customers API
GET /customers
- List customersPOST /customers
- Create customerGET /customers/{id}
- Get customer detailsPUT /customers/{id}
- Update customerGET /customers/{id}/orders
- Get customer ordersGET /customers/{id}/address
- Get customer addressesPUT /customers/{id}/address
- Update customer address
View Customers API Documentation →
Products API
GET /products
- List productsPOST /products
- Create productGET /products/{id}
- Get product detailsPUT /products/{id}
- Update productDELETE /products/{id}
- Delete productGET /products/variants
- List product variationsPOST /products/variants
- Create product variationPUT /products/variants/{id}
- Update product variation
View Products API Documentation →
Subscriptions API
GET /subscriptions
- List subscriptionsGET /subscriptions/{id}
- Get subscription detailsPUT /subscriptions/{id}
- Update subscriptionPOST /subscriptions/{id}/cancel
- Cancel subscriptionPOST /subscriptions/{id}/reactivate
- Reactivate subscription
View Subscriptions API Documentation →
Coupons API
GET /coupons
- List couponsPOST /coupons
- Create couponGET /coupons/{id}
- Get coupon detailsPUT /coupons/{id}
- Update couponDELETE /coupons/{id}
- Delete couponPOST /coupons/apply
- Apply couponPOST /coupons/cancel
- Cancel coupon
Settings API
GET /settings/store
- Get store settingsPOST /settings/store
- Update store settingsGET /settings/payment-methods
- Get payment method settingsPOST /settings/payment-methods
- Update payment method settingsGET /settings/storage-drivers
- Get storage driver settingsPOST /settings/storage-drivers
- Update storage driver settings
File Management API
GET /files
- List filesPOST /files/upload
- Upload fileDELETE /files/delete
- Delete fileGET /files/bucket-list
- Get file bucket list
Integration API
GET /integration/global-settings
- Get global integration settingsPOST /integration/global-settings
- Update global integration settingsGET /integration/global-feeds
- Get integration feedsPOST /integration/global-feeds/settings
- Save integration feed settings
Reports API
GET /reports/overview
- Get overview reportGET /reports/orders
- Get order reportGET /reports/customers
- Get customer reportGET /reports/products
- Get product reportGET /reports/revenue
- Get revenue report
Pro Endpoints ⭐ PRO ONLY
Licensing API (Pro)
GET /licenses
- List licensesPOST /licenses
- Create licenseGET /licenses/{id}
- Get license detailsPUT /licenses/{id}
- Update licensePOST /licenses/{id}/activate
- Activate license
View Licensing API Documentation →
Roles & Permissions API (Pro)
GET /settings/permissions
- Get permissionsPOST /settings/permissions
- Update permissionsGET /users/{id}/capabilities
- Get user capabilitiesPOST /users/{id}/capabilities
- Update user capabilities
View Roles & Permissions API Documentation →
Order Bump API (Pro)
GET /order-bumps
- List order bumpsPOST /order-bumps
- Create order bumpGET /order-bumps/{id}
- Get order bump detailsPUT /order-bumps/{id}
- Update order bumpDELETE /order-bumps/{id}
- Delete order bump
View Order Bump API Documentation →
Frontend Endpoints
Cart API
GET /cart
- Get cart contentsPOST /cart/add
- Add item to cartPUT /cart/update
- Update cart itemDELETE /cart/remove
- Remove item from cartPOST /cart/apply-coupon
- Apply coupon to cart
Checkout API
POST /checkout/process
- Process checkoutGET /checkout/shipping-methods
- Get shipping methodsPOST /checkout/calculate-shipping
- Calculate shipping
Public API
GET /public/products
- Get public product catalogGET /public/products/{id}
- Get public product detailsGET /public/categories
- Get product categories
Error Handling
The API uses standard HTTP status codes:
200
- Success201
- Created400
- Bad Request401
- Unauthorized403
- Forbidden404
- Not Found422
- Validation Error500
- Internal Server Error
Error Response Example
json
{
"success": false,
"error": {
"code": "validation_error",
"message": "The given data was invalid.",
"details": {
"email": ["The email field is required."],
"name": ["The name field must be at least 3 characters."]
}
}
}
Rate Limiting
API requests are subject to rate limiting to prevent abuse:
- Authenticated requests: 1000 requests per hour
- Unauthenticated requests: 100 requests per hour
- Bulk operations: 10 requests per hour
Rate limit headers are included in responses:
X-RateLimit-Limit: 1000
X-RateLimit-Remaining: 999
X-RateLimit-Reset: 1640995200
Webhooks
FluentCart supports webhooks for real-time notifications:
POST /webhook/feed
- Create webhookGET /webhook/feed
- List webhooksGET /webhook/feed/{id}
- Get webhook detailsPUT /webhook/feed/{id}
- Update webhookDELETE /webhook/feed/{id}
- Delete webhook
Webhook Events
order.created
- Order createdorder.updated
- Order updatedorder.paid
- Order paidsubscription.created
- Subscription createdsubscription.cancelled
- Subscription cancelledpayment.success
- Payment successfulpayment.failed
- Payment failed
SDK and Libraries
JavaScript SDK
javascript
import FluentCartAPI from 'fluent-cart-sdk';
const api = new FluentCartAPI({
baseURL: 'https://yoursite.com/wp-json/fluent-cart/v1',
apiKey: 'your-api-key'
});
// Get orders
const orders = await api.orders.list();
// Create order
const order = await api.orders.create({
customer_id: 123,
items: [
{ product_id: 456, quantity: 2 }
]
});
PHP SDK
php
use FluentCart\API\Client;
$client = new Client([
'base_url' => 'https://yoursite.com/wp-json/fluent-cart/v1',
'api_key' => 'your-api-key'
]);
// Get orders
$orders = $client->orders()->list();
// Create order
$order = $client->orders()->create([
'customer_id' => 123,
'items' => [
['product_id' => 456, 'quantity' => 2]
]
]);
Testing
Postman Collection
Download the FluentCart API Postman collection for easy testing: Download Postman Collection
API Testing Tools
- Postman - GUI-based API testing
- Insomnia - Alternative API testing tool
- curl - Command-line testing
- HTTPie - User-friendly command-line tool
Example curl Commands
bash
# Get orders
curl -X GET "https://yoursite.com/wp-json/fluent-cart/v1/orders" \
-H "Authorization: Basic dXNlcm5hbWU6YXBwbGljYXRpb25fcGFzc3dvcmQ="
# Create order
curl -X POST "https://yoursite.com/wp-json/fluent-cart/v1/orders" \
-H "Authorization: Basic dXNlcm5hbWU6YXBwbGljYXRpb25fcGFzc3dvcmQ=" \
-H "Content-Type: application/json" \
-d '{
"customer_id": 123,
"items": [
{"product_id": 456, "quantity": 2}
]
}'
Support and Resources
Community Support
- GitHub Issues - Bug reports and feature requests
- Developer Community - Community discussions
- Documentation Issues - Documentation improvements
Professional Support
- API Support - Priority support for API issues
- Custom Development - Custom API integrations
- Training - API development training
Related Documentation
- Database Models - Data models used by API endpoints
- Developer Hooks - Hooks triggered by API operations
- Module System - Modules that extend API functionality
- Frontend Development - Frontend API integration
- Integration Guide - Third-party API integrations
Next Steps
Continue with API development:
- Authentication Guide - Learn about API authentication
- Orders API - Start with order management endpoints
- Customers API - Customer management endpoints
- Products API - Product catalog endpoints
Previous/Next Navigation
- Previous: Developer Hooks - Extending FluentCart functionality
- Next: Module System - Building custom modules