[Proposal] Support Python `asyncio` by migrating to `httpx` from `requests`

オープン
#27 コメント 5 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
38/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
静か
技術スタック
python
領域
api

調査の方向性

Start by locating the current HTTP layer that uses requests, then read the linked HTTPX compatibility guide and review how the existing synchronous Client API is exposed. Done means preserving current synchronous usage, adding asyncio-compatible calls without breaking users, and including benchmarks to compare performance.

索引モデルが issue の本文から書いたものです。

説明

improvement

Motivation

  • We currently use the requests library for sending HTTP requests. While requests is stable and widely used, it is synchronous-only and does not support Python’s asyncio concurrency model.
  • This limits users who build async Python applications. Even if their application code uses async / await, the HTTP layer still blocks unless the underlying client library also supports async. A related request came up in our deprecated library: https://github.com/serpapi/google-search-results-python/issues/72
  • Supporting async is increasingly expected in modern Python SDKs, especially for APIs, since the async pattern works well with I/O blocked apps.
  • Most of the popular Python packages are already using httpx: eg, OpenAI and Anthropic Python SDKs, and Python MCP SDK

Plan:

  • Migrate the HTTP layer from requests to httpx.
  • Ref: Official migration guide from httpx: https://www.python-httpx.org/compatibility/.
  • The migration should require minimal changes because HTTPX is mostly compatible with the requests API style.
  • The changes will be made with full backward compatibility; there will not be any breakages for current users.
  • I will also add benchmarks to assess if there are any changes to performance as a part of this migration.
  • We will support the existing pattern:
import os
import serpapi

def send():
  client = serpapi.Client(api_key=os.getenv("SERPAPI_KEY"))
  results = client.search({
    "engine": "google",
    "q": "coffee"
  })

  print(results)

and will also add support for async calls:

import os
import serpapi

async def send():
  client = serpapi.Client(api_key=os.getenv("SERPAPI_KEY"))
  results = await client.search({
    "engine": "google",
    "q": "coffee"
  })

  print(results)

Users can choose the pattern that best fits their application.

主要言語
Python
スター
173
フォーク
24
平均マージ
1日 17時間
マージ済み PR(30日)
2

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

serpapi/serpapi-python のほかの issue

serpapi/serpapi-python の issue をすべて見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。