-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcloze_direct_api.py
More file actions
77 lines (60 loc) · 2.25 KB
/
cloze_direct_api.py
File metadata and controls
77 lines (60 loc) · 2.25 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/usr/bin/env python3
import json
import requests
import os
# Cloze API configuration
CLOZE_API_KEY = "d6a734618ad33f0772633455ca468ef5"
CLOZE_API_URL = "https://api.cloze.com/v1"
OUTPUT_DIR = "/Users/jamesbrady/Desktop/ai_trinity_workspace/data_extraction_project"
def cloze_api_request(endpoint, params=None):
"""Make a request to the Cloze API"""
headers = {
"Authorization": f"Bearer {CLOZE_API_KEY}",
"Content-Type": "application/json"
}
url = f"{CLOZE_API_URL}/{endpoint}"
try:
response = requests.get(url, headers=headers, params=params)
response.raise_for_status()
return response.json()
except Exception as e:
print(f"Error calling {endpoint}: {e}")
return None
def extract_cloze_data():
"""Extract all available data from Cloze"""
print("🔍 Starting Cloze data extraction...")
# Try different endpoints
endpoints = [
("profile", None),
("people/list", {"limit": 50}),
("companies/list", {"limit": 50}),
("projects/list", {"limit": 50}),
("timeline/list", {"limit": 50}),
]
results = {}
for endpoint, params in endpoints:
print(f"\nTrying endpoint: {endpoint}")
data = cloze_api_request(endpoint, params)
if data:
results[endpoint.replace('/', '_')] = data
# Save to file
filename = f"cloze_{endpoint.replace('/', '_')}.json"
filepath = os.path.join(OUTPUT_DIR, filename)
with open(filepath, 'w') as f:
json.dump(data, f, indent=2)
print(f"✅ Saved {filename}")
else:
print(f"❌ Failed to get data from {endpoint}")
# Create summary
summary = {
"extraction_date": "2025-06-01",
"endpoints_tried": len(endpoints),
"successful_extractions": len(results),
"files_created": list(results.keys())
}
summary_path = os.path.join(OUTPUT_DIR, "cloze_extraction_summary.json")
with open(summary_path, 'w') as f:
json.dump(summary, f, indent=2)
print(f"\n✅ Extraction complete! Summary saved to {summary_path}")
if __name__ == "__main__":
extract_cloze_data()