<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Anupam Pathak</title>
    <description>The latest articles on DEV Community by Anupam Pathak (@anupam_pathak_7c6b063edc7).</description>
    <link>https://dev.to/anupam_pathak_7c6b063edc7</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3932619%2Fbf4c1b8f-2191-43cd-99c1-ce67bf0e5b62.png</url>
      <title>DEV Community: Anupam Pathak</title>
      <link>https://dev.to/anupam_pathak_7c6b063edc7</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/anupam_pathak_7c6b063edc7"/>
    <language>en</language>
    <item>
      <title>How to Fetch Google Search Results via API in JavaScript (and why the price gap between tools is enormous)</title>
      <dc:creator>Anupam Pathak</dc:creator>
      <pubDate>Fri, 15 May 2026 07:45:33 +0000</pubDate>
      <link>https://dev.to/anupam_pathak_7c6b063edc7/how-to-fetch-google-search-results-via-api-in-javascript-and-why-the-price-gap-between-tools-is-dh5</link>
      <guid>https://dev.to/anupam_pathak_7c6b063edc7/how-to-fetch-google-search-results-via-api-in-javascript-and-why-the-price-gap-between-tools-is-dh5</guid>
      <description>&lt;p&gt;If you've ever needed to pull real Google search results into your app — for a rank tracker, a research tool, a content analysis pipeline, or even a side project — you've probably hit the same wall: SERP APIs are expensive.&lt;/p&gt;

&lt;p&gt;This post walks through how to fetch structured Google search data via a REST API in JavaScript, shows you the full response structure, and shares some honest thoughts on the cost gap between different providers I've tested.&lt;/p&gt;

&lt;p&gt;What is a SERP API?&lt;br&gt;
A SERP API (Search Engine Results Page API) returns the structured content of a search engine results page as JSON. Instead of loading google.com in a browser, you call an endpoint with a query and get back clean data: organic results, featured snippets, People Also Ask boxes, AI Overviews, ads, related searches — all parsed.&lt;/p&gt;

&lt;p&gt;The use cases are wide: rank tracking, keyword research tools, content gap analysis, competitor monitoring, or feeding search context into an LLM pipeline.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1tpmruwdsgkqdb6p8jhp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1tpmruwdsgkqdb6p8jhp.png" alt=" "&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The Basic Integration&lt;br&gt;
I've been using &lt;a href="https://apiserpent.com/" rel="noopener noreferrer"&gt;Serpent API&lt;/a&gt; for this. Here's the simplest working implementation:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="s2"&gt;`javascript
// Basic SERP fetch — returns Google web results
const fetchSERP = async (query) =&amp;gt; {
  const response = await fetch(
    `&lt;/span&gt;&lt;span class="nx"&gt;https&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="c1"&gt;//apiserpent.com/api/search?q=${encodeURIComponent(query)}`,&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;X-API-Key&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;sk_live_your_key&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="c1"&gt;// Usage&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;results&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;fetchSERP&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;best javascript frameworks 2025&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;results&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;results&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;organic&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// array of organic results&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;`&lt;br&gt;
That's the entire integration. One endpoint, one header, JSON response. No SDK required.&lt;/p&gt;

&lt;p&gt;The Response Structure&lt;br&gt;
Here's what a typical response object looks like (abbreviated):&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;&lt;code&gt;json&lt;br&gt;
**json — response structure&lt;br&gt;
{&lt;br&gt;
  "success": true,&lt;br&gt;
  "query": "best javascript frameworks 2025",&lt;br&gt;
  "results": {&lt;br&gt;
    "organic": [&lt;br&gt;
      {&lt;br&gt;
        "position": 1,&lt;br&gt;
        "title": "Top JS Frameworks in 2025",&lt;br&gt;
        "url": "https://example.com/...",&lt;br&gt;
        "snippet": "React continues to dominate..."&lt;br&gt;
      }&lt;br&gt;
      // up to 100 results per query&lt;br&gt;
    ],&lt;br&gt;
    "ai_overview": { /* Google AIO block if present */ },&lt;br&gt;
    "featured_snippet": { /* snippet box if present */ },&lt;br&gt;
    "people_also_ask": [ /* PAA questions + answers */ ],&lt;br&gt;
    "related_searches": [ /* related queries */ ],&lt;br&gt;
    "ads": [ /* top and bottom ads */ ]&lt;br&gt;
  },&lt;br&gt;
  "meta": {&lt;br&gt;
    "engine": "google",&lt;br&gt;
    "total_results": 100,&lt;br&gt;
    "country": "us"&lt;br&gt;
  }&lt;br&gt;
}**&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Switching Search Engines
&lt;/h2&gt;

&lt;p&gt;The SERP API supports Google (default), Bing, Yahoo, and DuckDuckGo. You switch with a simple query parameter:&lt;/p&gt;

&lt;p&gt;`&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;javascript&lt;/span&gt;
&lt;span class="c1"&gt;// Use Bing instead of Google&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;bingResults&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;https://apiserpent.com/api/search?q=seo+tools&amp;amp;engine=bing&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;X-API-Key&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;sk_live_your_key&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// DuckDuckGo — same pattern&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;ddgResults&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;https://apiserpent.com/api/search?q=seo+tools&amp;amp;engine=duckduckgo&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;X-API-Key&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;sk_live_your_key&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;`&lt;br&gt;
All four engines return the same normalized JSON structure. No extra parsing logic.&lt;/p&gt;

&lt;p&gt;Bonus: Tracking AI Citations&lt;br&gt;
This is the feature I didn't expect to need but now use constantly. The AI Ranking endpoint queries ChatGPT, Claude, Gemini, and Perplexity on your behalf and returns whether your brand/domain is cited in their responses.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;/code&gt;`plaintext&lt;/p&gt;

&lt;p&gt;&lt;code&gt;`&lt;br&gt;
javascript — ai ranking&lt;br&gt;
// Check if your brand appears in AI responses&lt;br&gt;
const aiVisibility = await fetch(&lt;br&gt;
  'https://apiserpent.com/api/ai-rank?q=best+serp+api&amp;amp;brand=apiserpent.com',&lt;br&gt;
  { headers: { 'X-API-Key': 'sk_live_your_key' } }&lt;br&gt;
);&lt;br&gt;
`&lt;/code&gt;&lt;br&gt;
`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;// Returns: visibility_score, cited_by[], sources[]&lt;br&gt;
This is increasingly relevant as users get answers directly from AI tools rather than clicking through to websites. It's an early signal for what's being called GEO — Generative Engine Optimization.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Faydvdxoaoq3kzn0c7dxf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Faydvdxoaoq3kzn0c7dxf.png" alt=" "&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Full pricing breakdown: &lt;a href="https://apiserpent.com/pricing" rel="noopener noreferrer"&gt;apiserpent.com/pricing&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Getting Started&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Sign up at apiserpent.com (Google OAuth, 30 seconds)&lt;/li&gt;
&lt;li&gt;Get your API key from the dashboard&lt;/li&gt;
&lt;li&gt;You start with 10 free searches — no credit card&lt;/li&gt;
&lt;li&gt;Read the docs: apiserpent.com/docs&lt;/li&gt;
&lt;li&gt;The &lt;a href="https://apiserpent.com/docs" rel="noopener noreferrer"&gt;documentation&lt;/a&gt; is genuinely clean.
I had a working prototype calling real Google data in under 30 minutes.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If you're building anything that touches search data — rank trackers, SEO tools, content pipelines, LLM context — this is worth 10 minutes of your time to test.&lt;br&gt;
Happy to answer questions about integration patterns, response edge cases (PAA structure is a bit nested), or the AI ranking feature in the comments.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>api</category>
      <category>seo</category>
    </item>
  </channel>
</rss>
