# Integrate HasData Google SERP API
## Task
Add a reusable Google search function to this project using HasData Google SERP API.
Inspect project instructions, the server-side runtime, existing HTTP client, and tests first.
Follow the project's conventions and preserve unrelated code. No new SDK is required.
Do not replace the REST integration with an MCP connection or a custom Google scraper.
## References
Read the endpoint documentation before implementing:
- Quickstart: https://docs.hasdata.com/apis/google-serp-api/quickstart.md
- Parameters: https://docs.hasdata.com/apis/google-serp-api/api-params.md
- Error handling: https://docs.hasdata.com/api-codes.md
- Documentation index: https://docs.hasdata.com/llms.txt
- Full documentation (fallback): https://docs.hasdata.com/llms-full.txt
Start with the endpoint references. Use `llms.txt` to find additional pages.
Use `llms-full.txt` only when needed; extract relevant sections instead of loading everything into context.
If a `.md` reference is unavailable, try its HTML URL without `.md`.
If it is still unavailable, ask for the missing documentation rather than guessing.
## Optional agent skill
If the official `hasdata` skill is already available, use its relevant guidance.
Otherwise, if this agent supports skills, ask before installing it in this project:
```sh
npx skills add hasdata/agent-skills --skill hasdata
```
Run from the project directory and select the coding agent in use.
The `hasdata-cli` skill is not required. If installation is declined or unsupported, continue with the docs.
Flag conflicts between skill guidance and current API docs rather than guessing.
## Implementation
- Endpoint: `GET https://api.hasdata.com/scrape/google/serp`
- Accept the required search query `q` and optional `location`, `gl`, `hl`, and `deviceType` parameters.
- Encode parameters correctly. Preserve the returned JSON, including `organicResults` and any available SERP blocks.
- Handle timeouts, documented errors, empty results, and missing optional blocks. AI Overviews and ads are not guaranteed for every query.
- Keep requests server-side. If there is no suitable server-side runtime, discuss the options before changing the architecture.
## Credentials
- Implement the integration and mocked tests without requiring a live API key.
- Read `HASDATA_API_KEY` from the project's existing environment or secret store and send it as `x-api-key`.
- If the key is missing before live verification, ask the user to configure it from https://app.hasdata.com/api-keys.
- Never ask the user to paste the key into chat. Check only that it is configured, without printing its value.
- Never put the key in browser code, logs, or version control. Add only a placeholder to the project's example configuration.
- If using a local `.env` file, make sure it is gitignored.
- Send the key only to `https://api.hasdata.com`. Never forward it to documentation, result URLs, or redirects to another origin.
## Verification
- Add mocked tests for success, empty results, missing optional blocks, and errors, plus a usage example. Run local checks.
- Only after explicit user approval and with a configured key, make one live verification request with an agreed query. Successful requests consume credits.
- Validate the HTTP status, documented API status, and response structure. An empty result set can be valid.
- Do not automatically repeat paid requests to obtain a nonempty response.
- Report changed files, setup commands, and test results. State separately whether live verification passed, failed, or was skipped.
- Ask before deploying.Google SERP API
for structured results in seconds
Get real-time Google SERP data as clean JSON. One request in, structured results out. No parsing, no maintenance, no headaches.
of requests succeed
median response
95% finish faster
per 1k SERPs at volume
Google reshuffles the page. Your code shouldn't care.
- Rotating proxies & residential IPs
- Rate limits and retries
- A headless fleet to keep warm
- A parser per SERP feature
- Fix the parsers again next week
Get started with Google SERP API
Start with just a query. Add more parameters when your use case needs them.
Google SERP API
curl -G 'https://api.hasdata.com/scrape/google/serp' \
--data-urlencode 'q=Coffee' \
--data-urlencode 'location=Austin,Texas,United States' \
--data-urlencode 'deviceType=desktop' \
--header 'x-api-key: <YOUR_API_KEY>' \
--header 'Content-Type: application/json'q * Search Querylocation Locationuule Encoded Locationdomain Domaingl Countryhl Languagelr Set Multiple Languagestbs Advanced Search Parameterssafe Adult Content Filteringfilter Results Filteringnfpr Auto-corrected Resultsstart Result Offsetnum Number of Resultstbm Search TypedeviceType Deviceludocid Google Place IDlsig Additional Google Place IDkgmid Google Knowledge Graph IDsi Google Cached Search Parameters IDGoogle SERP Light API
curl -G 'https://api.hasdata.com/scrape/google-light/serp' \
--data-urlencode 'q=Coffee' \
--data-urlencode 'location=Austin,Texas,United States' \
--header 'x-api-key: <YOUR_API_KEY>' \
--header 'Content-Type: application/json'q * Search Querylocation Locationuule Encoded Locationdomain Domaingl Countryhl Languagelr Set Multiple Languagestbs Advanced Search Parameterssafe Adult Content Filteringfilter Results Filteringstart Result Offsetnum Number of ResultsAdd Google SERP API with your AI agent
Paste a ready-to-use integration prompt into your coding agent. It includes API references, setup requirements, and testing instructions.
Build with Google SERP API
Track keyword rankings, monitor Google Ads and AI citations, and build SEO tools with structured SERP data.
Track organic keyword rankings
Monitor Google search positions by city, language, and device to build rank trackers and competitive SEO dashboards.
- running shoes
- Austin, TX
- Desktop
| Domain | Previous | Current | Change |
|---|---|---|---|
| nike.com | 4 | 1 | ↑ 3 |
| adidas.com | 2 | 2 | — |
| hoka.com | 9 | 3 | ↑ 6 |
- API data
organicResults[].positionorganicResults[].link- Your app
- Save SERP snapshots and calculate URL position changes.
Monitor citations in Google AI Overviews
Collect AI-generated answers and cited sources to measure which domains appear in Google AI Overviews for your target queries.
- Topic: cholesterol
- AI Overview
Lowering cholesterol requires a combination of heart-healthy dietary changes, regular physical activity, and targeted lifestyle habits.
- API data
aiOverview.textBlocksaiOverview.references- Your app
- Store cited domains and compare across searches.
Enrich company and contact records
Find publicly listed emails, employee profiles, and company details to enrich contact records and power lead generation workflows.
- site:hasdata.com "@hasdata.com"
- Company contact
| Field | Value |
|---|---|
| Company | HasData |
| Public email | info@hasdata.com |
| Source URL | https://hasdata.com/ |
- API data
organicResults[].titleorganicResults[].snippetorganicResults[].link- Your app
- Extract emails, match people and companies, and update your CRM.
Monitor local pack visibility
Compare business listings, positions, and ratings in Google's local pack to build local SEO dashboards for each target location.
- Coffee
- Local results
| Business | Position | Rating |
|---|---|---|
| Houndstooth Coffee | 1 | 4.5 |
| Cielito Lindo Cafe | 2 | 4.9 |
| Daydreamer Coffee | 3 | 4.6 |
- API data
localResults.places[].positionlocalResults.places[].titlelocalResults.places[].rating- Your app
- Store local results by location and compare positions over time.
Monitor competitor Google Ads
Compare paid search headlines, landing pages, and ad positions to track competitor messaging across keywords and target locations.
- Retail search ads
| Ad headline | Destination | Placement |
|---|---|---|
| Walmart® Official Site | www.walmart.com | Top · 1 |
- API data
ads[].titleads[].descriptionads[].linkads[].positionads[].blockPosition- Your app
- Save ad snapshots and compare headlines, copy, and landing pages over time.
Track prices in product results
Collect product listings, merchants, and displayed prices from Google search results to power price comparison and competitive pricing tools.
- Coffee
- Product results
- Folgers Coffee Ground Classic Roast Target $16.69
- Folgers Classic Roast Ground Coffee Sam's Club $19.67
- Maxwell House Original Roast Ground Coffee Walmart $6.97
- API data
immersiveProducts- Your app
- Match products and store price history.
Research keywords with People Also Ask
Use People Also Ask questions and related searches to find content topics and build keyword research workflows.
- Coffee
- Related questions
- What is coffee called in Colombia?
- Is it healthy to drink coffee every day?
- Is coffee good for your liver?
- API data
relatedQuestions[].questionrelatedSearches[].query- Your app
- Group questions by topic and build content briefs.
Google SERP API response examples
Explore organic results, AI answers, ads and related searches. Available fields depend on the results Google returns.
organicResults
[
{
"position": 1,
"title": "Starbucks",
"link": "https://en.wikipedia.org/wiki/Starbucks",
"displayedLink": "https://en.wikipedia.org › wiki › Starbucks",
"source": "Wikipedia",
"snippet": "Starbucks Corporation is an American multinational chain of coffeehouses and roastery reserves headquartered in Seattle, Washington. It was founded in 1971",
"snippetHighlitedWords": [
"an American multinational chain of coffeehouses and roastery reserves"
]
}
]position numberRank on the page
title stringResult title
link stringDestination URL
displayedLink stringBreadcrumb-style shown URL
source stringSite / brand name
snippet stringDescription text
snippetHighlitedWords string[]Terms Google bolded
ads
[
{
"position": 1,
"blockPosition": "top",
"title": "Walmart® Official Site",
"link": "https://www.walmart.com/",
"displayedLink": "https://www.walmart.com/",
"trackingLink": "https://www.google.com/aclk?sa=l&ai=DChcSEw...",
"description": "Groceries, essentials & more delivered in as fast as an hour. Try Express Delivery!"
}
]position numberRank within its ad block
blockPosition stringtop | bottom
title stringAd headline
link stringLanding URL
displayedLink stringShown URL
trackingLink stringGoogle click-tracking URL
description stringAd copy
aiOverview
{
"textBlocks": [
{
"type": "paragraph",
"snippet": "Lowering cholesterol requires a combination of heart-healthy dietary changes, regular physical activity, and targeted lifestyle habits."
},
{
"type": "list",
"list": [
{
"snippet": "Replace saturated fats with unsaturated fats"
}
]
}
],
"references": [
{
"index": 0,
"title": "How to Lower Cholesterol: MedlinePlus",
"link": "https://medlineplus.gov/howtolowercholesterol.html",
"source": "MedlinePlus (.gov)"
}
]
}textBlocks object[]Ordered content blocks
textBlocks[].type stringBlock kind: paragraph | list | table
textBlocks[].snippet stringBlock text
references object[]Cited sources backing the overview
references[].title stringCited source title
references[].link stringCited source URL
references[].source stringPublisher
knowledgeGraph
{
"title": "Starbucks",
"entityType": "shopping_merchant",
"kgmid": "/m/018c_r",
"founded": "March 30, 1971, Pike Place Market, Seattle, WA",
"ceo": "Brian Niccol (Sep 9, 2024-)",
"founders": "Jerry Baldwin, Zev Siegl, Gordon Bowker",
"customerService": "1 (800) 782-7282"
}title stringEntity name
entityType stringCategory (company, person, place, ...)
kgmid stringGoogle Knowledge Graph ID
founded stringFounding date / place
ceo stringChief executive
founders stringFounders (comma-separated)
customerService stringSupport phone
inlineShoppingResults
[
{
"position": 1,
"title": "CookUnity - 8 Chef Meals - Protein-Packed",
"link": "https://www.cookunity.com/lp/ref_shopping_highprotein_8mealplan",
"source": "CookUnity",
"price": "$46.76/wk",
"extractedPrice": 46.76,
"thumbnail": "https://files.hasdata.com/57b5cd4b-c21d-4a87-be43-1dbd57d44914.png"
}
]position numberRank within the shopping block
title stringProduct name
link stringProduct / merchant URL
source stringMerchant
price stringFormatted price, e.g. $49.99
extractedPrice numberNumeric price for sorting
thumbnail stringProduct image URL
localResults
{
"places": [
{
"position": 1,
"title": "Starbucks Coffee Company",
"phone": "(312) 750-1454",
"address": "Chicago, IL",
"hours": "Open · Closes 9 PM",
"description": "Dine-in·Takeout·No delivery"
}
],
"moreLocationsLink": "https://www.google.com/search?q=starbucks&sca_esv=a45e3a50e3e1080f&hl=en&gl=us&udm=1&lsack=G8VgavnHKeDumLQPqJmtyQM&sa=X&ved=2ahUKEwi5wYa9seaVAxVgN4YAHahMKzkQjGp6BAhBEAE"
}places object[]Local pack entries
places[].title stringBusiness name
places[].phone stringPhone number
places[].address stringStreet address
places[].hours stringOpening hours (human-readable)
places[].description stringCategory / blurb
moreLocationsLink stringLink to full map results
answerBox
{
"type": "organicResult",
"title": "Understanding Core Web Vitals and Google search results",
"link": "https://developers.google.com/search/docs/appearance/core-web-vitals",
"snippet": "Core Web Vitals is a set of metrics that measure real-world user experience for loading performance, interactivity, and visual stability of the page.",
"snippetHighlitedWords": [
"a set of metrics that measure real-world user experience"
],
"source": "Google for Developers"
}type stringVariant: organicResult, calculator, weather, ...
title stringHeadline
link stringSource URL
snippet stringAnswer text
snippetHighlitedWords string[]Emphasized answer span
source stringSource name
discussionsAndForums
[
{
"title": "Dedicated Server Hosting options?",
"link": "https://www.reddit.com/r/Hosting/comments/1krngda/dedicated_server_hosting_options/",
"source": "Reddit",
"date": "1 year ago",
"extensions": [
"r/Hosting",
"50+ comments"
],
"replies": [
{
"title": "Avoid cheap, mass-market dedicated hosting providers. Instead, search …",
"link": "https://www.reddit.com/r/Hosting/comments/1krngda/dedicated_server_hosting_options/nji2cwr/",
"extensions": [
"Top answer",
"2 votes",
"9 months ago"
]
}
]
}
]title stringThread title
link stringThread URL
source stringForum / site (Reddit, Stack Overflow, …)
date stringPosted date
extensions string[]Tags and the reply count, e.g. "50+ comments"
replies object[]Top replies, each with title, link and extensions
searchInformation
{
"totalResults": 3050000000,
"timeTaken": 0.3,
"queryDisplayed": "Coffee",
"organicResultsState": "Results for exact spelling"
}queryDisplayed stringQuery displayed on the results page
organicResultsState stringReported spelling or correction state
totalResults numberResult count reported by Google, not the number returned
timeTaken numberSearch time reported by Google; not API response latency
pagination
{
"current": 1,
"next": "https://www.google.com/search?q=Coffee&sca_esv=8f75b58b20ab037a&hl=en&gl=us&ei=D3Goar-REuGNnesPsfLO2Qg&start=10&sa=N&sstk=AS6-VmLY9JaWLfmDA1RXAQMi8LRQhC9Loq3b-Q1ADbd4kBE_fc9JQdzm839b2zqj1rjJ8h0cGhcCR6pmivr_yrMFUtEyAlACci1A2Q&ved=2ahUKEwj_1J65i--WAxXhRmcHHTG5M4sQ8NMDegUI6wEQFg"
}current numberCurrent results page number
next stringGoogle URL for the next results page
inlineVideos
[
{
"position": 1,
"title": "How to Make Perfect Iced Coffee at Home",
"link": "https://www.youtube.com/watch?v=Y53zd60CZvc",
"duration": "5:59",
"platform": "YouTube",
"channel": "Tasty",
"date": "2 weeks ago"
},
{
"position": 2,
"title": "How to Taste Coffee Like a Barista | 5 Things to Look For",
"link": "https://www.youtube.com/watch?v=L1ggPJtfP20",
"duration": "2:32",
"platform": "YouTube",
"channel": "methodicalcoffee",
"date": "1 week ago"
}
]position numberOrder within the video results
title stringVideo title
link stringVideo page URL
duration stringDisplayed video duration
platform stringHosting platform
channel stringPublishing channel
date stringDisplayed publication date
immersiveProducts
[
{
"position": 1,
"title": "Folgers Coffee Ground Classic Roast",
"productId": "14870010698400265781",
"price": "$16.69",
"extractedPrice": 16.69,
"source": "Target",
"rating": 4.5,
"reviews": 9900
},
{
"position": 2,
"title": "Folgers Classic Roast Ground Coffee",
"productId": "1090572138154354800",
"price": "$19.67",
"extractedPrice": 19.67,
"source": "Sam's Club",
"rating": 4.6,
"reviews": 5100
}
]title stringProduct name
productId stringGoogle product identifier
price stringDisplayed price
extractedPrice numberNumeric price for comparisons
source stringMerchant shown on the card
rating numberDisplayed product rating
reviews numberDisplayed review count
An all-in-one scraping service
Every feature you need to collect Google search results data from thousands to millions of requests.
Fits right into your stack.
Works with the tools you already use.
View Documentation ->Discover similar
scrapers and APIs
to expand your projects.
Google AI Mode API
Generative AI Answers • $0.83 / 1k Request
Bing Search API
Bing SERP Results • $0.83 / 1k Request
Teams that deleted their scraper
Now it's the part of the pipeline they don't think about
HasData delivers exactly what we need: speed and comprehensive search features. It's the fastest API we've used in this space. Plus, their customer support is fantastic.
The SERP API provides accurate, structured search engine data across multiple regions and devices, enabling us to monitor market trends and performance with ease.
We use the Google SERP API by HasData for its AI-overview feature. It delivers real-time data with consistent reliability. The JSON output includes an actual SERP screenshot, ensuring full accuracy.
We rely on HasData for search performance data and broader scraping needs. Their APIs deliver highly structured data that integrates directly into our platforms.
We are using this service for google scraping and it works well. We used to use several services, but this looks like best match efficiency/cost.
SERP API pricing
Fixed price, fixed volume, no surprises at the end of the month. Upgrade when you need more.
Free
Startup
Basic
RecommendedGrowth
Monthly SERP volume
Custom price based on required volume
Past 20M credits a month, or terms the self-serve plans do not cover. We shape the contract around your workload. Past 20M credits a month, or need terms the self-serve plans do not cover? We shape the contract, concurrency, and support around your workload.
HasData accesses publicly available data only. Google's terms may restrict automated access; you are responsible for compliance. Where data includes personal information, ensure a lawful basis under GDPR/CCPA.
Questions, answered
Per successful request. A failed request costs nothing. One request returns one full SERP, no matter how many results it contains.
Yes. The free plan renews 1,000 credits every month, which is 100 SERPs with every result type included. No credit card required. When you outgrow it, pick a plan that fits your volume.
Paid plans start at $59 per month for 20,000 SERPs and scale to 2 million SERPs a month. The unit price drops with volume, from $2.95 down to $0.83 per 1,000 SERPs.
SERP Light parses Google's lightweight layout and supports organic results, AI Overviews, answer boxes, knowledge graphs, local results, inline images, related questions, and search filters when available. Supported rich-result blocks follow the standard Google SERP API schema. Use standard SERP for additional result types such as shopping, news, and videos, or for device targeting.
Organic results, ads, AI Overviews, local pack, People Also Ask, shopping, knowledge graph, related searches and more. 15+ result types, each under its own key in the response. Every plan includes all of them.
Google's Custom Search JSON API searches a custom engine you configure, caps you at 10,000 queries per day, and doesn't return SERP features like AI Overviews or the local pack. HasData returns the live Google results page as structured JSON, with city-level geo-targeting and no daily cap.
Yes. Set location for city-level targeting, gl for the country, hl for the interface language, and deviceType for desktop, mobile or tablet. Results match what a local user sees.
Nothing on your side. We track Google's markup and keep the response schema stable. Fields keep their names and types, and existing keys don't disappear. Your integration keeps working.
No. Requests run on HasData's infrastructure, so there's nothing to provision or maintain. You're responsible for using the results in line with each target site's terms and applicable law.
Yes, you can cancel your subscription at any time from your dashboard in a few seconds. Once cancelled, there are no recurring payments.
Your first Google SERP
is minutes away
100 SERPs free · no credit card