From 5f4fc93e37314836fb1cc79f843c0631cf4cf1c2 Mon Sep 17 00:00:00 2001 From: Nathan Woodburn Date: Fri, 18 Jul 2025 12:55:36 +1000 Subject: [PATCH] feat: Initial staked domains --- shakestation.py | 37 ++++++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/shakestation.py b/shakestation.py index eac22e1..09fd20c 100644 --- a/shakestation.py +++ b/shakestation.py @@ -43,6 +43,27 @@ functions = { def main(params, authentication): return {"status": "Success"} + +def checkStaked(domain): + """ + Check if a domain is staked on Shakestation. + """ + response = requests.post(f"https://shakestation.io/api", + data={"action":"getStakedTLD","tld":domain}) + + if response.status_code != 200: + return False + + data = response.json() + + # Check if the domain is staked + if "data" not in data: + return False + + return data["data"] + + return False + def domain_info(params, authentication): domain = params.get("domain") if not domain: @@ -62,25 +83,27 @@ def domain_info(params, authentication): return {"info": "No type found in the data"} domainType = data["data"]["type"] - skippedTypes = ["auction"] score = data["data"].get("score", "No score available") - if domainType in skippedTypes: - return {"info": f"

Score: {score}

"} - + returnInfo = f"

Score: {score}

" if domainType == "marketplace": price = data["data"].get("price", "No price available") - return {"info": f"

Score: {score}
Price: {price}

View Listing"} - + returnInfo = f"

Score: {score}
Price: {price}

View Listing" + stakedData = checkStaked(domain) + if stakedData: + returnInfo += f"

Staked: {stakedData.get('price', '-1')} HNS ({stakedData.get('renew_price','-1')} HNS/yr)

" - return {"info": f"TODO: {domainType} domain type not implemented yet. Data: {data}"} + return {"info": returnInfo} if __name__ == "__main__": # Example usage params = {"domain": "pinwheelgalaxy"} authentication = None # Replace with actual authentication if needed result = domain_info(params, authentication) + print(json.dumps(result, indent=2)) + params = {"domain": "denizen"} + result = domain_info(params, authentication) print(json.dumps(result, indent=2)) \ No newline at end of file