SDKs overview

Toolcarton offers Software Development Kits (SDKs) and client libraries to facilitate programmatic interaction with its test data generation and API mocking services. These SDKs abstract the underlying Toolcarton REST API, allowing developers to integrate data generation into their applications, build scripts, or CI/CD pipelines using familiar programming languages. By providing language-specific methods and data structures, SDKs aim to reduce the boilerplate code required for API calls, authentication, error handling, and data parsing, thereby improving developer productivity when working with Toolcarton's features for generating synthetic data, mocking API responses, and seeding databases.

The primary advantage of using an SDK over direct API calls is the streamlined development experience. SDKs typically handle HTTP requests, JSON serialization/deserialization, and API key management, allowing developers to focus on the logic of their application rather than the intricacies of the API protocol. This is particularly beneficial for tasks such as automating the setup of test environments or dynamically generating test datasets based on specific criteria within an application's codebase. Toolcarton's SDKs are designed to mirror the functionality available through its web-based user interface, providing parity between manual and automated data generation processes.

Official SDKs by language

Toolcarton maintains official SDKs for several popular programming languages, ensuring direct support and continuous updates. These SDKs are developed and maintained by the Toolcarton team to guarantee compatibility with the latest API versions and features. Each SDK provides a consistent interface for operations such as creating data models, defining field types, generating data rows, and managing project configurations. The following table outlines the currently available official SDKs, their respective package names, installation commands, and maturity levels.

Language Package Name Installation Command Maturity
JavaScript/TypeScript @toolcarton/sdk-js npm install @toolcarton/sdk-js or yarn add @toolcarton/sdk-js Stable
Python toolcarton-sdk-py pip install toolcarton-sdk-py Stable
Go github.com/toolcarton/go-sdk go get github.com/toolcarton/go-sdk Stable
Ruby toolcarton-sdk-ruby gem install toolcarton-sdk-ruby Beta
PHP toolcarton/php-sdk composer require toolcarton/php-sdk Beta
Java com.toolcarton:java-sdk Maven: <dependency><groupId>com.toolcarton</groupId><artifactId>java-sdk</artifactId><version>X.Y.Z</version></dependency> Alpha
C# (.NET) Toolcarton.SDK.CSharp dotnet add package Toolcarton.SDK.CSharp Alpha

Maturity levels indicate the current development stage and stability. "Stable" SDKs are recommended for production use, "Beta" SDKs are generally stable but may undergo minor API changes, and "Alpha" SDKs are under active development and may experience more significant changes. Developers should consult the Toolcarton SDK documentation for the latest version information and detailed release notes.

Installation

Installing Toolcarton SDKs typically follows the standard package management practices for each respective language. Authentication usually involves an API key, which can be generated from your Toolcarton account dashboard. This key is then passed to the SDK client upon initialization. For robust security, it is generally recommended to store API keys as environment variables rather than hardcoding them directly into source code, especially in production or shared development environments. This practice aligns with general security guidelines for API key management, as detailed in resources like Google Maps API security best practices.

JavaScript/TypeScript

npm install @toolcarton/sdk-js
# or
yarn add @toolcarton/sdk-js

Python

pip install toolcarton-sdk-py

Go

go get github.com/toolcarton/go-sdk

After fetching, ensure your project is properly configured to use Go modules. For example, you might need to run go mod tidy to update your go.mod file. The Go SDK is designed to be idiomatic, leveraging Go's concurrency features and error handling patterns. Developers can find specific Go SDK usage examples within the Toolcarton documentation.

Ruby

gem install toolcarton-sdk-ruby

The Ruby SDK integrates with common Ruby patterns and is distributed as a RubyGems package. Detailed instructions for configuring the Ruby SDK client are available in the official documentation, including setup for Ruby on Rails applications.

PHP

composer require toolcarton/php-sdk

The PHP SDK is Composer-compatible, allowing for easy integration into PHP projects, including frameworks like Laravel or Symfony. Developers can refer to the Toolcarton PHP SDK guide for comprehensive examples and best practices.

Java

For Maven-based projects, add the following to your pom.xml:

<dependencies>
    <dependency>
        <groupId>com.toolcarton</groupId>
        <artifactId>java-sdk</artifactId>
        <version>X.Y.Z</version> <!-- Replace with the latest version -->
    </dependency>
</dependencies>

For Gradle, add to build.gradle:

implementation 'com.toolcarton:java-sdk:X.Y.Z' // Replace with the latest version

The Java SDK provides an object-oriented interface for interacting with Toolcarton services. The Toolcarton Java SDK reference includes examples for initializing the client and performing common data generation tasks.

C# (.NET)

dotnet add package Toolcarton.SDK.CSharp

The C# SDK is distributed as a NuGet package and integrates seamlessly into .NET projects. It follows common .NET conventions for asynchronous operations and dependency injection. Developers can consult the C# SDK documentation for detailed setup and usage examples within .NET applications.

Quickstart example

This example demonstrates how to use the Toolcarton Python SDK to generate 10 rows of synthetic user data based on a predefined data model in your Toolcarton project. Before running this code, ensure you have an API key and a data model named "User" set up in your Toolcarton account.

Python Quickstart

import os
from toolcarton_sdk_py import ToolcartonClient

# Initialize the client with your API key from an environment variable
api_key = os.environ.get("TOOLCARTON_API_KEY")
if not api_key:
    raise ValueError("TOOLCARTON_API_KEY environment variable not set.")

client = ToolcartonClient(api_key=api_key)

try:
    # Define the data model ID or name (using name for simplicity in this example)
    model_name = "User" # Ensure this model exists in your Toolcarton project
    rows_to_generate = 10

    print(f"Generating {rows_to_generate} rows for model '{model_name}'...")

    # Generate data
    generated_data = client.data.generate(
        model_name=model_name,
        rows=rows_to_generate
    )

    print("Data generated successfully:")
    for i, row in enumerate(generated_data):
        print(f"Row {i+1}: {row}")

except Exception as e:
    print(f"An error occurred: {e}")

To execute this example:

  1. Install the Python SDK: pip install toolcarton-sdk-py.
  2. Set your Toolcarton API key as an environment variable: export TOOLCARTON_API_KEY="YOUR_API_KEY_HERE" (on Linux/macOS) or $env:TOOLCARTON_API_KEY="YOUR_API_KEY_HERE" (on Windows PowerShell).
  3. Ensure you have a data model named "User" configured in your Toolcarton project. This model should define the fields (e.g., id, name, email, address) and their respective data types or generators.
  4. Save the code as a .py file (e.g., generate_users.py) and run it: python generate_users.py.

This script will connect to the Toolcarton API, request data generation for the specified model, and print the resulting synthetic data to the console. For more complex scenarios, such as conditional data generation or integrating with specific database types, the Toolcarton quickstart guides provide additional examples across various languages.

Community libraries

In addition to official SDKs, the Toolcarton ecosystem may include community-contributed libraries and integrations. These resources are developed by individual developers or third-party organizations and can offer specialized functionalities, integrations with other tools, or support for languages not covered by official SDKs. While community libraries can extend the utility of Toolcarton, it is important to note that their maintenance, support, and compatibility with future Toolcarton API versions are managed independently by their creators. Developers considering community libraries should review their documentation, community activity, and licensing terms.

Examples of potential community contributions could include:

  • CLI Tools: Command-line interfaces built on top of Toolcarton's API for quick data generation tasks without writing code.
  • Framework Integrations: Libraries that provide seamless integration with popular web frameworks (e.g., a Django package for database seeding with Toolcarton data).
  • Data Connectors: Tools for directly importing generated data into specific database systems or data warehouses.
  • Testing Framework Adapters: Integrations with testing frameworks (e.g., JUnit, Pytest) to automate test data setup and teardown.

Developers are encouraged to check the Toolcarton community page or relevant public repositories (e.g., GitHub) for a comprehensive list of available community projects. The quality and maturity of community libraries can vary, so evaluating their activity and support is recommended before adoption in production environments. Community engagement is a key aspect of open development, as highlighted by resources such as the Mozilla Developer Network's community resources, which emphasize the value of collaborative contributions.