A comprehensive REST API plugin for Revive Adserver that provides RESTful endpoints for managing campaigns, banners, zones, targeting, and statistics. Features a complete API token management system with admin panel interface for secure authentication and granular permissions. Fully compatible with the revive-adserver-mcp server.
- ✅ Campaign Management - Complete CRUD operations for advertising campaigns
- ✅ Banner Management - Upload, manage, and configure banner advertisements
- ✅ Zone Configuration - Configure and manage advertising zones and placements
- ✅ Advanced Targeting - Geographic, time-based, device, and URL targeting with rule sets
- ✅ Statistics & Analytics - Comprehensive performance reporting and metrics
- ✅ File Upload System - Secure banner file uploads with validation
- ✅ API Token Management - Complete token-based authentication system
- ✅ Admin Panel - Web-based interface for token and settings management
- ✅ Permission System - Granular permissions (16 different access levels)
- ✅ Session Authentication - Integration with existing Revive admin sessions
- ✅ Rate Limiting - Configurable per-IP request limits and security controls
- ✅ Usage Analytics - Complete audit trail and token usage monitoring
- ✅ MCP Compatible - Full integration with revive-adserver-mcp
- ✅ CORS Support - Cross-origin request handling for web applications
- ✅ REST Standards - RESTful API design with consistent JSON responses
- ✅ Revive Integration - Native integration with Revive Adserver 5.x
- Revive Adserver 5.0+
- PHP 7.4+
- MySQL 5.7+ or MariaDB 10.3+
The easiest way to install this plugin is using the Revive Adserver built-in plugin installer:
-
Download the Plugin Package
- Go to the Releases page
- Download the latest
reviveRestApi-X.X.X.zipfile
-
Access Plugin Installer
- Log into your Revive Adserver admin panel
- Navigate to Plugins → Plugin Administration
-
Install Plugin
- Click the "Install Plugin" button
- Choose "Upload a plugin"
- Select the downloaded
reviveRestApi-X.X.X.zipfile - Click "Upload" to install
-
Activate Plugin
- After upload, find "Revive REST API (MCP Compatible)" in the plugin list
- Click "Install" to activate the plugin
- The plugin status should change to "Enabled"
-
Configure Settings
- Click "Settings" next to the plugin
- Configure the API Base Path (default:
/api/v1) - Save your settings
-
Verify Installation
- Test the API health endpoint:
http://yoursite.com/api/v1/health - You should receive a JSON response confirming the API is working
- Test the API health endpoint:
-
Access Token Management
- Navigate to:
http://yoursite.com/plugins/reviveRestApi/www/admin/ - Create and manage API tokens through the web interface
- Configure API settings and security controls
- Navigate to:
If you prefer manual installation:
-
Download Plugin Files
- Download the latest release ZIP file
- Extract the contents
-
Upload to Server
- Upload the
reviveRestApifolder to:/path/to/revive/plugins/ - Ensure proper file permissions (readable by web server)
- Upload the
-
Install via Admin Panel
- Access your Revive admin panel
- Navigate to Plugins → Plugin Administration
- Find "Revive REST API (MCP Compatible)" and click Install
- Configure plugin settings as needed
If using the Docker setup from this repository:
# Plugin is already included in the container
docker-compose up -dPlugin Not Showing Up:
- Verify the ZIP file was uploaded correctly
- Check file permissions on the plugins directory
- Ensure Revive Adserver version compatibility (5.0+)
Upload Fails:
- Check PHP upload limits (
upload_max_filesize,post_max_size) - Verify disk space on server
- Ensure web server has write permissions to plugins directory
API Not Working After Install:
- Clear any caches (browser, CDN, server-side)
- Check web server URL rewriting is enabled
- Verify no conflicting plugins or .htaccess rules
Navigate to: http://yoursite.com/plugins/reviveRestApi/www/admin/
Requirements: Must be logged into Revive Adserver admin panel first
- Create API Tokens: Generate secure tokens with custom permissions
- Token Overview: View all tokens with usage statistics and status
- Permission Control: Assign granular permissions (campaigns, banners, zones, etc.)
- Usage Analytics: Monitor token usage patterns and API activity
- Token Lifecycle: Activate, deactivate, and delete tokens as needed
- Enable/Disable API: Global API on/off control
- Authentication Requirements: Force authentication for all endpoints
- Rate Limiting: Configure requests per minute (default: 100)
- Token Expiration: Set default token expiry (default: 90 days)
- User Token Limits: Maximum tokens per user (default: 5)
- Token Monitoring: Real-time usage tracking and alerts
- IP Restrictions: Monitor and control access by IP address
- Audit Trail: Complete log of all API token activities
- Permission Management: Fine-grained access control system
Plugin settings can be configured through:
-
Admin Panel Interface (Recommended):
- Navigate to
/plugins/reviveRestApi/www/admin/ - Use the Settings tab for configuration
- Navigate to
-
Revive Plugin Settings:
- Plugins → Plugin Administration → Settings
- Configure the API Base Path (default:
/api/v1)
/api/v1
GET /api/v1/healthGET /api/v1/campaigns # List campaigns
POST /api/v1/campaigns # Create campaign
GET /api/v1/campaigns/{id} # Get campaign details
PUT /api/v1/campaigns/{id} # Update campaign
DELETE /api/v1/campaigns/{id} # Delete campaignGET /api/v1/banners # List banners
POST /api/v1/banners # Create banner
GET /api/v1/banners/{id} # Get banner details
PUT /api/v1/banners/{id} # Update banner
DELETE /api/v1/banners/{id} # Delete banner
POST /api/v1/banners/{id}/upload # Upload banner fileGET /api/v1/zones # List zones
POST /api/v1/zones # Create zone
GET /api/v1/zones/{id} # Get zone details
PUT /api/v1/zones/{id} # Update zone
DELETE /api/v1/zones/{id} # Delete zoneGET /api/v1/campaigns/{id}/targeting # Get campaign targeting
PUT /api/v1/campaigns/{id}/targeting # Update campaign targeting
GET /api/v1/banners/{id}/targeting # Get banner targeting
PUT /api/v1/banners/{id}/targeting # Update banner targetingGET /api/v1/stats/campaigns # Campaign statistics
GET /api/v1/stats/campaigns/{id} # Specific campaign stats
GET /api/v1/stats/banners # Banner statistics
GET /api/v1/stats/banners/{id} # Specific banner stats
GET /api/v1/stats/zones # Zone statistics
GET /api/v1/stats/zones/{id} # Specific zone statsThe API supports two authentication methods with a complete token management system:
For users logged into the Revive admin interface, API requests will automatically use the existing session.
The plugin includes a complete API token management system with admin panel integration.
- Log into your Revive Adserver admin panel
- Navigate to:
/plugins/reviveRestApi/www/admin/ - Click "Create New Token"
- Enter token name and select permissions
- Save the generated token securely (shown only once)
Include your API token in one of these ways:
Authorization Header (Recommended):
Authorization: Bearer rapi_YourTokenHereCustom Header:
X-API-Token: rapi_YourTokenHereQuery Parameter:
/api/v1/campaigns?api_token=rapi_YourTokenHere- Secure Generation: Cryptographically secure tokens with SHA-256 hashing
- Permission System: Granular permissions (campaigns.read, banners.write, etc.)
- Expiration Control: Configurable token expiration (default: 90 days)
- Usage Analytics: Track token usage with detailed logging
- Admin Panel: Web-based interface for token management
- Rate Limiting: Configurable per-IP request limits
# List your tokens
GET /api/v1/tokens
# Create new token
POST /api/v1/tokens
{
"name": "My API Token",
"permissions": ["campaigns.read", "stats.read"]
}
# Delete token
DELETE /api/v1/tokens/{id}campaigns.read/write/delete- Campaign managementbanners.read/write/delete/upload- Banner managementzones.read/write/delete- Zone managementtargeting.read/write- Targeting rulesrulesets.read/write/delete/apply- Rule set managementstats.read- Statistics accessall- Full API access
For complete token management documentation, see TOKEN-MANAGEMENT.md.
curl -X POST http://yoursite.com/api/v1/campaigns \
-H "Content-Type: application/json" \
-H "Authorization: Bearer rapi_YourTokenHere" \
-d '{
"campaignname": "Summer Sale 2024",
"clientid": 1,
"views": 100000,
"clicks": 5000,
"revenue": 2500.00,
"status": 0
}'curl -X POST http://yoursite.com/api/v1/banners/1/upload \
-H "Authorization: Bearer rapi_YourTokenHere" \
-F "file=@banner-300x250.jpg"curl -X PUT http://yoursite.com/api/v1/campaigns/1/targeting \
-H "Content-Type: application/json" \
-H "Authorization: Bearer rapi_YourTokenHere" \
-d '{
"geo": {
"countries": ["US", "CA", "UK"],
"regions": ["California", "New York", "London"]
},
"time": {
"hour_from": 9,
"hour_to": 17,
"days": [1, 2, 3, 4, 5]
}
}'curl -X POST http://yoursite.com/api/v1/tokens \
-H "Content-Type: application/json" \
-H "Authorization: Bearer rapi_AdminTokenHere" \
-d '{
"name": "Campaign Manager",
"permissions": ["campaigns.read", "campaigns.write", "stats.read"]
}'# List all tokens
curl -X GET http://yoursite.com/api/v1/tokens \
-H "Authorization: Bearer rapi_YourTokenHere"
# Get token details with usage stats
curl -X GET http://yoursite.com/api/v1/tokens/1 \
-H "Authorization: Bearer rapi_YourTokenHere"
# Delete a token
curl -X DELETE http://yoursite.com/api/v1/tokens/1 \
-H "Authorization: Bearer rapi_YourTokenHere"{
"success": true,
"data": { ... },
"meta": {
"total": 100,
"limit": 20,
"offset": 0,
"page": 1,
"pages": 5
}
}{
"error": "Error message",
"code": 400,
"timestamp": "2024-08-20T14:30:00+00:00"
}This plugin is designed to work seamlessly with the revive-adserver-mcp Model Context Protocol server, enabling natural language interactions with your ad server through Claude Code.
- Dual Authentication: Session-based and token-based authentication methods
- API Token System: Cryptographically secure tokens with SHA-256 hashing
- Permission System: 16 granular permissions (campaigns.read, banners.write, etc.)
- Token Lifecycle: Secure generation, validation, expiration, and revocation
- Admin Panel Access: Secure web interface with session-based authentication
- Rate Limiting: Configurable per-IP request limits (default: 100/minute)
- Token Expiration: Automatic token expiration (configurable, default: 90 days)
- Usage Monitoring: Complete audit trail of all API token usage
- Input Validation: XSS and SQL injection protection across all endpoints
- Secure Storage: Tokens stored as SHA-256 hashes, never in plain text
- CORS Management: Configurable cross-origin resource sharing
- IP Tracking: Monitor and log all API requests by IP address
- User Agent Logging: Track client applications accessing the API
- Security Event Logging: Comprehensive security event monitoring
- Failed Authentication Tracking: Monitor and alert on authentication failures
Symptoms: API returns 401 status code Causes & Solutions:
- Authentication disabled: Check if
require_authenticationis set to0in API settings - Invalid token format: Ensure token starts with
rapi_and is properly formatted - Expired token: Check token expiration date in admin panel
- Inactive token: Verify token is active (
is_active = 1) in admin panel
Symptoms: API returns 403 status code Causes & Solutions:
- Insufficient permissions: Check token permissions match required endpoint access
- Missing permission: Add required permission (e.g.,
campaigns.read) to token - Token ownership: Ensure user has access to view/modify the requested token
Symptoms: Valid token rejected by API Diagnostic Steps:
- Verify token format: Should start with
rapi_prefix - Check expiration: View token details in admin panel
- Confirm permissions: Ensure token has required permissions for endpoint
- Test with admin session: Try the same endpoint while logged into admin panel
- Check API settings: Verify API is enabled and authentication configured correctly
Symptoms: Cannot access /plugins/reviveRestApi/www/admin/
Solutions:
- Login required: Must be logged into Revive admin panel first
- File permissions: Check web server read permissions on admin directory
- URL path: Verify correct plugin path based on your installation
- Database tables: Ensure token management tables were created during installation
- Test API Health:
GET /api/v1/healthshould return JSON status - Check Database: Verify
api_tokens,api_token_usage, andapi_settingstables exist - Review Logs: Check web server error logs for PHP errors
- Token Validation: Use admin panel to view token status and usage
- Permission Test: Try endpoint with session authentication (logged into admin)
For token-related issues:
- Check token status in admin panel (
/plugins/reviveRestApi/www/admin/) - Review TOKEN-MANAGEMENT.md for detailed documentation
- Test with different permission combinations
- Monitor usage logs for authentication patterns
For issues, questions, or contributions:
- Check the documentation
- Review existing issues
- Create a new issue with detailed information
This plugin is released under the GPL-2.0+ license, compatible with Revive Adserver's licensing.
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
See CHANGELOG.md for version history and changes.