Editor - API Reference
The O2VEND Theme Editor provides API endpoints for programmatic theme management. This guide covers the editor API.
API Overview
Editor API endpoints:
- Theme management
- File operations
- Widget management
- Settings configuration
- Publishing operations
Base URL
All editor API requests:
https://your-store.o2vend.com/editor/webstoreapi
Authentication
Editor API requires:
- Tenant context (from hostname)
- Valid session
- Appropriate permissions
Theme Endpoints
List Themes
Get all available themes:
GET /editor/webstoreapi/themes
Response:
[
{
"name": "default",
"path": "/path/to/theme",
"source": "local"
},
{
"name": "modern",
"path": "/path/to/theme",
"source": "repository"
}
]
Get Theme
Get specific theme:
GET /editor/webstoreapi/themes/:themeName
Response:
{
"name": "default",
"path": "/path/to/theme"
}
Load Theme
Load theme for editing:
POST /editor/webstoreapi/themes/load
Content-Type: application/json
{
"themeName": "default"
}
Response:
{
"success": true,
"theme": "default"
}
File Endpoints
Get File Tree
Get theme file structure:
GET /editor/webstoreapi/themes/:themeName/files
Response:
{
"files": [
{
"path": "layout/theme.liquid",
"type": "file",
"size": 1234
},
{
"path": "templates",
"type": "directory",
"children": [...]
}
]
}
Get File Content
Get file content:
GET /editor/webstoreapi/themes/:themeName/files/*path
Response:
{
"content": "file content here",
"path": "layout/theme.liquid"
}
Save File
Save file changes:
PUT /editor/webstoreapi/themes/:themeName/files/*path
Content-Type: application/json
{
"content": "updated file content"
}
Response:
{
"success": true,
"path": "layout/theme.liquid"
}
Create File
Create new file:
POST /editor/webstoreapi/themes/:themeName/files
Content-Type: application/json
{
"path": "snippets/new-snippet.liquid",
"content": "file content"
}
Response:
{
"success": true,
"path": "snippets/new-snippet.liquid"
}
Delete File
Delete file:
DELETE /editor/webstoreapi/themes/:themeName/files/*path
Response:
{
"success": true,
"path": "snippets/old-snippet.liquid"
}
Widget Endpoints
Get Widgets
Get widgets for page section:
GET /editor/webstoreapi/widgets/:pageId/:section
Response:
{
"widgets": [
{
"id": "widget-123",
"type": "ProductWidget",
"section": "hero",
"position": 1,
"settings": {...}
}
]
}
Create Widget
Create new widget:
POST /editor/webstoreapi/widgets/:pageId/:section
Content-Type: application/json
{
"type": "ProductWidget",
"settings": {
"title": "Featured Products"
}
}
Response:
{
"success": true,
"widget": {
"id": "widget-123",
"type": "ProductWidget"
}
}
Update Widget
Update widget:
PUT /editor/webstoreapi/widgets/:pageId/:section/:widgetId
Content-Type: application/json
{
"settings": {
"title": "Updated Title"
}
}
Response:
{
"success": true,
"widget": {...}
}
Delete Widget
Delete widget:
DELETE /editor/webstoreapi/widgets/:pageId/:section/:widgetId
Response:
{
"success": true
}
Settings Endpoints
Get Settings
Get theme settings:
GET /editor/webstoreapi/themes/:themeName/settings_data
Response:
{
"current": {
"primary_color": "#000000",
"store_name": "My Store"
}
}
Update Settings
Update theme settings:
PUT /editor/webstoreapi/themes/:themeName/settings_data
Content-Type: application/json
{
"current": {
"primary_color": "#ff0000"
}
}
Response:
{
"success": true
}
Publishing Endpoints
Publish Theme
Publish theme to tenant repository:
POST /editor/webstoreapi/themes/:themeName/publish
Response:
{
"success": true,
"version": "1.0.0"
}
Activate Theme
Activate published theme:
POST /editor/webstoreapi/themes/:themeName/activate
Response:
{
"success": true,
"theme": "default"
}
Error Handling
Error Response Format
{
"error": "Error message",
"code": "ERROR_CODE",
"details": {...}
}
Common Errors
401 Unauthorized:
{
"error": "Unauthorized",
"code": "UNAUTHORIZED"
}
404 Not Found:
{
"error": "Theme not found",
"code": "NOT_FOUND"
}
500 Server Error:
{
"error": "Internal server error",
"code": "SERVER_ERROR"
}
API Examples
JavaScript Example
const editorApi = {
baseUrl: '/editor/webstoreapi',
async getThemes() {
const response = await fetch(`${this.baseUrl}/themes`);
return response.json();
},
async getFile(themeName, filePath) {
const response = await fetch(
`${this.baseUrl}/themes/${themeName}/files/${filePath}`
);
return response.json();
},
async saveFile(themeName, filePath, content) {
const response = await fetch(
`${this.baseUrl}/themes/${themeName}/files/${filePath}`,
{
method: 'PUT',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ content })
}
);
return response.json();
}
};
Rate Limiting
API requests are rate-limited:
- Monitor rate limit headers
- Implement retry logic
- Handle rate limit errors
Next Steps
- Getting Started - Editor basics
- File Management - File operations
- Publishing - Publish themes