REST API for Database Operations

Updated on 10. 2. 2026



ZiziCache exposes database maintenance endpoints under /wp-json/zizi-cache/v1. All routes require authenticated admin access and a valid REST nonce.

Available REST Endpoints

Database-related routes:

  • /database-statistics (GET): database info, summary, top tables, chart data
  • /database-growth-history (GET): size history (params: days, t=1 to force refresh)
  • /database-status (GET): summarized status (autoload size, orphaned postmeta, Action Scheduler status)
  • /cleanup-counts (GET/POST): counts of cleanable items (POST with options to filter)
  • /cleanup-database (POST): clean selected items (items array)
  • /optimize-db-tables (POST): cleanup based on options array, returns deleted counts
  • /optimize-db-tables-batch (POST): safe table optimization (optional tables list, batch_size accepted)
  • /index-recommendations (GET): index recommendations with SQL
  • /apply-index-recommendations (POST): apply selected recommendations by ID from a previous response
  • /database-operation-logs (GET): recent database operation logs (optional limit)
  • /db-event-log (POST): write a database event entry to the log
  • /save-settings (POST): update database settings (schedule and Action Scheduler cleanup)

API Security

All routes use the plugin permission callback (administrator capability + REST nonce). There is no built‑in rate limiting.

Batch Operations

The batch optimization endpoint runs in a single request, processes tables one by one, and skips large or unfragmented InnoDB tables. It returns per‑table results; there is no async progress channel.

Examples of API Usage

Basic examples of API calls:

GET /wp-json/zizi-cache/v1/database-statistics

GET /wp-json/zizi-cache/v1/database-growth-history?days=30

POST /wp-json/zizi-cache/v1/cleanup-database
{
"items": ["db_post_revisions", "db_transients_expired"]
}

GET /wp-json/zizi-cache/v1/index-recommendations

POST /wp-json/zizi-cache/v1/apply-index-recommendations
{
"recommendations": [{"id": 0}, {"id": 3}]
}

POST /wp-json/zizi-cache/v1/optimize-db-tables-batch
{
"tables": ["wp_posts", "wp_postmeta"],
"batch_size": 500
}

Response Formats

The API returns structured JSON responses with success status, data payloads, and error messages when applicable.

What are your feelings