Ninja API Explorer
A powerful tool for exploring and testing WordPress REST APIs with Swagger-like interface
Install
No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:
wp plugin install https://github.com/ahmadreza-log/ninja-api/archive/refs/heads/master.zipA powerful WordPress plugin that provides a Swagger-like interface for exploring and testing WordPress REST APIs. Built with clean MVC architecture and modern design principles.
🚀 Features
Core Functionality
- Dynamic Route Discovery: Automatically discovers all registered WordPress REST API routes
- Interactive API Testing: Built-in endpoint tester with support for all HTTP methods
- Route Documentation: Detailed information about each endpoint including parameters and examples
- Real-time Filtering: Filter routes by namespace, method, and public/private status
- Smart Search: Search through route paths and descriptions
- Copy to Clipboard: Easy URL copying for external testing
User Interface
- Clean Light Mode Design: Modern, professional interface
- Tabbed Navigation: Organized view with All Routes, Grouped Routes, and API Tester tabs
- Responsive Design: Works perfectly on desktop, tablet, and mobile devices
- WordPress Admin Integration: Seamlessly integrated into WordPress admin panel
- Collapsible Namespaces: Organized route grouping with expand/collapse functionality
Developer Features
- MVC Architecture: Clean separation of concerns with Models, Views, and Controllers
- OpenAPI Specification: Generates OpenAPI 3.0 specification for API documentation
- Request Logging: Logs API test requests for debugging and analysis
- Extensible Design: Easy to extend with custom functionality
- Performance Optimized: Efficient code with minimal resource usage
📋 Requirements
- WordPress: 5.0 or higher
- PHP: 7.4 or higher
- Browser: Modern browser with JavaScript enabled
- Permissions: Administrator access to WordPress admin
🔧 Installation
Manual Installation
- Download the plugin files
- Upload the
ninja-apifolder to/wp-content/plugins/directory - Activate the plugin through the 'Plugins' menu in WordPress
- Navigate to 'API Explorer' in the WordPress admin menu
From WordPress Admin
- Go to Plugins → Add New
- Search for "Ninja API Explorer"
- Click "Install Now" and then "Activate"
- Access the plugin from the admin menu
🎯 Usage
Accessing the Plugin
After activation, you'll find "API Explorer" in your WordPress admin menu. The plugin provides three main tabs:
- All Routes: View all registered API routes with filtering options
- Grouped Routes: Routes organized by namespace for better navigation
- API Tester: Built-in tool for testing API endpoints
Exploring Routes
- Browse Routes: Navigate through all available WordPress REST API routes
- Filter Options: Use the filter bar to narrow down results by namespace, HTTP method, or public status
- Search: Type in the search box to find specific routes
- Route Details: Click "Details" to see comprehensive information about any route
Testing APIs
- Navigate to the "API Tester" tab
- Enter the endpoint URL
- Select the HTTP method (GET, POST, PUT, PATCH, DELETE, etc.)
- Add request body if needed (for POST/PUT/PATCH requests)
- Click "Test Endpoint" to execute the request
- View the response with status code, response time, and body
Advanced Features
- Copy URLs: Click "Copy URL" to copy endpoint URLs for external testing
- Namespace Grouping: View routes organized by WordPress namespaces (wp/v2, etc.)
- Request Logging: All test requests are logged for future reference
- OpenAPI Export: Generate OpenAPI specification for external documentation tools
🏗️ Architecture
MVC Structure
App/
├── Controllers/
│ ├── BaseController.php # Base controller class
│ ├── AdminController.php # Admin panel controller
│ └── ApiTestController.php # API testing controller
├── Models/
│ ├── ApiRouteModel.php # Route data model
│ └── ApiEndpointModel.php # Endpoint data model
├── Services/
│ └── ApiService.php # Core API service
├── Helpers/
│ ├── RouteHelper.php # Route utility functions
│ └── ViewHelper.php # View rendering helper
└── Views/
└── admin/
├── main-page.php # Main interface
├── settings-page.php # Settings page
└── documentation-page.php # Documentation
Key Components
- ApiService: Handles WordPress REST API interaction and route discovery
- ViewHelper: Manages view rendering and template system
- RouteHelper: Provides utility functions for route processing
- AdminController: Manages admin interface and user interactions
- ApiTestController: Handles API testing functionality
🎨 Customization
Styling
The plugin uses clean CSS that can be easily customized:
- Main styles:
assets/css/admin.css - Responsive design included
- WordPress admin theme integration
- Customizable color scheme
Extending Functionality
The plugin is designed to be extensible:
- Custom Controllers: Extend
BaseControllerfor new functionality - Additional Services: Add new service classes for extended features
- Custom Views: Create new view templates for additional pages
- Hook Integration: Use WordPress hooks for custom integrations
🔒 Security
- Nonce Verification: All AJAX requests use WordPress nonces
- Permission Checks: Administrator-level access required
- Input Sanitization: All user inputs are properly sanitized
- Output Escaping: All outputs are properly escaped
- Direct Access Protection: All files include access protection
🐛 Troubleshooting
Common Issues
Plugin not showing in admin menu:
- Ensure you have administrator privileges
- Check if the plugin is properly activated
- Verify WordPress version compatibility
Routes not displaying:
- Check if WordPress REST API is enabled
- Verify that routes are properly registered
- Check browser console for JavaScript errors
API tests failing:
- Verify the endpoint URL is correct
- Check if the endpoint requires authentication
- Ensure the request method matches the endpoint requirements
Debug Mode
Enable WordPress debug mode to see detailed error messages:
define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
🤝 Contributing
We welcome contributions from the community! Here's how you can help:
Ways to Contribute
- Bug Reports: Report issues with detailed information
- Feature Requests: Suggest new features or improvements
- Code Contributions: Submit pull requests with fixes or enhancements
- Documentation: Help improve documentation and examples
- Testing: Test the plugin on different WordPress setups
Development Setup
- Fork the repository
- Create a feature branch:
git checkout -b feature/your-feature-name - Make your changes following the existing code style
- Test your changes thoroughly
- Submit a pull request with a clear description
Code Standards
- Follow WordPress Coding Standards
- Use PascalCase for class names
- Maintain MVC architecture
- Include proper documentation
- Write clean, readable code
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
🙏 Acknowledgments
- WordPress REST API team for the excellent API framework
- WordPress community for inspiration and feedback
- Contributors who help improve this plugin
📞 Support
- Documentation: Check this README and inline code comments
- Issues: Report bugs and request features via GitHub issues
- Community: Join WordPress developer communities for general help
🔄 Changelog
Version 1.0.0
- Initial release
- Complete MVC architecture implementation
- Route discovery and display functionality
- Built-in API testing tool
- Tabbed interface with filtering and search
- Responsive design for all devices
- OpenAPI specification generation
- Request logging system
Made with ❤️ for the WordPress community