Currently I have the following. From the documentation I was able to find the headers, parameters, and endpoints that I will need for the request. Unfortunately I keep running into a 400 error.
API_KEY = key
# Define the base URL for the summarizer endpoint
base_url = "https://api.search.brave.com/res/v1/summarizer/search"
headers = {
"X-Subscription-Token": API_KEY
}
params = {
"key": "This is my search!"
}
print(headers)
response = requests.get(base_url, headers=headers, params=params)
# Check for successful response
if response.status_code == 200:
# Parse the JSON response
print("worked")
data = response.json()
# Access the summary (example)
summary = data.get("snippet")
print(f"Summary: {summary}")
else:
print(f"Error: {response.status_code}")
I tried playing around with the endpoint and tried using a post request instead of a get request since it worked for Places API response = requests.post(url, json=payload, headers=headers, timeout= 10).
I’m pretty new to this so go easy on me 🙂
`
Jas Chawla is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.