31 lines
876 B
Python
31 lines
876 B
Python
import requests
|
|
import json
|
|
|
|
def test_api():
|
|
url = "http://localhost:8000/api/metrics/query"
|
|
params = {
|
|
"metric_type": "weight",
|
|
"source": "fitbit",
|
|
"start_date": "2025-01-01",
|
|
"end_date": "2026-01-02",
|
|
"limit": 1000 # Try requesting 1000
|
|
}
|
|
|
|
try:
|
|
response = requests.get(url, params=params)
|
|
response.raise_for_status()
|
|
data = response.json()
|
|
print(f"Status: {response.status_code}")
|
|
print(f"Records returned: {len(data)}")
|
|
if len(data) < 10:
|
|
print("Data preview:", json.dumps(data, indent=2))
|
|
else:
|
|
print("First record:", json.dumps(data[0], indent=2))
|
|
print("Last record:", json.dumps(data[-1], indent=2))
|
|
|
|
except Exception as e:
|
|
print(f"Error: {e}")
|
|
|
|
if __name__ == "__main__":
|
|
test_api()
|