-
-
Save firstuserhere/092281de1e2d8b47db9890fe992e239b to your computer and use it in GitHub Desktop.
Mana purchases; edit usernames list to change
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = "p3ADzwIUS3fk0ka80XYEE3OM3S32" | |
# 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") | |
def get_user_id(username): | |
url = f"https://manifold.markets/api/v0/user/{username}" | |
response = requests.get(url) | |
if response.status_code == 200: | |
return response.json()['id'] | |
else: | |
raise ValueError(f"Error {response.status_code}: {response.text}") | |
usernames = ["ScottAlexander", "Aella"] | |
for username in usernames: | |
try: | |
user_id = get_user_id(username) | |
total = 0 | |
n_txns = 0 | |
for txn in get_mana_purchases(user_id=user_id, limit=1000): | |
amount = txn['data']['amount'] | |
total += amount | |
n_txns += 1 | |
print(f"User {username}: M{total} purchased in {n_txns} transactions") | |
except Exception as e: | |
print(f"Failed for {username}: {e}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment