diff --git a/node/main.py b/node/main.py index f231744..5adda28 100644 --- a/node/main.py +++ b/node/main.py @@ -4,28 +4,30 @@ import json -UPSHOT_API_TOKEN = os.environ.get('UPSHOT_API_TOKEN') +UPSHOT_API_TOKEN = os.environ.get("UPSHOT_API_TOKEN") + def get_signed_appraisal(asset_id): return f"https://api.upshot.xyz/v2/appraisals/assets/signed?asset_ids={asset_id.lower()}" + def get_asset_appraisal(asset_id, api_key): # Get the signed appraisal URL for the asset url = get_signed_appraisal(asset_id) - + # Send a GET request to the Upshot API with the signed URL and API key - response = requests.get(url, headers={'x-api-key': api_key}) - + response = requests.get(url, headers={"x-api-key": api_key}) + # Check if the request was successful if response.status_code != 200: return None - + # Parse the response JSON res = response.json() - + try: # Extract the asset appraisal from the response data - appraisal = res['data'][0]['price'] + appraisal = res["data"][0]["price"] return f"{appraisal}" except Exception as e: # Return None if there is an error or no appraisal data available @@ -51,7 +53,7 @@ def process(asset_id): if __name__ == "__main__": # Your code logic with the parsed argument goes here try: - asset_id = sys.argv[1] + asset_id = sys.argv[2] process(asset_id) except Exception as e: response = json.dumps({"error": {str(e)}})