Getting started overview

This guide outlines the process for new users to begin using Random Data's services, focusing on account setup, API key management, and the execution of a primary API request. Random Data facilitates the creation of synthetic data for various development and testing scenarios, including populating databases, generating test cases, and prototyping applications. The platform offers a RESTful API, command-line interface (CLI) for local data generation, and SDKs for common programming languages.

To successfully complete this getting started process, users will:

  1. Create a Random Data account.
  2. Locate and secure their API key.
  3. Make a basic data generation request using the API.

The following table summarizes the key steps:

Step Action Location/Tool
1. Account Creation Register for a new Random Data account. Random Data homepage
2. API Key Retrieval Access your unique API key from the dashboard. Random Data dashboard > API Settings
3. First Request Send a basic data generation request. cURL, Postman, or a preferred SDK (Python, Node.js)

Create an account and get keys

To begin using Random Data, a user account is required. Random Data provides a free tier that includes 500 API requests per month and supports up to 10 data schemas, suitable for initial exploration and development.

Account Registration

Navigate to the Random Data homepage and locate the 'Sign Up' or 'Get Started' option. The registration process typically involves providing an email address and creating a password. After successful registration, a verification email may be sent to confirm the account.

API Key Retrieval

Upon logging into your new Random Data account, access the user dashboard. API keys are typically located in a dedicated section, often labeled 'API Settings', 'Developer Settings', or 'Credentials'. The API key is a unique string that authenticates your requests to the Random Data API. It is critical to treat this key as sensitive information, similar to a password, and store it securely. For example, environment variables are a common method for handling API keys in development environments, as described in Mozilla's documentation on environment variables.

Locate and copy your API key. This key will be included in the headers or parameters of your API requests to authorize them.

Your first request

After obtaining your API key, you can make your first request to the Random Data API. This example demonstrates generating a simple set of random user data. The Random Data API is RESTful, meaning it uses standard HTTP methods (GET, POST, PUT, DELETE) to interact with resources, as detailed in the Random Data API reference.

Using cURL

cURL is a command-line tool for making HTTP requests and is often used for testing APIs. Replace YOUR_API_KEY with the key retrieved from your dashboard.

curl -X POST \  https://api.randomdata.com/v1/generate \  -H 'Content-Type: application/json' \  -H 'Authorization: Bearer YOUR_API_KEY' \  -d '{    "schema": {      "name": "firstName",      "email": "email",      "age": "number|18-65"    },    "count": 1  }'

This request sends a POST request to the /v1/generate endpoint, specifying a schema for a single user with a first name, email, and an age between 18 and 65. The Authorization header includes your API key, prefixed with Bearer, a common practice for Bearer Token authentication.

Using Python SDK

Random Data provides SDKs to simplify interaction with its API. For Python, ensure you have the SDK installed via pip:

pip install randomdata-sdk

Then, you can make a request as follows:

import os
from randomdata import RandomDataClient

# It is recommended to store your API key as an environment variable
api_key = os.environ.get("RANDOMDATA_API_KEY") 

if not api_key:
    print("Error: RANDOMDATA_API_KEY environment variable not set.")
    exit(1)

client = RandomDataClient(api_key=api_key)

# Define the schema for the data you want to generate
schema = {
    "name": "firstName",
    "email": "email",
    "age": "number|18-65"
}

try:
    # Generate 1 record based on the defined schema
    data = client.generate_data(schema=schema, count=1)
    print("Generated Data:")
    for item in data:
        print(item)
except Exception as e:
    print(f"An error occurred: {e}")

This Python example initializes the Random Data client with the API key (preferably from an environment variable) and then calls the generate_data method with the specified schema and count.

Expected Response

A successful response for both cURL and Python examples will return a JSON array containing the generated data, similar to this:

[
  {
    "name": "Jane",
    "email": "[email protected]",
    "age": 32
  }
]

Common next steps

After successfully making your first request, several avenues can be explored to deepen your interaction with Random Data:

  • Explore Advanced Schemas: The Random Data documentation provides extensive details on creating complex data schemas, including relationships, custom formats, and localization options. Users can define intricate data structures to meet specific application requirements.
  • Integrate with SDKs: For ongoing development, utilizing one of the official Random Data SDKs (Python, Node.js, Java, Ruby) can streamline API interactions, handling authentication, request formatting, and response parsing.
  • Utilize the CLI: The Data Generator CLI allows local data generation without direct API calls, which can be useful for populating local development databases or generating large datasets offline.
  • Set up Mock API Servers: Random Data's Mock API Server feature enables developers to create endpoints that return predefined or dynamically generated data, facilitating frontend and mobile development without a fully functional backend.
  • Monitor Usage: Track your API request usage and manage your subscription through the Random Data dashboard. This helps in understanding consumption patterns and planning for scaling.
  • Review Pricing Plans: If your needs exceed the free tier, examine the Random Data pricing page for information on paid plans, which offer increased request limits, advanced features, and dedicated support.

Troubleshooting the first call

Issues during the initial API call are often related to authentication or request formatting. Here are common troubleshooting steps:

  • API Key Verification: Double-check that the API key in your request exactly matches the key displayed in your Random Data dashboard. Ensure there are no leading or trailing spaces or incorrect characters.
  • Authorization Header Format: Confirm that the Authorization header is correctly formatted as Bearer YOUR_API_KEY. Missing the Bearer prefix or incorrect spacing will result in authentication failures.
  • Content-Type Header: For POST requests with a JSON body, ensure the Content-Type: application/json header is present. The absence of this header can lead to the API misinterpreting the request body.
  • Schema Validation Errors: If the API returns an error related to the schema, review the Random Data API reference to ensure your schema definition adheres to the expected format and available data types. Syntax errors in the JSON payload are a common cause.
  • Network Connectivity: Verify that your development environment has an active internet connection and is not blocked by a firewall or proxy from accessing api.randomdata.com.
  • Rate Limiting: While unlikely on a first call, if you are quickly iterating, be aware of the API rate limits. Exceeding these limits, especially on the free tier, can temporarily block requests.
  • Error Messages: Pay close attention to the error messages returned by the API. They often provide specific details about what went wrong, such as 401 Unauthorized for authentication issues or 400 Bad Request for malformed requests.
  • SDK Specific Issues: If using an SDK, ensure it is the latest version. Consult the specific SDK documentation for any known issues or specific setup requirements.