forked from Polymarket/py-clob-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathget_open_orders_with_readonly_key.py
More file actions
39 lines (29 loc) · 973 Bytes
/
get_open_orders_with_readonly_key.py
File metadata and controls
39 lines (29 loc) · 973 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import os
import httpx
from dotenv import load_dotenv
from py_clob_client.endpoints import ORDERS
load_dotenv()
def main():
host = os.getenv("CLOB_API_URL", "https://clob.polymarket.com")
# Replace with your address and readonly API key
address = os.getenv("POLY_ADDRESS", "0xc68576124eC1fF645F81a560E14003C8deF2e8fb")
readonly_api_key = os.getenv("CLOB_READONLY_API_KEY", "019aee85-4ea1-79cd-a287-8508f21209a2")
# Get all open orders for the address
response = httpx.get(
f"{host}{ORDERS}",
headers={
"POLY_READONLY_API_KEY": readonly_api_key,
"POLY_ADDRESS": address,
"Content-Type": "application/json",
},
params={
"maker_address": address,
},
follow_redirects=True,
)
if response.status_code == 200:
print(response.json())
else:
print(f"Error {response.status_code}: {response.text}")
print("Done!")
main()