Skip to main content

Pangolinfo SERP API SDK - AI Overview SERP and keyword trends data for e-commerce intelligence.

Project description

pangolinfo-serp

Pangolinfo SERP API SDK — AI Overview SERP and keyword trends data for e-commerce intelligence.

Built and maintained by PANGOLIN INFO TECH PTE. LTD.

Installation

pip install pangolinfo-serp

Quick start

from pangolinfo_serp import SerpClient

client = SerpClient(token="your_bearer_token")

# AI Overview for a Google search URL
result = client.ai_overview("https://www.google.com/search?q=how+java+work")
print(result["json"])

# Keyword trends comparison
trends = client.keyword_trends(["shoe", "hat"])
print(trends["json"])

Authentication

Grab a free API key from tool.pangolinfo.com, then pass it as the token argument. It is sent as a Bearer token on every request.

client = SerpClient(token="YOUR_TOKEN")

Methods

ai_overview(url, screenshot=False)

Scrapes a Google search result page and returns the AI Overview, organic results, related searches and references.

  • url (str, required) — Target Google search URL, e.g. "https://www.google.com/search?q=how+java+work".
  • screenshot (bool, optional) — Capture a screenshot of the page.

Posts to POST https://scrapeapi.pangolinfo.com/api/v2/scrape with parserName="googleSearch".

Returns the data object:

{
  "json": {
    "ai_overview": "...",
    "organic": ["..."],
    "related_searches": ["..."],
    "references": ["..."]
  },
  "screenshot": "https://...",
  "taskId": "abc123",
  "url": "https://www.google.com/search?q=..."
}

Example:

with SerpClient(token="TOKEN") as client:
    data = client.ai_overview(
        "https://www.google.com/search?q=best+running+shoes",
        screenshot=True,
    )
    ai = data["json"].get("ai_overview")
    screenshot_url = data.get("screenshot")

keyword_trends(keywords, time_range="today 12-m", region="US", language="en-US")

Returns Google Trends comparison data for one or more keywords.

  • keywords (str | list[str], required) — A single keyword or a list of keywords, e.g. "shoe" or ["shoe", "hat"].
  • time_range (str, optional) — Time range, e.g. "today 12-m" (default), "today 3-m", "today 1-m".
  • region (str, optional) — Region code, e.g. "US" (default), "GB".
  • language (str, optional) — Language, e.g. "en-US" (default).

Posts to POST https://scrapeapi.pangolinfo.com/api/v1/google/trends.

Returns the data object:

{
  "json": {
    "keywordsGeoData": {"..."},
    "keywordsRankData": {"..."},
    "timelineData": ["..."],
    "geoMapData": {"..."}
  },
  "taskId": "abc123",
  "url": "https://trends.google.com/..."
}

Example:

with SerpClient(token="TOKEN") as client:
    data = client.keyword_trends(
        ["shoe", "hat"],
        time_range="today 3-m",
        region="US",
        language="en-US",
    )
    timeline = data["json"]["timelineData"]

Configuration

SerpClient accepts optional configuration:

client = SerpClient(
    token="YOUR_TOKEN",
    base_url="https://scrapeapi.pangolinfo.com",  # default
    timeout=120,  # seconds, AI Overview can take 30s+
)

Use it as a context manager to ensure the underlying HTTP connection is closed:

with SerpClient(token="TOKEN") as client:
    ...

Errors

All errors derive from pangolinfo_serp.SerpError:

Exception When
AuthenticationError HTTP 401 / 403 — bad or missing token.
APIError API returns code != 0 or an HTTP error.
TimeoutError Request times out.
from pangolinfo_serp import SerpClient, APIError, AuthenticationError

try:
    client.ai_overview("https://www.google.com/search?q=java")
except AuthenticationError:
    print("check your token")
except APIError as exc:
    print(f"API error code={exc.code}: {exc}")

Links

License

MIT — © PANGOLIN INFO TECH PTE. LTD.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pangolinfo_serp-0.2.0.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pangolinfo_serp-0.2.0-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

Details for the file pangolinfo_serp-0.2.0.tar.gz.

File metadata

  • Download URL: pangolinfo_serp-0.2.0.tar.gz
  • Upload date:
  • Size: 5.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for pangolinfo_serp-0.2.0.tar.gz
Algorithm Hash digest
SHA256 aab805e6240155a1e0791e2178ef4db522630d14eda841c56028e6355637194a
MD5 c527491e91629d9ebfe5cd25c614e6f9
BLAKE2b-256 b12565632f9c2c1e7d0b2e02c35f43499922fd2dd8e92d3a3135469fcdba7739

See more details on using hashes here.

File details

Details for the file pangolinfo_serp-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for pangolinfo_serp-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 aedee6680e36dec530b28eb10eaadfcb0a20e0756f32057eca7abb25f733ca59
MD5 88154c6ec484f9836c7962078e9af5d5
BLAKE2b-256 23824d36c142095847693cbf8188807d20d491049d96f46caaa341a736c5f680

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page