When calling SerpApi methods, the client distinguishes between search parameters (sent to SerpApi) and request options (sent to requests).
- Request Options:
timeout, proxies, verify, stream, and cert are passed to the requests library. - Search Parameters: All other keyword arguments are sent to SerpApi as API parameters (e.g.,
engine, q, location).
If you provide both a parameter dictionary and additional keyword arguments, the keyword arguments will update the dictionary. To prevent modifying your original dictionary, pass a copy using .copy().
# Combining parameters and options
results = client.search(
engine="google",
q="coffee",
location="Austin, Texas",
timeout=10,
)
# Updating a dictionary with keyword arguments
params = {"engine": "google", "q": "coffee"}
results = client.search(params, location="Austin, Texas", timeout=10)
# Using a copy to keep the original dictionary unchanged
params = {"engine": "google", "q": "coffee"}
results = client.search(params.copy(), location="Austin, Texas")