network/gaiia/examples/basic.py
2026-07-19 14:42:02 -05:00

39 lines
1.1 KiB
Python

"""Minimal usage example.
Set GAIIA_KEY in your env, then ``python examples/basic.py``.
"""
from __future__ import annotations
import os
from gaiia import GaiiaClient
def main() -> None:
with GaiiaClient(timezone="America/Chicago") as g:
techs = g.query("{ technicians(first: 5) { nodes { id readableId firstName lastName } } }")
for t in techs["technicians"]["nodes"]:
print(f"{t['readableId']:>4} {t['firstName']} {t['lastName']} {t['id']}")
print("rate-limit:", g.last_rate_limit)
print("\npaginating all technicians:")
for t in g.iter_nodes(
"""
query Q($after: String) {
technicians(first: 50, after: $after) {
nodes { id readableId firstName lastName }
pageInfo { hasNextPage endCursor }
}
}
""",
"technicians",
):
print(f" {t['readableId']:>4} {t['firstName']} {t['lastName']}")
if __name__ == "__main__":
if not os.environ.get("GAIIA_KEY"):
raise SystemExit("Set GAIIA_KEY in your env first.")
main()