gfg-search
gfg-search is an unofficial Python client for the GeeksforGeeks search API.
It wraps the endpoint:
https://www.geeksforgeeks.org/gfg-assets/_next/data/<build-id>/search.json?gq=<query>
and automatically discovers the current <build-id> from the GeeksforGeeks homepage.
Features
- Simple one-line search function.
- Reusable client class with connection/session reuse.
- Typed result model via
dataclass. - Raw response access when needed.
Installation
From PyPI (after publishing):
pip install gfg-search
From local source:
pip install .
Quick Start
from gfg_search import search
results = search("dsa", max_results=5)
for item in results:
print(item.title)
print(item.link)
print(item.snippet)
print("-")
Client Usage
from gfg_search import GFGSearchClient
client = GFGSearchClient(timeout=12)
results = client.search("python")
first = results[0]
print(first.title)
print(first.link)
Raw Response Usage
from gfg_search import GFGSearchClient
client = GFGSearchClient()
raw_items = client.search_raw("graph")
print(type(raw_items))
print(raw_items[0].keys())
API Reference
search(query, *, max_results=None, timeout=10.0)
query(str): Search text.max_results(int | None): Limit the number of returned results.timeout(float): Timeout (seconds) for HTTP requests.
Returns list[SearchResult].
GFGSearchClient(timeout=10.0, base_url="https://www.geeksforgeeks.org", session=None)
Methods:
search(query, *, max_results=None) -> list[SearchResult]search_raw(query) -> list[dict]
SearchResult
Main fields:
titlelinksnippetdisplay_linkformatted_urlhtml_titlehtml_snippetkindpagemap
Error Handling
from gfg_search import GFGSearchClient, GFGSearchHTTPError, GFGSearchParsingError
client = GFGSearchClient()
try:
print(client.search("dynamic programming", max_results=3))
except GFGSearchHTTPError as exc:
print("Network error:", exc)
except GFGSearchParsingError as exc:
print("Response format error:", exc)
Notes
- This package is unofficial and not affiliated with GeeksforGeeks.
- Since this endpoint is internal to their web app, response shape or route behavior may change in future.
Development
Run a local editable install:
pip install -e .
Build distribution artifacts:
python -m build
License
MIT
Metadata
Release files for gfg-search 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| gfg_search-0.1.0.tar.gz | 6.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| gfg_search-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 12.4 kB
Release files / gfg_search-0.1.0.tar.gz
| Download URL | gfg_search-0.1.0.tar.gz |
|---|---|
| Size | 6.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
09c49cd1b4881e97dc64cdb310dd44fcb4ac75aef1e91528a994997d12ab61a5
|
|
BLAKE2b-256 checksum How to use checksums |
19234e73b2901c3096d68d56732fc9abc8dcbfc5d1d8c32dd69c47671ffee4e2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.4
|
Release files / gfg_search-0.1.0-py3-none-any.whl
| Download URL | gfg_search-0.1.0-py3-none-any.whl |
|---|---|
| Size | 6.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
049a9c95f8e998a7c281e9413e2012dd665d16f233c7598c4f42f1379986d5c0
|
|
BLAKE2b-256 checksum How to use checksums |
e1f35afe11d15aa87ea493edc22009443daa36867a5b30dd55995faed3876e77
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.4
|