Skip to content

Instantly share code, notes, and snippets.

@cqtsma2
Last active March 30, 2024 21:28
Show Gist options
  • Save cqtsma2/27af54ffddd6ababd114d9f642517611 to your computer and use it in GitHub Desktop.
Save cqtsma2/27af54ffddd6ababd114d9f642517611 to your computer and use it in GitHub Desktop.
ANU Quantum Numbers API examples
#!/usr/bin/python3
import json
import requests
QRN_URL = "https://api.quantumnumbers.anu.edu.au/"
QRN_KEY = "txxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx7" # replace with your secret API-KEY
DTYPE = "uint8" # uint8, uint16, hex8, hex16
LENGTH = 10 # between 1--1024
BLOCKSIZE = 1 # between 1--10. Only needed for hex8 and hex16
params = {"length": LENGTH, "type": DTYPE, "size": BLOCKSIZE}
headers = {"x-api-key": QRN_KEY}
response = requests.get(QRN_URL, headers=headers, params=params)
if response.status_code == 200:
js = response.json()
if js["success"] == True:
print(js["data"])
else:
print(js["message"])
else:
print(f"Got an unexpected status-code: {response.status_code}")
print(response.text)
#!/bin/bash
QRN_URL=https://api.quantumnumbers.anu.edu.au/
QRN_KEY=txxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx7 # replace with your secret API-KEY
curl -H x-api-key:${QRN_KEY} ${QRN_URL}?type=hex16\&length=10\&size=10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment