Skip to content

Instantly share code, notes, and snippets.

@chrisjbillington
Last active September 18, 2023 01:35
Show Gist options
  • Save chrisjbillington/243dba897d5cf7a71edc0fc486ef93b8 to your computer and use it in GitHub Desktop.
Save chrisjbillington/243dba897d5cf7a71edc0fc486ef93b8 to your computer and use it in GitHub Desktop.
import requests
SUPABASE_URL = "https://pxidrgkatumlvfqaxcll.supabase.co"
SUPABASE_ANON_KEY = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InB4aWRyZ2thdHVtbHZmcWF4Y2xsIiwicm9sZSI6ImFub24iLCJpYXQiOjE2Njg5OTUzOTgsImV4cCI6MTk4NDU3MTM5OH0.d_yYtASLzAoIIGdXUBIgRAGLBnNow7JG2SoaNMQ8ySg"
HEADERS = {
"Accept": "*/*",
"Accept-Language": "en-US,en;q=0.9",
"Apikey": SUPABASE_ANON_KEY,
"Authorization": f"Bearer {SUPABASE_ANON_KEY}",
"Content-Type": "application/json",
"Origin": "https://manifold.markets",
"Referer": "https://manifold.markets/",
"User-Agent": "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Mobile Safari/537.36",
"X-Client-Info": "supabase-js/2.2.0",
}
def get_mana_purchases(user_id, limit=1000):
endpoint = f"{SUPABASE_URL}/rest/v1/txns"
params = {
"select": "*",
"order": "data->>createdTime.desc",
"limit": str(limit),
"data->>category": 'eq.MANA_PURCHASE',
"data->>toId": f'eq.{user_id}'
}
response = requests.get(endpoint, headers=HEADERS, params=params, timeout=30)
if response.status_code == 200:
return response.json()
else:
raise ValueError(f"Error {response.status_code}: {response.text}")
USER = "FzpgR5aK88WvlbER2dKykybnDn42"
total = 0
n_txns = 0
for txn in get_mana_purchases(user_id=USER, limit=1000):
amount = txn['data']['amount']
total += amount
n_txns += 1
print(f"M{total} purchased in {n_txns} transactions")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment