Python SDK
serpcheap आधिकारिक Python क्लाइंट है — Python 3.8+, केवल मानक लाइब्रेरी।
इंस्टॉल करें
Section titled “इंस्टॉल करें”pip install serpcheapक्विकस्टार्ट
Section titled “क्विकस्टार्ट”from serpcheap import SerpCheap
client = SerpCheap("YOUR_API_KEY")res = client.search(q="best running shoes", gl="us")print(res.organic[0].title)पैरामीटर
Section titled “पैरामीटर”res = client.search( q="best running shoes", # required gl="us", # country (default "us") hl="en", # UI language (optional) tbs="qdr:d", # time filter: qdr:h / qdr:d / qdr:w page=1, # 1-indexed (default 1))रिस्पॉन्स फ़ील्ड: res.search, res.page, res.organic, res.ads, res.knowledge_graph,
res.people_also_ask, res.related_searches, res.stats (balance, cost, cached)।
विकल्प और पेजिनेशन
Section titled “विकल्प और पेजिनेशन”client = SerpCheap("YOUR_API_KEY", timeout_ms=15000, max_retries=2)
for page in client.search_pages(q="coffee makers", from_=1, to=5): for result in page.organic: print(result.position, result.title)त्रुटि प्रबंधन
Section titled “त्रुटि प्रबंधन”from serpcheap import SerpCheapError
try: res = client.search(q="query")except SerpCheapError as e: print(e.code, e.status, e.retry_after_ms, e.retryable)