GET
/v1/bitstring
QuBitLang
Returns a raw quantum random bitstring - a sequence of 0s and 1s. Each bit is the direct result of a quantum measurement collapse. Ideal for cryptographic protocols, quantum simulation, and binary randomness.
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
| length | integer | No | 128 | Number of bits to generate (1–4,096) |
Code Examples
bitstring.py
from trueentropy import TrueEntropy
client = TrueEntropy(api_key="te_live_YOUR_KEY")
result = client.bitstring(length=256)
print(result.bits)
# "101101001110100101101001110100101..."
print(len(result.bits))
# 256
bitstring.js
import { TrueEntropy } from '@trueentropy/sdk';
const client = new TrueEntropy('te_live_YOUR_KEY');
const result = await client.bitstring({ length: 256 });
console.log(result.data.bits);
// "101101001110100101101001110100101..."
bitstring.php
use TrueEntropy\Client;
$client = new Client('te_live_YOUR_KEY');
$result = $client->bitstring(['length' => 256]);
echo $result->bits;
Terminal
curl https://api.trueentropy.net/v1/bitstring \
-H "Authorization: Bearer te_live_YOUR_KEY" \
-G -d "length=256"
Response
200 OKJSON
{
"data": {
"bits": "10110100111010010110...01001110100101",
"length": 256
},
"metadata": {
"request_id": "req_e5f6a7b8c9d0",
"timestamp": "2026-03-09T15:42:17Z",
"qubitlang_circuit": "qrng_hadamard_v2.3",
"qubitlang_version": "1.4.0",
"quantum_backend": "ibm_fez",
"nist_verified": true,
"certificate_id": "cert_e5f6a7b8c9d0",
"powered_by": "QuBitLang"
}
}
Response Headers
X-QuBitLang-Circuit: qrng_hadamard_v2.3
X-QuBitLang-Version: 1.4.0
X-Quantum-Backend: ibm_fez
X-NIST-Verified: true
X-RateLimit-Remaining: 47
X-RateLimit-Reset: 1741536180
Errors
| Status | Code | Description |
|---|---|---|
| 400 | invalid_length | length must be between 1 and 4,096 |
| 401 | auth_missing | No API key provided |
| 401 | auth_invalid | API key is invalid or revoked |
| 429 | rate_limited | Rate limit exceeded |