Update Kagi API endpoint and request method

Co-authored-by: russelg <russelg@users.noreply.github.com>
This commit is contained in:
Lukáš Kucharczyk 2026-05-22 20:07:28 +02:00 • committed by GitHub
parent 42783881e9
commit f695aba2ae
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -17,21 +17,20 @@ def search_kagi(api_key: str, query: str, count: int, filter_list: Optional[list
query (str): The query to search for
count (int): The number of results to return
"""
url = 'https://kagi.com/api/v0/search'
url = 'https://kagi.com/api/v1/search'
headers = {
'Authorization': f'Bot {api_key}',
'Authorization': f'Bearer {api_key}',
}
params = {'q': query, 'limit': count}
params = {'query': query, 'limit': count}
response = requests.get(url, headers=headers, params=params)
response = requests.post(url, headers=headers, json=params)
response.raise_for_status()
json_response = response.json()
search_results = json_response.get('data', [])
search_results = json_response.get('data', {}).get('search', [])
results = [
SearchResult(link=result['url'], title=result['title'], snippet=result.get('snippet'))
for result in search_results
if result['t'] == 0
]
print(results)