78 lines
2.1 KiB
Python
78 lines
2.1 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Check DAOhaus API Response
|
|
|
|
This script checks the response from the DAOhaus API for Public Haus DAO.
|
|
"""
|
|
|
|
import requests
|
|
import sys
|
|
|
|
# Constants
|
|
DAOHAUS_API_URL = "https://admin.daohaus.club/api"
|
|
PUBLIC_HAUS_DAO_ID = "0xf5d6b637a9185707f52d40d452956ca49018247a" # Public Haus DAO ID on Optimism
|
|
CHAIN_ID = "10" # Optimism chain ID
|
|
|
|
def check_api_response(url):
|
|
"""
|
|
Check the response from an API URL
|
|
|
|
Args:
|
|
url: The URL to check
|
|
"""
|
|
print(f"Checking URL: {url}")
|
|
|
|
try:
|
|
# Make request to API
|
|
response = requests.get(url)
|
|
|
|
# Print status code
|
|
print(f"Status code: {response.status_code}")
|
|
|
|
# Print headers
|
|
print("Headers:")
|
|
for key, value in response.headers.items():
|
|
print(f" {key}: {value}")
|
|
|
|
# Print content
|
|
print("\nContent:")
|
|
print(response.text)
|
|
|
|
# Try to parse as JSON
|
|
try:
|
|
data = response.json()
|
|
print("\nJSON data:")
|
|
print(data)
|
|
except Exception as e:
|
|
print(f"\nError parsing JSON: {e}")
|
|
|
|
except Exception as e:
|
|
print(f"Exception checking API: {e}")
|
|
|
|
def main():
|
|
"""Main function"""
|
|
# Check DAO info endpoint
|
|
dao_url = f"{DAOHAUS_API_URL}/dao/{CHAIN_ID}/{PUBLIC_HAUS_DAO_ID}"
|
|
print(f"Checking DAO info endpoint: {dao_url}")
|
|
check_api_response(dao_url)
|
|
|
|
print("\n" + "=" * 80 + "\n")
|
|
|
|
# Check members endpoint
|
|
members_url = f"{DAOHAUS_API_URL}/dao/{CHAIN_ID}/{PUBLIC_HAUS_DAO_ID}/members"
|
|
print(f"Checking members endpoint: {members_url}")
|
|
check_api_response(members_url)
|
|
|
|
# Try alternative API URL
|
|
print("\n" + "=" * 80 + "\n")
|
|
print("Trying alternative API URL...")
|
|
|
|
alt_api_url = "https://api.daohaus.club/api"
|
|
alt_dao_url = f"{alt_api_url}/dao/{CHAIN_ID}/{PUBLIC_HAUS_DAO_ID}"
|
|
print(f"Checking alternative DAO info endpoint: {alt_dao_url}")
|
|
check_api_response(alt_dao_url)
|
|
|
|
return 0
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main()) |