Light Rider Logo

QuantumLiFi API Documentation

The QuantumLiFi API provides access to true quantum randomness generated from our quantum terminals. Use this API to incorporate high-quality entropy into your applications for cryptography, simulations, gaming, and more.

Our system uses IDQ250C2 quantum random number generator (QRNG) chips to produce true randomness based on quantum phenomena, providing the highest quality entropy source available.

Authentication

All API requests require authentication using an API key. Include your API key in the X-API-Key header:

curl -X GET "https://quantumlifi.com/api/random/int?min=1&max=100" \
  -H "X-API-Key: your-api-key-here"
              

Rate Limits

Rate limits vary based on your subscription plan:

Plan Requests per Day Requests per Minute Max Bytes per Request
Free 1,000 60 1,024
Pro 100,000 600 10,240
Enterprise Unlimited 6,000 102,400

Entropy Sources

Our API uses different entropy sources based on availability and request load:

  • Quantum Source: IDQ250C2 quantum random number generator (highest quality)
  • Hybrid Source: Mixture of quantum entropy and CSPRNG during high-load periods
  • CSPRNG Fallback: Used in rare cases of quantum source unavailability
{
  "success": true,
  "source": "quantum",  // Possible values: "quantum", "hybrid", "csprng"
  "value": 42,
  "timestamp": "2025-04-20T14:32:15Z"
}
              

API Reference

Random Integer

GET /api/random/int

Returns a random integer within the specified range (inclusive).

Query Parameters

Parameter Type Required Description
min integer No Minimum value (default: 0)
max integer No Maximum value (default: 100)
count integer No Number of random integers to generate (default: 1, max: 1000)

Random Float

GET /api/random/float

Returns a random floating-point number within the specified range.

Query Parameters

Parameter Type Required Description
min number No Minimum value (default: 0.0)
max number No Maximum value (default: 1.0)
precision integer No Number of decimal places (default: 10, max: 16)
count integer No Number of random floats to generate (default: 1, max: 1000)

Random Bytes

GET /api/random/bytes

Returns random bytes in the specified format.

Query Parameters

Parameter Type Required Description
length integer No Number of bytes to generate (default: 16, max varies by plan)
format string No Output format: "hex", "base64", or "binary" (default: "hex")

API Status

GET /api/status

Returns the current status of the QuantumLiFi API and entropy buffer health.

Response Example

{
  "status": "operational",
  "terminalId": "quantum-terminal-01",
  "uptime": "120.35 minutes",
  "bufferHealth": 98,
  "entropyRate": "simulated",
  "timestamp": "2025-04-20T14:36:22Z"
}
                

Client Libraries

We provide official client libraries for several programming languages:

// Using fetch API
function getRandomInt() {
  const apiKey = 'your-api-key-here';

  return fetch('https://quantumlifi.com/api/random/int?min=1&max=100', {
    method: 'GET',
    headers: {
      'X-API-Key': apiKey
    }
  })
  .then(response => {
    if (!response.ok) {
      throw new Error(`HTTP error! Status: ${response.status}`);
    }
    return response.json();
  })
  .then(data => {
    console.log(`Random number: ${data.value}`);
    console.log(`Source: ${data.source}`);
    return data;
  })
  .catch(error => {
    console.error('Error fetching random number:', error);
    throw error;
  });
}

// Using the official client library
import { QuantumClient } from 'quantumlifi';

const client = new QuantumClient({
  apiKey: 'your-api-key-here'
});

async function getRandomBytes() {
  try {
    const response = await client.getRandomBytes({
      length: 32,
      format: 'hex'
    });

    console.log(`Random bytes: ${response.data}`);
    console.log(`Source: ${response.source}`);
    return response;
  } catch (error) {
    console.error('Error:', error);
    throw error;
  }
}
                  
import requests

# Using the requests library
def get_random_int(min_value=1, max_value=100):
    api_key = 'your-api-key-here'
    url = f'https://quantumlifi.com/api/random/int?min={min_value}&max={max_value}'

    headers = {
        'X-API-Key': api_key
    }

    try:
        response = requests.get(url, headers=headers)
        response.raise_for_status()  # Raises an exception for 4XX/5XX responses

        data = response.json()
        print(f"Random number: {data['value']}")
        print(f"Source: {data['source']}")
        return data
    except requests.exceptions.RequestException as e:
        print(f"Error fetching random number: {e}")
        raise

# Using the official client library
from quantumlifi import QuantumClient

client = QuantumClient(api_key='your-api-key-here')

def get_random_bytes(length=32, format='hex'):
    try:
        response = client.get_random_bytes(length=length, format=format)
        print(f"Random bytes: {response['data']}")
        print(f"Source: {response['source']}")
        return response
    except Exception as e:
        print(f"Error: {e}")
        raise
                  
package main

import (
    "encoding/json"
    "fmt"
    "io"
    "net/http"
    "time"
)

type RandomIntResponse struct {
    Success   bool   `json:"success"`
    Source    string `json:"source"`
    Value     int    `json:"value"`
    Timestamp string `json:"timestamp"`
}

func GetRandomInt(min, max int) (RandomIntResponse, error) {
    apiKey := "your-api-key-here"
    url := fmt.Sprintf("https://quantumlifi.com/api/random/int?min=%d&max=%d", min, max)

    client := &http.Client{
        Timeout: time.Second * 10,
    }

    req, err := http.NewRequest("GET", url, nil)
    if err != nil {
        return RandomIntResponse{}, err
    }

    req.Header.Set("X-API-Key", apiKey)

    resp, err := client.Do(req)
    if err != nil {
        return RandomIntResponse{}, err
    }
    defer resp.Body.Close()

    if resp.StatusCode != http.StatusOK {
        return RandomIntResponse{}, fmt.Errorf("unexpected status code: %d", resp.StatusCode)
    }

    bodyBytes, err := io.ReadAll(resp.Body)
    if err != nil {
        return RandomIntResponse{}, err
    }

    var result RandomIntResponse
    if err := json.Unmarshal(bodyBytes, &result); err != nil {
        return RandomIntResponse{}, err
    }

    fmt.Printf("Random number: %d\n", result.Value)
    fmt.Printf("Source: %s\n", result.Source)

    return result, nil
}

// Using the official client library
// import "github.com/quantumlifi/go-client"
                  
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.time.Duration;
import org.json.JSONObject;

public class QuantumLiFiExample {
    private static final String API_KEY = "your-api-key-here";
    private static final String BASE_URL = "https://quantumlifi.com/api";

    private final HttpClient httpClient;

    public QuantumLiFiExample() {
        this.httpClient = HttpClient.newBuilder()
                .connectTimeout(Duration.ofSeconds(10))
                .build();
    }

    public JSONObject getRandomInt(int min, int max) throws Exception {
        String url = String.format("%s/random/int?min=%d&max=%d", BASE_URL, min, max);

        HttpRequest request = HttpRequest.newBuilder()
                .uri(URI.create(url))
                .header("X-API-Key", API_KEY)
                .GET()
                .build();

        HttpResponse response = httpClient.send(request,
                HttpResponse.BodyHandlers.ofString());

        if (response.statusCode() != 200) {
            throw new RuntimeException("Unexpected status code: " + response.statusCode());
        }

        JSONObject result = new JSONObject(response.body());

        System.out.println("Random number: " + result.getInt("value"));
        System.out.println("Source: " + result.getString("source"));

        return result;
    }

    public static void main(String[] args) {
        try {
            QuantumLiFiExample example = new QuantumLiFiExample();
            JSONObject result = example.getRandomInt(1, 100);
            System.out.println(result.toString(2));  // Pretty print JSON
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

// Using the official client library
// import com.quantumlifi.api.QuantumClient;
                  

Error Handling

The API returns standard HTTP status codes along with a JSON error response:

Status Code Description
200 OK The request was successful
400 Bad Request The request was malformed or contained invalid parameters
401 Unauthorized Missing or invalid API key
429 Too Many Requests Rate limit exceeded
500 Internal Server Error An error occurred on the server

Error Response Format

{
  "success": false,
  "error": {
    "code": "rate_limit_exceeded",
    "message": "You have exceeded your rate limit. Please try again later.",
    "details": {
      "retry_after": 60
    }
  }
}