[Proposal] Support Python `asyncio` by migrating to `httpx` from `requests`
オープン
まだ誰も着手していません。
評価
調査の方向性
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
asyncpattern 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
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
serpapi/serpapi-python のほかの issue
-
improvement
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
serpapi/serpapi-python#17 · コメント 2 件 · リアクション 1 件 ·