Production-ready quantum random number generation with cryptographic proofs, blockchain anchoring, and post-quantum signatures. This documentation covers everything you need to integrate QRNG API into your applications.
Generate your first quantum random bytes in 60 seconds:
Sign up at qrngapi.com/signup and get your API key from the Dashboard.
curl -X POST https://qrngapi.com/api/random \
-H "Content-Type: application/json" \
-H "X-API-Key: qrng_your_api_key_here" \
-d '{
"bytes": 32,
"format": "hex"
}'
{
"entropy": "a1b2c3d4e5f6789012345678901234567890abcdef1234567890abcdef123456",
"bytes": 32,
"format": "hex",
"method": "photon",
"timestamp": "2025-01-15T12:00:00.000Z",
"signature": "base64_encoded_ed25519_signature...",
"publicKey": "base64_encoded_public_key...",
"hash": "sha3_256_hash_of_entropy..."
}
All API requests require authentication using an API key. Include your key in the request header:
X-API-Key: qrng_xxxxxxxxxxxxxxxxxxxxxxxxxxxx
qrng_ followed by 32 alphanumeric characters.
Base URL: https://qrngapi.com/api
Generate quantum random bytes with cryptographic proof and optional blockchain anchoring.
| Header | Required | Description |
|---|---|---|
Content-Type | Yes | Must be application/json |
X-API-Key | Yes | Your API key |
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
bytes | integer | Yes | - | Number of random bytes to generate (1-1024) |
format | string | No | hex | Output format: hex, base64, or array |
method | string | No | auto | Quantum method: photon, tunneling, vacuum, thermal |
signatureType | string | No | ed25519 | Signature algorithm: ed25519, dilithium2, dilithium3, dilithium5 |
notarize | boolean | No | false | Anchor to blockchain (Pro+ tiers) |
chain | string | No | polygon | Blockchain: polygon or avalanche |
| Field | Type | Description |
|---|---|---|
entropy | string/array | The generated random data in requested format |
bytes | integer | Number of bytes generated |
format | string | Output format used |
method | string | Quantum method used |
timestamp | string | ISO 8601 timestamp |
signature | string | Cryptographic signature (base64) |
publicKey | string | Public key for verification (base64) |
hash | string | SHA3-256 hash of entropy |
signatureType | string | Signature algorithm used |
txHash | string | Blockchain transaction hash (if notarized) |
curl -X POST https://qrngapi.com/api/random \
-H "Content-Type: application/json" \
-H "X-API-Key: qrng_your_api_key" \
-d '{
"bytes": 64,
"format": "base64",
"method": "photon"
}'
curl -X POST https://qrngapi.com/api/random \
-H "Content-Type: application/json" \
-H "X-API-Key: qrng_your_enterprise_key" \
-d '{
"bytes": 32,
"format": "hex",
"signatureType": "dilithium3"
}'
Verify the cryptographic signature of previously generated entropy.
| Parameter | Type | Required | Description |
|---|---|---|---|
entropy | string | Yes | The entropy value to verify |
signature | string | Yes | The signature from generation response |
publicKey | string | Yes | The public key from generation response |
timestamp | string | No | Original timestamp for additional validation |
{
"valid": true,
"entropy": "a1b2c3d4...",
"verifiedAt": "2025-01-15T12:01:00.000Z"
}
Check API health status and quantum hardware availability.
{
"status": "healthy",
"timestamp": "2025-01-15T12:00:00.000Z",
"hardware": {
"photon": { "status": "online", "latency": 12 },
"tunneling": { "status": "online", "latency": 15 },
"vacuum": { "status": "online", "latency": 18 },
"thermal": { "status": "maintenance", "latency": null }
},
"uptime": 99.99
}
Get your current usage statistics and quota information. Requires authentication.
{
"tier": "pro",
"period": {
"start": "2025-01-01T00:00:00.000Z",
"end": "2025-01-31T23:59:59.999Z"
},
"usage": {
"requests": 15420,
"bytes": 493440,
"limit": 100000
},
"rateLimit": {
"requestsPerMinute": 300,
"remaining": 298,
"resetsAt": "2025-01-15T12:01:00.000Z"
}
}
For real-time continuous entropy streaming, connect via WebSocket:
wss://qrngapi.com/ws/entropy?apiKey=YOUR_API_KEY
{
"action": "subscribe",
"bytes": 16,
"interval": 1000,
"format": "hex"
}
{
"type": "entropy",
"data": {
"entropy": "a1b2c3d4e5f6789012345678901234ab",
"bytes": 16,
"format": "hex",
"method": "photon",
"timestamp": "2025-01-15T12:00:01.000Z",
"sequence": 1
}
}
{
"action": "unsubscribe"
}
| Event Type | Description |
|---|---|
entropy | Entropy data packet |
subscribed | Confirmation of subscription |
unsubscribed | Confirmation of unsubscription |
error | Error message |
rateLimit | Rate limit warning |
const ws = new WebSocket('wss://qrngapi.com/ws/entropy?apiKey=YOUR_API_KEY');
ws.onopen = () => {
console.log('Connected to QRNG API');
ws.send(JSON.stringify({
action: 'subscribe',
bytes: 32,
interval: 1000,
format: 'hex'
}));
};
ws.onmessage = (event) => {
const data = JSON.parse(event.data);
if (data.type === 'entropy') {
console.log('Received entropy:', data.data.entropy);
}
};
ws.onerror = (error) => {
console.error('WebSocket error:', error);
};
ws.onclose = () => {
console.log('Disconnected from QRNG API');
};
Every entropy response includes a cryptographic signature that proves the data was generated by QRNG API. Here's how to verify signatures in different languages:
import { verify } from '@noble/ed25519';
async function verifyEntropy(response) {
const { entropy, signature, publicKey, timestamp } = response;
// Reconstruct the signed message
const message = new TextEncoder().encode(
JSON.stringify({ entropy, timestamp })
);
// Decode base64 signature and public key
const sig = Buffer.from(signature, 'base64');
const pubKey = Buffer.from(publicKey, 'base64');
// Verify the signature
const isValid = await verify(sig, message, pubKey);
return isValid;
}
from nacl.signing import VerifyKey
from nacl.exceptions import BadSignature
import base64
import json
def verify_entropy(response):
entropy = response['entropy']
signature = base64.b64decode(response['signature'])
public_key = base64.b64decode(response['publicKey'])
timestamp = response['timestamp']
# Reconstruct the signed message
message = json.dumps({'entropy': entropy, 'timestamp': timestamp}).encode()
# Verify
verify_key = VerifyKey(public_key)
try:
verify_key.verify(message, signature)
return True
except BadSignature:
return False
package main
import (
"crypto/ed25519"
"encoding/base64"
"encoding/json"
)
func verifyEntropy(response map[string]interface{}) bool {
entropy := response["entropy"].(string)
timestamp := response["timestamp"].(string)
sig, _ := base64.StdEncoding.DecodeString(response["signature"].(string))
pubKey, _ := base64.StdEncoding.DecodeString(response["publicKey"].(string))
message, _ := json.Marshal(map[string]string{
"entropy": entropy,
"timestamp": timestamp,
})
return ed25519.Verify(pubKey, message, sig)
}
QRNG API supports post-quantum signatures using the NIST-standardized Dilithium algorithm (FIPS 204). These signatures are resistant to attacks from quantum computers.
| Type | Security Level | Signature Size | Tier Required |
|---|---|---|---|
ed25519 | ~128-bit classical | 64 bytes | All tiers |
dilithium2 | ~128-bit quantum | ~2.4 KB | Pro+ |
dilithium3 | ~192-bit quantum | ~3.3 KB | Enterprise |
dilithium5 | ~256-bit quantum | ~4.6 KB | Enterprise |
curl -X POST https://qrngapi.com/api/random \
-H "Content-Type: application/json" \
-H "X-API-Key: qrng_enterprise_key" \
-d '{
"bytes": 32,
"signatureType": "dilithium3"
}'
Use one of these libraries for client-side verification:
npm install @noble/post-quantumpip install pqcrypto// JavaScript - Verifying Dilithium signatures
import { ml_dsa65 } from '@noble/post-quantum';
const isValid = ml_dsa65.verify(
publicKey,
message,
signature
);
Optionally anchor your entropy to a public blockchain for immutable proof of generation time and content.
| Chain | Network | Confirmation Time | Tier Required |
|---|---|---|---|
| Polygon | Mainnet | ~2 seconds | Pro+ |
| Avalanche | C-Chain | ~1 second | Enterprise |
curl -X POST https://qrngapi.com/api/random \
-H "Content-Type: application/json" \
-H "X-API-Key: qrng_pro_key" \
-d '{
"bytes": 32,
"notarize": true,
"chain": "polygon"
}'
{
"entropy": "a1b2c3d4...",
"bytes": 32,
"signature": "...",
"txHash": "0x1234567890abcdef...",
"chain": "polygon",
"blockNumber": 12345678
}
Production-ready client libraries with full TypeScript/type support:
pip install qrng-api
from qrng import QRNGClient
client = QRNGClient(api_key="qrng_your_api_key")
# Generate random bytes
result = client.random(bytes=32, format="hex")
print(result.entropy)
# Verify signature
is_valid = client.verify(result)
print(f"Signature valid: {is_valid}")
# Stream entropy
for entropy in client.stream(bytes=16, interval=1.0):
print(entropy.data)
npm install @qrng/sdk
import { QRNGClient } from '@qrng/sdk';
const client = new QRNGClient({ apiKey: 'qrng_your_api_key' });
// Generate random bytes
const result = await client.random({ bytes: 32, format: 'hex' });
console.log(result.entropy);
// Verify signature
const isValid = await client.verify(result);
console.log(`Signature valid: ${isValid}`);
// Stream entropy
const stream = client.stream({ bytes: 16, interval: 1000 });
stream.on('entropy', (data) => console.log(data.entropy));
stream.start();
go get github.com/qrng-api/go-sdk
package main
import (
"fmt"
"github.com/qrng-api/go-sdk/qrng"
)
func main() {
client := qrng.NewClient("qrng_your_api_key")
// Generate random bytes
result, err := client.Random(qrng.RandomRequest{
Bytes: 32,
Format: "hex",
})
if err != nil {
panic(err)
}
fmt.Println(result.Entropy)
// Verify signature
valid, _ := client.Verify(result)
fmt.Printf("Signature valid: %v\n", valid)
}
<dependency>
<groupId>io.qrng</groupId>
<artifactId>qrng-api-sdk</artifactId>
<version>1.0.0</version>
</dependency>
import io.qrng.QRNGClient;
import io.qrng.RandomResult;
public class Example {
public static void main(String[] args) {
QRNGClient client = new QRNGClient("qrng_your_api_key");
// Generate random bytes
RandomResult result = client.random()
.bytes(32)
.format("hex")
.execute();
System.out.println(result.getEntropy());
// Verify signature
boolean valid = client.verify(result);
System.out.println("Signature valid: " + valid);
}
}
cargo add qrng-api
use qrng_api::QRNGClient;
#[tokio::main]
async fn main() -> Result<(), Box> {
let client = QRNGClient::new("qrng_your_api_key");
// Generate random bytes
let result = client.random()
.bytes(32)
.format("hex")
.send()
.await?;
println!("{}", result.entropy);
// Verify signature
let valid = client.verify(&result).await?;
println!("Signature valid: {}", valid);
Ok(())
}
Rate limits are enforced per API key based on your subscription tier:
| Tier | Requests/min | Max Bytes/request | WebSocket Streams | Monthly Quota |
|---|---|---|---|---|
| Free | 10 | 64 | 1 | 10,000 requests |
| Starter | 60 | 256 | 2 | 100,000 requests |
| Pro | 300 | 512 | 5 | 1,000,000 requests |
| Enterprise | 1000+ | 1024 | Unlimited | Custom |
Every response includes rate limit information in headers:
| Header | Description |
|---|---|
X-RateLimit-Limit | Maximum requests per minute |
X-RateLimit-Remaining | Remaining requests in current window |
X-RateLimit-Reset | Unix timestamp when limit resets |
429 Too Many Requests response. Wait until the reset time before retrying.
All errors return a consistent JSON format:
{
"error": "Invalid API key format",
"code": "INVALID_API_KEY",
"status": 401,
"timestamp": "2025-01-15T12:00:00.000Z",
"requestId": "req_abc123xyz"
}
| HTTP Status | Code | Description |
|---|---|---|
| 400 | BAD_REQUEST | Invalid request parameters |
| 400 | INVALID_BYTES | Bytes must be between 1 and 1024 |
| 400 | INVALID_FORMAT | Format must be hex, base64, or array |
| 401 | INVALID_API_KEY | API key is missing or invalid |
| 401 | API_KEY_EXPIRED | API key has been revoked |
| 403 | TIER_LIMIT | Feature not available for your tier |
| 403 | QUOTA_EXCEEDED | Monthly quota exceeded |
| 429 | RATE_LIMIT | Too many requests |
| 500 | INTERNAL_ERROR | Server error - contact support |
| 503 | HARDWARE_UNAVAILABLE | Quantum hardware temporarily unavailable |
try {
const result = await client.random({ bytes: 32 });
} catch (error) {
switch (error.code) {
case 'RATE_LIMIT':
// Wait and retry
await sleep(error.retryAfter * 1000);
break;
case 'QUOTA_EXCEEDED':
// Upgrade plan or wait for next billing cycle
console.log('Monthly quota exceeded');
break;
case 'HARDWARE_UNAVAILABLE':
// Retry with different method or wait
break;
default:
console.error('Unexpected error:', error.message);
}
}
Need help integrating QRNG API? We're here to help!