API Documentation (v1)

Introduction

The MySQL Random Data Generator API provides a stateless, programmatic way to generate test data. It is ideal for integration into automated test suites, CI/CD pipelines, or custom development scripts. The API strictly generates SQL and does not interact with any database directly.

Endpoint

POST /api/v1/generate/sql

Base URL is relative to your installation path.

Rate Limits & Constraints

  • Rate Limit: 10 requests per minute per IP.
  • Max Rows: 100,000 rows per request. Requests exceeding this will be truncated.
  • Execution Time: 10 seconds maximum. Long-running generations will be truncated with a warning comment.

Request Specification

The API expects a JSON body with the following parameters:

Parameter Type Required Description
table_definition String Yes A valid CREATE TABLE SQL statement.
rows Integer No Number of rows to generate (Max: 100,000. Default: 1000).
options.batch_size Integer No Number of rows per INSERT statement (Default: 500).

Example Usage

cURL Request
curl -X POST https://nitty-witty.com/api/v1/generate/sql \
     -H "Content-Type: application/json" \
     -d '{
       "table_definition": "CREATE TABLE users (id INT, email VARCHAR(100))",
       "rows": 100,
       "options": { "batch_size": 50 }
     }' --output data.sql
PHP Example
$data = [
    'table_definition' => 'CREATE TABLE users (id INT, email VARCHAR(100))',
    'rows' => 1000
];

$ch = curl_init('https://nitty-witty.com/api/v1/generate/sql');
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type:application/json']);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);
file_put_contents('generated.sql', $response);
curl_close($ch);

Response

The API streams the output with Content-Type: application/sql. If successful, it initiates a file download named generated.sql. In case of an error, it returns a 400/500 status code with a JSON error message.


Support & Improvements

For any improvements, feature requests, or to report bugs, please: