镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Add async support (e.g. AsyncClient) for use in async frameworks #35

Description

@harshitayadavv

serpapi.Client is fully synchronous under the hood (uses requests), so calling it from async code, like inside a FastAPI route, blocks the event loop.

Checked and there's no async entry point right now:

import serpapi
[m for m in dir(serpapi.Client) if not m.startswith('_')]
['BASE_DOMAIN', 'DASHBOARD_URL', 'USER_AGENT', 'account', 'locations', 'request', 'search', 'search_archive']

A couple options that could fix this:

  1. Add an async def search_async(...) method that just wraps the existing search() using run_in_executor, small and low risk
  2. Add a proper AsyncClient built on httpx or aiohttp for true non-blocking requests, more work but avoids the thread pool overhead

Not sure which direction you'd rather take, happy to build either one and add tests once there's some agreement on approach.

Activity

  1. adarshdigievo commented on Jul 10, 2026

    @adarshdigievo
    Member

    @harshitayadavv Thanks for the request. We are actively discussing adding async support via #27. Please follow the original issue for further updates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions