Quickstart

Integrate hardware-extracted, cryptographically conditioned entropy into your application in minutes using our official Python and Node.js SDKs, or direct API endpoints.


Authentication

All requests to the Quey Cloud API require an API key. You can generate an API key from your Dashboard.

Authenticate your requests by providing your API key in a custom header named x-quey-key.

x-quey-key: qu_cloud_your_api_key_here

Security Note

Never hardcode your API key in production. Always use environment variables or a secure secrets manager.


Installation (Python SDK)

The easiest way to interact with Quey is via our official Python SDK. Install the package via pip:

$ pip install quey-random

Initialize the client with your API key and request entropy:

generate_seed.py
from quey_random import QueyRandom

# Initialize the client with your secure Cloud API key
quey = QueyRandom(api_key="qu_cloud_your_api_key_here")

# Fetch 32 bytes (256 bits) of hardware-extracted entropy
seed = quey.get_bytes(32)
print(f"Entropy Seed: {seed.hex()}")

# Generate a uniform true random float for simulations
val = quey.random()
print(f"Photonic Entropy: {val}")

Installation (Node.js SDK)

You can also interact with Quey using our official Node.js/TypeScript SDK. Install the package via npm:

$ npm install quey-random

Initialize the client with your API key and request entropy:

generateSeed.ts
import { QueyRandom } from 'quey-random';

// Initialize the client
const client = new QueyRandom('qu_cloud_your_api_key_here');

async function generateSeed() {
  // Request 32 bytes (256 bits) of hardware-extracted entropy
  const seedBuffer = await client.getBytes(32);
  
  console.log(`Entropy Seed: ${seedBuffer.toString('hex')}`);
  // Output: Entropy Seed: 7f8a9b2...
}

generateSeed();

Example: Monte-Carlo Simulation

Estimate π by sampling random points in the unit square. Pre-fetch a buffer for fast random() calls in tight loops.

monte_carlo_pi.py
from quey_random import QueyRandom

quey = QueyRandom(api_key="qu_cloud_your_api_key_here")

# Pre-fetch a buffer for fast random() calls
quey.prefetch(megabytes=10)

# Run 100k Monte-Carlo iterations to estimate π
inside = 0
for _ in range(100_000):
    x = quey.random()
    y = quey.random()
    if x*x + y*y <= 1:
        inside += 1

pi_estimate = 4 * inside / 100_000
print(f"π ≈ {pi_estimate}")

Example: Verifiable Raffle Draw

Pick winners from a participant list and obtain a signed verification certificate proving the draw used physical entropy.

raffle_draw.js
import { QueyRandom } from 'quey-random';

const quey = new QueyRandom({ apiKey: process.env.QUEY_API_KEY });

// Draw 10 winners from 50,000 participants with a verifiable certificate
const draw = await quey.drawWithCertificate({
  participants: 50_000,
  winners: 10
});

console.log('Winners (indexes):', draw.winners);
console.log('Verification URL:', draw.certificateUrl);

Example: Cryptographic Seed Material

Get physical entropy bytes for use as input to a key derivation function (KDF), nonce material, or seed for cryptographic operations.

crypto_seed.py
from quey_random import QueyRandom

quey = QueyRandom(api_key="qu_cloud_your_api_key_here")

# Get 64 bytes (512 bits) of physical entropy as seed material
seed = quey.get_bytes(64)

# Use as seed for KDF, key derivation, nonces, etc.
print(f"Seed (hex): {seed.hex()}")

Example: Bulk Entropy Download (cURL)

Download a large block of entropy as raw binary directly via REST. Useful for offline simulation seeding or batch jobs.

# Download a 1 MB block of entropy as binary
curl -X GET "https://api.queyquantum.io/v1/entropy/bulk?bytes=1048576" \
  -H "X-Quey-Token: qu_cloud_your_api_key_here" \
  --output entropy_block.bin

# Verify entropy quality locally
sha256sum entropy_block.bin

REST API

For environments where the SDK is not available, you can interact directly with our REST API to fetch raw entropy blocks.

GET https://us-central1-quey-deb85.cloudfunctions.net/getQuantumEntropy

Returns a hex-encoded string of hardware-extracted random bytes.

Query Parameters

Parameter Type Description
size integer Number of bytes to return (Max: 10240). Default: 32.
format string Output format: hex, base64, or binary. Default: hex.

Example Request (cURL)

curl -X GET "https://us-central1-quey-deb85.cloudfunctions.net/getQuantumEntropy?size=32" \
  -H "x-quey-key: qu_cloud_your_api_key_here"

Example Response

{
  "status": "success",
  "bytes_returned": 32,
  "entropy_hex": "7f8a9b2c4e5f6d7a8b9c0d1e2f3a4b5c6d7e8f9a0b1c2d3e4f5a6b7c8d9e0f1",
  "node_id": "quey_edge_01"
}