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.
POST /api/v1/generate/sql
Base URL is relative to your installation path.
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). |
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
$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);
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.
For any improvements, feature requests, or to report bugs, please: