Custom Data Providers
Custom Data Providers allow you to input your own data and use it in data generation. This feature enables precise control over generated values by defining your own datasets and referencing them using a simple format.
Defining Custom Data
You can provide custom data through the app or via the API. Each dataset is assigned a unique name, which can be referenced when defining fields.
Providing Data in the App
- Enter a dataset name.
- Provide a list of values, separated by newlines.
Providing Data via the API
- Send a JSON payload where:
- The key is the dataset name.
- The value is an array of values.
Example API Payload
{
"product_names": ["Laptop", "Smartphone", "Tablet"],
"customer_names": ["John Doe", "Jane Smith", "Alice Johnson"]
}
Usage Format
When defining fields in your data schema, you can reference your custom data using the following syntax:
field_name: data_type @dataset_name
Example
If you've provided a dataset of product names under product_names
, you can define a schema as follows:
product_name: string @product_names
price: float
stock: integer
This setup will generate product_name
values using entries from your custom dataset while generating random values for price
and stock
.
Example Use Case
Scenario: Generating Customer Names from Provided Data
Assume you have entered the following names in the app under customer_names
:
John Doe
Jane Smith
Alice Johnson
Or provided the following JSON via the API:
{
"customer_names": ["John Doe", "Jane Smith", "Alice Johnson"]
}
Now, you can use:
first_name: string @customer_names
email: string @email
This setup will generate customer names from the provided dataset while randomly generating email addresses.
Best Practices
- Ensure data entries are well-structured and relevant.
- Use descriptive names to avoid confusion.
- Regularly update datasets to keep generated data meaningful.