Installation
Install the Strapi integration package:Node 18+ required
Setup
1. Install the Plugin
Add the ApiTraffic plugin to your Strapi application:2. Add to Middlewares Configuration
The middleware must be added to theconfig/middlewares.js
file:
3. Environment Configuration
Add the required environment variables to your.env
file:
.env
Configuration
Required Environment Variables
Environment Variable | Required | Type | Description |
---|---|---|---|
API_TRAFFIC_TOKEN | Yes | String | Ingest token from your ApiTraffic account |
API_TRAFFIC_BUCKET | Yes | String | Bucket ID for data organization |
Optional Configuration
You can also configure additional options by creating a plugin configuration file atconfig/plugins.js
:
Features
Automatic API Monitoring
Once installed, ApiTraffic automatically monitors:- Content API requests - All requests to your Strapi content endpoints
- Admin API requests - Administrative operations and user management
- Custom API routes - Any custom routes you’ve added to your Strapi application
- Plugin API calls - Requests to installed plugin endpoints
Workflow Integration
ApiTraffic’s workflow engine allows you to create automated workflows that trigger based on your Strapi API activity:- Content Creation Workflows - Trigger actions when new content is created
- User Registration Flows - Automate user onboarding processes
- Data Synchronization - Sync content changes with external systems
- Notification Systems - Send alerts based on API usage patterns
Real-time Analytics
Monitor your Strapi application with comprehensive analytics:- Request volume and patterns
- Response times and performance metrics
- Error rates and debugging information
- User activity and content usage statistics
Security Features
Data Redaction
ApiTraffic automatically redacts sensitive data based on your account settings. Configure redaction rules in your ApiTraffic dashboard to protect:- User passwords and authentication tokens
- Personal identifiable information (PII)
- Payment and financial data
- Custom sensitive fields
Request Exclusions
Exclude specific endpoints from monitoring by configuring exclusion rules in your ApiTraffic account. Common exclusions for Strapi include:- Health check endpoints (
/_health
) - Static asset requests
- Admin panel assets
- Internal monitoring endpoints
Advanced Usage
Custom Tagging
While Strapi doesn’t support direct tagging in middleware, you can add custom tags through controller extensions:Webhook Integration
Combine ApiTraffic with Strapi webhooks for comprehensive monitoring:Troubleshooting
Plugin not capturing requests
Plugin not capturing requests
Ensure the ApiTraffic middleware is properly added to your
config/middlewares.js
file and placed in the correct order.Missing environment variables
Missing environment variables
Verify that
API_TRAFFIC_TOKEN
and API_TRAFFIC_BUCKET
are set in your .env
file and that Strapi is loading them correctly.Plugin not loading
Plugin not loading
Check that the plugin is properly installed and that your
package.json
includes @apitraffic/strapi
in dependencies.Performance issues
Performance issues
If you’re experiencing performance issues, consider adjusting the sampling rate in your ApiTraffic account settings.
Debug Mode
Enable debug logging by setting the debug flag in your plugin configuration:Strapi Marketplace
The ApiTraffic plugin is available on the Strapi Marketplace for easy discovery and installation.Use Cases
Content Management Monitoring
- Track content creation, updates, and deletions
- Monitor user engagement with different content types
- Analyze API usage patterns for optimization
Performance Optimization
- Identify slow-performing endpoints
- Monitor database query performance
- Track memory and CPU usage patterns
Security Monitoring
- Detect unusual API access patterns
- Monitor authentication failures
- Track admin panel usage
Integration Workflows
- Automatically sync content with external systems
- Trigger email campaigns based on content changes
- Update search indexes when content is modified