|
19 | 19 | </a> |
20 | 20 | </p> |
21 | 21 |
|
22 | | -<p align="center"> |
23 | | - <strong>The most reliable and high-performance SERP API for Google Search, Maps, News, Shopping, and more.</strong> |
24 | | -</p> |
25 | | - |
26 | | ---- |
| 22 | +OpenAPI-driven Python SDK for JustSerpAPI with a stable high-level `Client` as the public entrypoint. |
27 | 23 |
|
28 | | -## 🌐 Quick Links |
| 24 | +## Installation |
29 | 25 |
|
30 | | -- **Official Website**: [justserpapi.com](https://justserpapi.com) |
31 | | -- **API Documentation**: [docs.justserpapi.com](https://docs.justserpapi.com) |
32 | | -- **User Dashboard**: [dashboard.justserpapi.com](https://dashboard.justserpapi.com) |
33 | | -- **Support**: [support@justserpapi.com](mailto:support@justserpapi.com) |
| 26 | +```bash |
| 27 | +pip install justserpapi |
| 28 | +``` |
34 | 29 |
|
35 | | ---- |
| 30 | +## Quick Start |
36 | 31 |
|
37 | | -## 🚀 Overview |
| 32 | +```python |
| 33 | +from justserpapi import Client |
| 34 | + |
| 35 | +with Client(api_key="YOUR_API_KEY") as client: |
| 36 | + response = client.google.search( |
| 37 | + query="coffee shops in New York", |
| 38 | + location="New York, NY", |
| 39 | + language="en", |
| 40 | + ) |
| 41 | + print(response.organic_results) |
| 42 | +``` |
38 | 43 |
|
39 | | -JustSerpAPI provides a comprehensive suite of tools to scrape and parse search engine results in real-time. This Python SDK allows you to integrate Google Search, Maps, Images, News, Shopping, and AI-powered overviews directly into your Python applications with full type safety and high performance. |
| 44 | +## Promoted High-Level API |
40 | 45 |
|
41 | | -### Key Features |
42 | | -- **Full Google Coverage**: Search, Maps, News, Shopping, Finance, Images, and Patents. |
43 | | -- **AI-Powered**: Access Google AI Overviews and AI Search modes. |
44 | | -- **Easy Integration**: Built-in authentication, automatic retries, and clean models. |
45 | | -- **Type Safety**: Full PEP 484 type hints support for a great developer experience. |
| 46 | +The high-level surface is designed to be the default entrypoint: |
46 | 47 |
|
47 | | ---- |
| 48 | +```python |
| 49 | +from justserpapi import Client |
48 | 50 |
|
49 | | -## 🛠 Installation |
| 51 | +client = Client(api_key="YOUR_API_KEY", timeout=20.0) |
50 | 52 |
|
51 | | -Install the package via `pip`: |
| 53 | +search = client.google.search(query="best espresso beans", language="en") |
| 54 | +maps = client.google.maps.search(query="espresso bars", location="Shanghai") |
| 55 | +news = client.google.news.search(query="OpenAI", language="en") |
| 56 | +images = client.google.images.search(query="espresso machine") |
| 57 | +shopping = client.google.shopping.search(query="espresso tamper") |
| 58 | +overview = client.google.ai.overview(url="https://example.com/ai-overview") |
52 | 59 |
|
53 | | -```bash |
54 | | -pip install justserpapi |
| 60 | +client.close() |
55 | 61 | ``` |
56 | 62 |
|
57 | | ---- |
| 63 | +Promoted high-level responses are parsed into Pydantic models: |
58 | 64 |
|
59 | | -## 📖 Getting Started |
| 65 | +- `GoogleSearchResponse` |
| 66 | +- `GoogleMapsSearchResponse` |
| 67 | +- `GoogleNewsSearchResponse` |
| 68 | +- `GoogleImagesSearchResponse` |
| 69 | +- `GoogleShoppingSearchResponse` |
| 70 | +- `GoogleAIOverviewResponse` |
60 | 71 |
|
61 | | -To start using the SDK, you need an **API Key**. You can get one from the [User Dashboard](https://dashboard.justserpapi.com). |
| 72 | +## Configuration |
62 | 73 |
|
63 | | -### Simple Search Example |
| 74 | +The public client exposes the common knobs directly: |
64 | 75 |
|
65 | 76 | ```python |
66 | | -import justserpapi |
67 | | -from justserpapi.api.google_api_api import GoogleAPIApi |
68 | | -from pprint import pprint |
69 | | - |
70 | | -# Configure the SDK |
71 | | -configuration = justserpapi.Configuration( |
72 | | - host="https://api.justserpapi.com" |
| 77 | +from justserpapi import Client |
| 78 | +from urllib3.util.retry import Retry |
| 79 | + |
| 80 | +client = Client( |
| 81 | + api_key="YOUR_API_KEY", |
| 82 | + base_url="https://api.justserpapi.com", |
| 83 | + timeout=(5.0, 30.0), |
| 84 | + retries=Retry(total=5, backoff_factor=0.5), |
73 | 85 | ) |
74 | | -configuration.api_key['ApiKeyAuth'] = 'YOUR_API_KEY_HERE' |
75 | | - |
76 | | -# Initialize the API client |
77 | | -with justserpapi.ApiClient(configuration) as api_client: |
78 | | - # Create an instance of the Google API |
79 | | - api_instance = GoogleAPIApi(api_client) |
80 | | - |
81 | | - try: |
82 | | - # Search for "coffee shops in New York" |
83 | | - response = api_instance.search( |
84 | | - query="coffee shops in New York", |
85 | | - location="New York,NY", |
86 | | - language="en" |
87 | | - ) |
88 | | - pprint(response) |
89 | | - except justserpapi.ApiException as e: |
90 | | - print(f"Exception when calling API: {e}") |
| 86 | +client.close() |
91 | 87 | ``` |
92 | 88 |
|
93 | | ---- |
94 | | - |
95 | | -## 🍱 Supported APIs |
96 | | - |
97 | | -| Service | Method | Description | |
98 | | -| :--- | :--- | :--- | |
99 | | -| **Google Search** | `search()` | Core Google search results (Organic, Ads, etc.) | |
100 | | -| **Google Maps** | `maps_search()` | Local business listings and place details | |
101 | | -| **Google AI** | `ai_overview()` | Extract AI-generated summaries from Google | |
102 | | -| **Google Images** | `images_search()` | High-quality image search results | |
103 | | -| **Google News** | `news_search()` | Real-time news results | |
104 | | -| **Google Shopping**| `shopping_search()`| Comprehensive product and price data | |
| 89 | +- `api_key`: value sent in the `X-API-Key` header |
| 90 | +- `base_url`: API host, defaults to `https://api.justserpapi.com` |
| 91 | +- `timeout`: default request timeout injected into promoted high-level methods |
| 92 | +- `retries`: `urllib3` retry configuration; defaults to a conservative retry strategy for the high-level client |
105 | 93 |
|
106 | | -Check out the [Full Documentation](https://docs.justserpapi.com) for a complete list of endpoints and parameters. |
| 94 | +## OpenAPI Control Plane |
107 | 95 |
|
108 | | ---- |
| 96 | +This repository is driven by the canonical OpenAPI document plus the SDK control-plane files in `config/`, `scripts/`, and `overlays/`. |
109 | 97 |
|
110 | | -## 🛡️ Authentication |
| 98 | +- If `openapi/justserpapi.openapi.json` is committed, local generation is fully reproducible. |
| 99 | +- If it is not committed, CI can fetch and cache it by running `python scripts/sdkctl.py fetch-spec` with `JUSTSERPAPI_API_KEY` configured. |
111 | 100 |
|
112 | | -The API uses an API Key passed in the `X-API-Key` header. In the SDK, this is managed via the `Configuration` object: |
| 101 | +Typical maintenance flow: |
113 | 102 |
|
114 | | -```python |
115 | | -configuration.api_key['ApiKeyAuth'] = 'YOUR_API_KEY' |
| 103 | +```bash |
| 104 | +python scripts/sdkctl.py validate-examples |
| 105 | +python scripts/sdkctl.py validate-spec --skip-generator-validate |
| 106 | +python scripts/sdkctl.py generate --clean |
116 | 107 | ``` |
117 | 108 |
|
118 | | ---- |
119 | | - |
120 | | -## ⚖️ License |
| 109 | +## License |
121 | 110 |
|
122 | 111 | Distributed under the MIT License. See `LICENSE` for more information. |
123 | | - |
124 | | ---- |
125 | | - |
126 | | -<p align="center"> |
127 | | - Proudly maintained by the <a href="https://justserpapi.com">JustSerpAPI Team</a>. |
128 | | -</p> |
0 commit comments