Python SDK for the OpenSERP self-hosted server and OpenSERP Cloud.
Project description
OpenSERP Python SDK
Alpha: API may change before 1.0.
Python SDK for the OpenSERP self-hosted server and OpenSERP Cloud. The same client works against both backends.
Install
pip install openserp
For DataFrame export:
pip install "openserp[pandas]"
OSS Mode
OSS mode is the default. Run the open source server locally, then point the SDK at it:
from openserp import OpenSERP
client = OpenSERP(base_url="http://localhost:7000")
resp = client.search(
engine="google",
text="openserp",
limit=10,
region="US",
)
print(resp.results[0].title, resp.results[0].url)
If you omit every option, the client uses http://localhost:7000.
Cloud Mode
Pass an API key and the client defaults to https://api.openserp.org/v1.
import os
from openserp import OpenSERP
client = OpenSERP(api_key=os.environ["OPENSERP_API_KEY"])
resp = client.search(engine="google", text="openserp")
print(resp.results[0].title)
print(client.last_response.credits)
Async
import asyncio
import os
from openserp import AsyncOpenSERP
async def main() -> None:
async with AsyncOpenSERP(api_key=os.environ["OPENSERP_API_KEY"]) as client:
resp = await client.search(engine="google", text="openserp")
print(resp.results[0].title)
asyncio.run(main())
Mega Search
from openserp import OpenSERP
client = OpenSERP()
mega = client.mega_search(
text="openserp",
engines=["google", "bing", "yandex"],
mode="balanced",
)
df = mega.to_pandas()
print(df[["rank", "title", "url", "engine"]])
Convenience helpers are also available:
client.fast_search(text="openserp", engines=["google", "bing"])
client.any_search(text="openserp", engines=["google", "bing"])
client.mega_image(text="golang logo", engines=["google", "bing"])
AI / RAG
from openserp import OpenSERP
client = OpenSERP()
resp = client.search(engine="google", text="latest postgres indexing guide", limit=5)
context = "\n\n".join(
f"{item.title}\n{item.url}\n{item.snippet}"
for item in resp.results
)
prompt = f"Use these web results as grounding:\n\n{context}\n\nSummarize the key points."
SEO Keyword Tracker
from openserp import OpenSERP
client = OpenSERP()
keywords = ["openserp", "serp api", "google search api"]
frames = []
for keyword in keywords:
resp = client.search(engine="google", text=keyword, region="US", limit=10)
frame = resp.to_pandas()
frame["keyword"] = keyword
frames.append(frame)
report = __import__("pandas").concat(frames, ignore_index=True)
report.to_csv("rank-report.csv", index=False)
Async Batch
import asyncio
from openserp import AsyncOpenSERP
async def main() -> None:
sem = asyncio.Semaphore(20)
queries = [f"keyword {i}" for i in range(500)]
async with AsyncOpenSERP() as client:
async def run(query: str):
async with sem:
return await client.search(engine="google", text=query, limit=10)
responses = await asyncio.gather(*(run(query) for query in queries))
print(len(responses))
asyncio.run(main())
Endpoint Availability
Search endpoints work in both modes. Operational OSS endpoints such as health(), stats(), parse_google(), and parse_bing() require a self-hosted server and raise OssOnlyError in Cloud mode.
Cloud account endpoints such as me(), pricing(), engines_status(), and engines_capabilities() require Cloud mode and raise CloudOnlyError in OSS mode.
Development
python -m pip install -e ".[dev,pandas]"
pytest
ruff check .
mypy src
python -m build
The project is scaffolded for uv too:
uv build
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file openserp-0.1.1.tar.gz.
File metadata
- Download URL: openserp-0.1.1.tar.gz
- Upload date:
- Size: 10.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f5b9509e0c8b291ca5f1b9c587771313d7846266ae4fc82a6caf582f6d3dd0f2
|
|
| MD5 |
506dcb150c8f8cbdf85ccfa057d545c4
|
|
| BLAKE2b-256 |
a9255320dc62c8633d907d94d1c663265aa6b659cd21ecfee7f3f71e28ae97b5
|
Provenance
The following attestation bundles were made for openserp-0.1.1.tar.gz:
Publisher:
sdk-python.yml on karust/openserp_project
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
openserp-0.1.1.tar.gz -
Subject digest:
f5b9509e0c8b291ca5f1b9c587771313d7846266ae4fc82a6caf582f6d3dd0f2 - Sigstore transparency entry: 1621185204
- Sigstore integration time:
-
Permalink:
karust/openserp_project@06ddc953f11d4b017a91e0931531f91db1fe0c7f -
Branch / Tag:
refs/tags/sdk-python-v0.1.1 - Owner: https://github.com/karust
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
sdk-python.yml@06ddc953f11d4b017a91e0931531f91db1fe0c7f -
Trigger Event:
release
-
Statement type:
File details
Details for the file openserp-0.1.1-py3-none-any.whl.
File metadata
- Download URL: openserp-0.1.1-py3-none-any.whl
- Upload date:
- Size: 10.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a769b6a1b356579bb0f151e6f770613fe05dc0bbc339b215ae5bc8cd9c1d80bd
|
|
| MD5 |
2452ac51111da8cd724047e0564fc5ba
|
|
| BLAKE2b-256 |
50421426425542960e75134ba7211d99d031147c63df5c17866fca9fcec9e34f
|
Provenance
The following attestation bundles were made for openserp-0.1.1-py3-none-any.whl:
Publisher:
sdk-python.yml on karust/openserp_project
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
openserp-0.1.1-py3-none-any.whl -
Subject digest:
a769b6a1b356579bb0f151e6f770613fe05dc0bbc339b215ae5bc8cd9c1d80bd - Sigstore transparency entry: 1621185273
- Sigstore integration time:
-
Permalink:
karust/openserp_project@06ddc953f11d4b017a91e0931531f91db1fe0c7f -
Branch / Tag:
refs/tags/sdk-python-v0.1.1 - Owner: https://github.com/karust
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
sdk-python.yml@06ddc953f11d4b017a91e0931531f91db1fe0c7f -
Trigger Event:
release
-
Statement type: