Skip to content

Instantly share code, notes, and snippets.

@xmonader
Created January 29, 2025 15:56
Show Gist options
  • Save xmonader/24bd6954e69e6960b8a3bc5c2914f6fd to your computer and use it in GitHub Desktop.
Save xmonader/24bd6954e69e6960b8a3bc5c2914f6fd to your computer and use it in GitHub Desktop.
import requests
import json
url = "https://graphql.grid.tf/graphql"
# Change timestamp_gt if needed
query = """
query MyQuery {
contractBillReports(where: {timestamp_gt: "1735745739"}) {
amountBilled
}
}
"""
response = requests.post(
url,
json={
"query": query
},
headers={
"Content-Type": "application/json",
}
)
if response.status_code == 200:
total = 0
data = response.json()
if "data" in data:
# Extract the results
results = data["data"]["contractBillReports"]
for report in results:
amt = report['amountBilled']
print(f"Amount Billed: {amt}")
total += int(amt)
print("total: ", total)
else:
print("No data returned.")
else:
print(f"Request failed. Status code: {response.status_code}")
try:
response.raise_for_status()
except Exception as e:
print(e)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment