client
Class info¶
Classes¶
| Name | Children | Inherits |
|---|---|---|
| AsyncSerpAPIClient searchly.providers.serpapi_provider.client Async client for SerpAPI. |
🛈 DocStrings¶
SerpAPI client implementing search protocols.
AsyncSerpAPIClient
¶
Bases: HttpSessionMixin, WebSearchProvider, NewsSearchProvider
Async client for SerpAPI.
Source code in src/searchly/providers/serpapi_provider/client.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 | |
__init__
¶
Initialize SerpAPI client.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
api_key
|
str | None
|
SerpAPI key. Defaults to SERPAPI_KEY env var. |
None
|
Source code in src/searchly/providers/serpapi_provider/client.py
news_search
async
¶
news_search(
query: str,
*,
max_results: int = 10,
country: CountryCode | None = None,
language: LanguageCode | None = None,
location: str | None = None,
safe: bool = True,
time_period: TimePeriod | None = None,
**kwargs: Any,
) -> NewsSearchResponse
Execute a news search query.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query
|
str
|
Search query string. |
required |
max_results
|
int
|
Maximum number of results to return. |
10
|
country
|
CountryCode | None
|
Country code for regional results (converted to lowercase). |
None
|
language
|
LanguageCode | None
|
Language code for results (converted to lowercase). |
None
|
location
|
str | None
|
Location string (e.g. "Austin, Texas"). |
None
|
safe
|
bool
|
Enable safe search. |
True
|
time_period
|
TimePeriod | None
|
Time period filter ("d"=day, "w"=week, "m"=month, "y"=year). |
None
|
**kwargs
|
Any
|
Additional SerpAPI-specific options. |
{}
|
Returns:
| Type | Description |
|---|---|
NewsSearchResponse
|
Unified news search response. |
Source code in src/searchly/providers/serpapi_provider/client.py
web_search
async
¶
web_search(
query: str,
*,
max_results: int = 10,
country: CountryCode | None = None,
language: LanguageCode | None = None,
location: str | None = None,
safe: bool = True,
**kwargs: Any,
) -> WebSearchResponse
Execute a web search query.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query
|
str
|
Search query string. |
required |
max_results
|
int
|
Maximum number of results to return. |
10
|
country
|
CountryCode | None
|
Country code for regional results (converted to lowercase). |
None
|
language
|
LanguageCode | None
|
Language code for results (converted to lowercase). |
None
|
location
|
str | None
|
Location string (e.g. "Austin, Texas"). |
None
|
safe
|
bool
|
Enable safe search. |
True
|
**kwargs
|
Any
|
Additional SerpAPI-specific options. |
{}
|
Returns:
| Type | Description |
|---|---|
WebSearchResponse
|
Unified web search response. |
Source code in src/searchly/providers/serpapi_provider/client.py
example
async
¶
Example usage of AsyncSerpAPIClient.