SDKs overview

Random Data offers Software Development Kits (SDKs) to facilitate interaction with its API for generating synthetic data. These SDKs are designed to abstract the underlying HTTP requests and responses, allowing developers to integrate data generation capabilities into their applications using idiomatic language constructs. The primary goal of these libraries is to streamline tasks such as populating databases for development, creating mock APIs, and generating synthetic test cases Random Data documentation. By providing pre-built functions and objects, SDKs reduce the need for manual HTTP client configuration and response parsing, which can simplify development workflows.

SDKs generally handle aspects like authentication, request serialization, response deserialization, and error handling, making the API more accessible to developers. For example, a Python SDK would expose methods that directly correspond to API endpoints, allowing a developer to call randomdata.generate_users(count=10) instead of constructing a raw HTTP POST request to /api/v1/users/generate with appropriate headers and JSON body.

Beyond official SDKs, the developer community often contributes libraries that extend functionality or provide integrations with specific frameworks. These community-driven efforts can offer alternative ways to access the Random Data platform, sometimes catering to niche requirements or emerging technologies not yet covered by official releases.

Official SDKs by language

Random Data provides official SDKs for several popular programming languages, ensuring robust and documented methods for integrating its data generation services. These SDKs are maintained by Random Data and are the recommended approach for most production applications official Random Data documentation. Each SDK is designed to reflect the nuances of its respective language while providing consistent access to the core Random Data API features.

Language Package Name Installation Command Maturity
Python randomdata-py pip install randomdata-py Stable
Node.js @randomdata/client npm install @randomdata/client Stable
Java com.randomdata:client Maven: Add dependency in pom.xml
<dependency>
    <groupId>com.randomdata</groupId>
    <artifactId>client</artifactId>
    <version>1.x.x</version>
</dependency>
Gradle: Add dependency in build.gradle
implementation 'com.randomdata:client:1.x.x'
Stable
Ruby randomdata-ruby gem install randomdata-ruby Stable

Installation

Installing the Random Data SDKs typically involves using the standard package manager for the respective programming language. Detailed instructions and any specific system requirements are available in the Random Data developer documentation. Before installing, ensure your development environment meets the minimum version requirements for the SDK and its dependencies, such as Python 3.8+, Node.js 14+, Java 11+, or Ruby 2.7+.

Python

To install the Python SDK, use pip, the Python package installer:

pip install randomdata-py

It is recommended to install SDKs within a virtual environment to manage dependencies effectively, as described in the Python venv documentation.

Node.js

For Node.js projects, use npm or yarn to add the package:

npm install @randomdata/client

Or with Yarn:

yarn add @randomdata/client

Java

Java projects typically manage dependencies using Maven or Gradle. Add the following to your project's build file:

Maven (pom.xml)

<dependencies>
    <dependency>
        <groupId>com.randomdata</groupId>
        <artifactId>client</artifactId>
        <version>1.x.x</version> <!-- Replace with the latest version -->
    </dependency>
</dependencies>

Gradle (build.gradle)

dependencies {
    implementation 'com.randomdata:client:1.x.x' // Replace with the latest version
}

Ruby

For Ruby applications, use the gem command:

gem install randomdata-ruby

Then, include it in your Gemfile:

gem 'randomdata-ruby'

And run bundle install.

Quickstart example

The following examples demonstrate how to use the Random Data SDKs to generate a basic set of user data. A valid API key is typically required for authentication, which can be obtained from the Random Data platform dashboard.

Python Quickstart

This Python example initializes the client and requests a specified number of user profiles with random data.

import os
from randomdata_py import RandomDataClient

# Initialize the client with your API key
# It's recommended to store your API key in an environment variable
api_key = os.environ.get("RANDOMDATA_API_KEY")
if not api_key:
    raise ValueError("RANDOMDATA_API_KEY environment variable not set")

client = RandomDataClient(api_key=api_key)

try:
    # Generate 5 random user profiles
    users = client.generate_data(schema_name="user_profile", count=5)
    for user in users:
        print(user)
except Exception as e:
    print(f"An error occurred: {e}")

Node.js Quickstart

The Node.js example shows how to import the client and asynchronously fetch random user data.

const { RandomDataClient } = require('@randomdata/client');

// Initialize the client with your API key
const apiKey = process.env.RANDOMDATA_API_KEY;

if (!apiKey) {
    throw new Error("RANDOMDATA_API_KEY environment variable not set");
}

const client = new RandomDataClient(apiKey);

async function generateUsers() {
    try {
        // Generate 5 random user profiles
        const users = await client.generateData('user_profile', 5);
        console.log(users);
    } catch (error) {
        console.error('An error occurred:', error.message);
    }
}

generateUsers();

Java Quickstart

This Java example demonstrates client initialization and a synchronous call to generate data.

import com.randomdata.client.RandomDataClient;
import com.randomdata.client.model.DataGenerationRequest;
import com.randomdata.client.ApiException;

import java.util.List;
import java.util.Map;

public class Quickstart {
    public static void main(String[] args) {
        String apiKey = System.getenv("RANDOMDATA_API_KEY");
        if (apiKey == null || apiKey.isEmpty()) {
            System.err.println("RANDOMDATA_API_KEY environment variable not set.");
            return;
        }

        RandomDataClient client = new RandomDataClient(apiKey);

        try {
            // Define the data generation request
            DataGenerationRequest request = new DataGenerationRequest()
                    .schema_name("user_profile")
                    .count(5);

            // Generate 5 random user profiles
            List<Map<String, Object>> users = client.generateData(request);
            for (Map<String, Object> user : users) {
                System.out.println(user);
            }
        } catch (ApiException e) {
            System.err.println("API Error: " + e.getMessage());
            System.err.println("Status Code: " + e.getCode());
            System.err.println("Response Body: " + e.getResponseBody());
        } catch (Exception e) {
            System.err.println("An unexpected error occurred: " + e.getMessage());
        }
    }
}

Ruby Quickstart

The Ruby quickstart shows how to configure the client and retrieve data. Ensure the randomdata-ruby gem is installed.

require 'randomdata-ruby'

# Configure the client with your API key
RandomDataRuby.configure do |config|
  config.api_key = ENV['RANDOMDATA_API_KEY']
end

unless RandomDataRuby.configuration.api_key
  puts 'Error: RANDOMDATA_API_KEY environment variable not set.'
  exit(1)
end

begin
  # Generate 5 random user profiles
  users = RandomDataRuby::Client.generate_data(schema_name: 'user_profile', count: 5)
  users.each do |user|
    puts user
  end
rescue RandomDataRuby::ApiError => e
  puts "API Error: #{e.message}"
  puts "Status Code: #{e.code}"
  puts "Response Body: #{e.response_body}"
rescue StandardError => e
  puts "An unexpected error occurred: #{e.message}"
end

Community libraries

While Random Data provides official SDKs, the broader developer community also contributes libraries and tools that can either enhance or complement the official offerings. These community-driven projects are typically open-source and can be found on platforms like GitHub or package repositories specific to programming languages.

Community libraries for data generation might include integrations with popular web frameworks, command-line interfaces for specific workflows, or utilities for advanced data transformation and manipulation. For example, a community library might exist that directly integrates Random Data's output with a specific ORM or database migration tool, simplifying the seeding process.

Developers often create these libraries to address specific use cases not covered by official SDKs, or to provide a more opinionated or specialized interface. While these libraries can be valuable, it is important to verify their maintenance status, documentation quality, and security practices, as they may not carry the same support guarantees as official SDKs.

Some prominent community-driven alternatives for generating synthetic or random data, which might be integrated with or used alongside Random Data, include Faker, a Python library for generating fake data, and Mockaroo, an online service for generating realistic test data. Another related tool is JSONPlaceholder, which provides a free fake API for testing and prototyping. These tools highlight the ecosystem of options available for developers working with synthetic datasets.