Metadata-Version: 2.4
Name: serpcheap-django
Version: 0.2.0
Summary: Django integration for the serp.cheap Google SERP API — app, settings, cached client, management command.
Project-URL: Homepage, https://serp.cheap
Project-URL: Documentation, https://app.serp.cheap
Project-URL: Repository, https://github.com/SerpCheap/serpcheap-django
Author: serp.cheap
License: MIT
License-File: LICENSE
Keywords: api,django,google,scraping,search,serp
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Web Environment
Classifier: Framework :: Django
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Internet :: WWW/HTTP
Requires-Python: >=3.8
Requires-Dist: django>=3.2
Requires-Dist: serpcheap>=0.2
Description-Content-Type: text/markdown

# serpcheap-django

Django integration for the [serp.cheap](https://serp.cheap) **Google Search API** — real-time Google SERP data (organic results, ads, knowledge graph, page scraping, rank tracking), wrapped as a Django app with settings, cached client, and a management command.

It's the **cheapest Google Search API** we know of — $0.0003 per cached search, $0.0006 fresh, no monthly minimum (~10× cheaper than SerpApi).

Wraps the [`serpcheap`](https://pypi.org/project/serpcheap/) Python SDK with a Django app, settings-driven config, transparent result caching via Django's cache framework, and a management command.

## Install

```bash
pip install serpcheap-django
```

Add the app and configure it in `settings.py`:

```python
INSTALLED_APPS = [
    # ...
    "serpcheap_django",
]

SERPCHEAP = {
    "API_KEY": os.environ["SERPCHEAP_API_KEY"],  # get one at https://app.serp.cheap
}
```

## Usage

```python
from serpcheap_django import serpcheap

results = serpcheap.search("best running shoes", gl="us")
page = serpcheap.scrape("https://example.com")
rank = serpcheap.rank("example.com", "best running shoes")
```

Results are cached by default (keyed by query + options) using your default Django cache, so repeat calls don't spend credits. Reach the raw, uncached SDK client when you need it:

```python
from serpcheap_django import get_client

for page in get_client().client.search_pages("best running shoes", to=3):
    ...
```

### Management command

```bash
python manage.py serpcheap_search "best running shoes" --gl us --page 1
python manage.py serpcheap_search "best running shoes" --json
```

## Configuration

All keys are optional except `API_KEY`:

```python
SERPCHEAP = {
    "API_KEY": "...",                       # required
    "BASE_URL": "https://api.serp.cheap",
    "TIMEOUT_MS": 15000,
    "MAX_RETRIES": 2,
    "CACHE": {
        "ENABLED": True,
        "ALIAS": "default",                 # any cache alias from settings.CACHES
        "TTL": 3600,
    },
}
```

Set `CACHE["ENABLED"] = False` to disable result caching entirely.

## License

MIT
