Docs / SDKs / cURL
🖥

cURL Examples

Direct HTTP examples using cURL for every TrueEntropy API endpoint. Useful for quick testing, shell scripts, CI/CD pipelines, and any language without an official SDK.

Authentication

All requests require a Bearer token in the Authorization header:

curl https://api.trueentropy.net/v1/integers \ -H "Authorization: Bearer te_live_YOUR_KEY"

GET /v1/integers

Random integers between 1 and 100
curl https://api.trueentropy.net/v1/integers \ -H "Authorization: Bearer te_live_YOUR_KEY" \ -G -d "count=10" \ -d "min=1" \ -d "max=100"

GET /v1/floats

Random floats with 10 decimal places
curl https://api.trueentropy.net/v1/floats \ -H "Authorization: Bearer te_live_YOUR_KEY" \ -G -d "count=5" \ -d "precision=10"

GET /v1/bytes

32 random bytes as hex
curl https://api.trueentropy.net/v1/bytes \ -H "Authorization: Bearer te_live_YOUR_KEY" \ -G -d "count=32" \ -d "encoding=hex"
32 random bytes as base64
curl https://api.trueentropy.net/v1/bytes \ -H "Authorization: Bearer te_live_YOUR_KEY" \ -G -d "count=32" \ -d "encoding=base64"

GET /v1/uuid

Generate 3 quantum UUIDs
curl https://api.trueentropy.net/v1/uuid \ -H "Authorization: Bearer te_live_YOUR_KEY" \ -G -d "count=3"

GET /v1/bitstring

256-bit random bitstring
curl https://api.trueentropy.net/v1/bitstring \ -H "Authorization: Bearer te_live_YOUR_KEY" \ -G -d "length=256"

GET /v1/shuffle

Quantum Fisher-Yates shuffle
curl https://api.trueentropy.net/v1/shuffle \ -H "Authorization: Bearer te_live_YOUR_KEY" \ -G --data-urlencode "items=1,2,3,4,5,6,7,8,9,10"

POST /v1/batch

Bulk 100k integers
curl -X POST https://api.trueentropy.net/v1/batch \ -H "Authorization: Bearer te_live_YOUR_KEY" \ -H "Content-Type: application/json" \ -d '{"type":"integers","count":100000,"params":{"min":1,"max":1000000}}'

GET /v1/certificate

Retrieve provenance certificate (JSON)
curl https://api.trueentropy.net/v1/certificate \ -H "Authorization: Bearer te_live_YOUR_KEY" \ -G -d "id=cert_a7f2b9c4d8e1"
Download certificate as PDF
curl https://api.trueentropy.net/v1/certificate \ -H "Authorization: Bearer te_live_YOUR_KEY" \ -G -d "id=cert_a7f2b9c4d8e1" \ -d "format=pdf" \ -o certificate.pdf

Response Headers

View QuBitLang response headers with the -i flag:

curl -i https://api.trueentropy.net/v1/integers \ -H "Authorization: Bearer te_live_YOUR_KEY" \ -G -d "count=1" # 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: 49

Shell Script Example

generate_keys.sh
#!/bin/bash API_KEY="te_live_YOUR_KEY" BASE="https://api.trueentropy.net/v1" # Generate a 256-bit random key (32 bytes hex) KEY=$(curl -s "$BASE/bytes?count=32&encoding=hex" \ -H "Authorization: Bearer $API_KEY" | jq -r '.data.bytes') echo "Quantum random key: $KEY" # Generate a quantum UUID UUID=$(curl -s "$BASE/uuid?count=1" \ -H "Authorization: Bearer $API_KEY" | jq -r '.data.uuids[0]') echo "Quantum UUID: $UUID"

Error Handling

Check HTTP status code
curl -s -o response.json -w "%{http_code}" \ https://api.trueentropy.net/v1/integers \ -H "Authorization: Bearer te_live_YOUR_KEY" \ -G -d "count=10" # Returns: 200, 400, 401, 429, etc.