3.5 Python Examples
Python code examples for interacting with the JSONAir API.
Authentication — Get a Bearer Token
import json
import urllib.request
import urllib.error
def get_token(base_url: str, pat: str) -> str:
payload = json.dumps({"token": pat}).encode()
req = urllib.request.Request(
f"{base_url}/api/v1/jsonair/auth/token",
data=payload,
headers={"Content-Type": "application/json"},
method="POST",
)
with urllib.request.urlopen(req) as resp:
body = json.loads(resp.read())
return body["access_token"]Fetch Configuration Data
Putting It Together — Poll with Re-Authentication
Fetch the Reload Key
Fetch the Debug Level
Last updated