-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_api.py
More file actions
30 lines (23 loc) · 688 Bytes
/
test_api.py
File metadata and controls
30 lines (23 loc) · 688 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import requests
import os
from dotenv import load_dotenv
load_dotenv()
API_KEY = os.getenv('SPOONACULAR_API_KEY')
def test_api():
url = "https://api.spoonacular.com/recipes/complexSearch"
params = {
"apiKey": API_KEY,
"number": 1,
"addRecipeInformation": True
}
print(f"Testing API with key: {API_KEY[:5]}...")
response = requests.get(url, params=params)
print(f"Status Code: {response.status_code}")
if response.status_code == 200:
data = response.json()
print("\nAPI Response:")
print(data)
else:
print(f"Error Response: {response.text}")
if __name__ == "__main__":
test_api()