This article explains how to download additional solve metadata for a completed solve using the API (with a Python example). This can also be translated into other programming languages.
The full API docs can be found here.
Prerequisites
Before you begin:
- Authenticate and load your access token
- The
load_token()andauthenticate()functions are given in the Authenticating and getting a token article
- The
- Having a solve ID to pass in for the
solve_idvariable. You can get this from:- If using the API to submit your solves, the response to the
/solveendpoint is a list of solve ID(s) - If looking through the web UI, the solve ID can be found in the URL where it says
id=, for example this solve ID is 1234./solve?id=1234
- If using the API to submit your solves, the response to the
Example: Python code to download the solution JSON
import json
def download_solve_info(token, solve_id, output_path="solve.json"):
"""
Downloads the solve data as JSON and saves it locally.
"""
url = f"{BASE_URL}/solve"
headers = {"Authorization": f"Bearer {token}"}
params = {"solve_id": solve_id}
print("⬇️ Downloading solve information...")
response = requests.get(url, headers=headers, params=params)
response.raise_for_status()
data = response.json()
# Save directly to JSON file
with open(output_path, "w", encoding="utf-8") as f:
json.dump(data, f, indent=2, ensure_ascii=False)
print(f"✅ Solve information saved to {output_path}")
# Main workflow
if __name__ == "__main__":
token = load_token() or authenticate()
print("✅ Authenticated")
solve_id = "<populate your solve ID here>"
download_solve_info(token, solve_id, "solve.json")
Comments
0 comments
Please sign in to leave a comment.