Generating data from the API
Last updated
Was this helpful?
To generate data for an existing database:
POST /api/v1/generate_tasksThis method expects a JSON object as the request body with the following parameters:
{
"workspace": string,
"database": string,
"format": string,
"connection": string,
"entity": string,
"overrides": object
}Where:
workspace
The name of the workspace in which the database resides.
database
The name of the database for which to generate data.
format
(Optional) The format of the generated data.
Allows values are "sql", "sqlite", "postgres-optimized", "csv", or "jsonl".
connection
(Optional) The name of the target database connection to insert the generated data into. If you provide a format, then do not provide a connection. When you provide a connection, the target database and all of the tables must already exist.
entity
(Optional) The name of a table to generate. When provided, Fabricate only generates data for that table, and the generated data is provided as plain text instead of a .zip file.
overrides
(Optional) Overrides to variable values and table column configuration. Only available for rule-based databases. Cannot use for Data Agent databases. For more information, go to Generating data from the API.
To check the status of a data generation task:
Where:
id
The UUID of the data generation task to get
The response is a JSON object in the same format as the response from the POST /api/v1/generate_tasks endpoint.
The download_url field in the response from GET /api/v1/generate_tasks/:id contains a URL to download the generated data.
Depending on the format of the data, to load it into your database, use the appropriate method:
The data is provided as a zip file.
To load the data into your database, unzip it and then run the following command:
Last updated
Was this helpful?
Was this helpful?
GET /api/v1/generate_tasks/:idpsql -U <username> -d <database> -f path/to/dir/load.sql