<?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: Petix Pleasure</title>
    <description>The latest articles on DEV Community by Petix Pleasure (@petix_pleasure_2bbaae7ce9).</description>
    <link>https://dev.to/petix_pleasure_2bbaae7ce9</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.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4256936%2F887ec5a2-0032-4b60-adc9-6466555b66d3.png</url>
      <title>DEV Community: Petix Pleasure</title>
      <link>https://dev.to/petix_pleasure_2bbaae7ce9</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/petix_pleasure_2bbaae7ce9"/>
    <language>en</language>
    <item>
      <title>Rate limits are per account, not per key</title>
      <dc:creator>Petix Pleasure</dc:creator>
      <pubDate>Tue, 24 Nov 2026 00:49:37 +0000</pubDate>
      <link>https://dev.to/petix_pleasure_2bbaae7ce9/rate-limits-are-per-account-not-per-key-518b</link>
      <guid>https://dev.to/petix_pleasure_2bbaae7ce9/rate-limits-are-per-account-not-per-key-518b</guid>
      <description>&lt;p&gt;The first thing most teams do when they hit a rate limit is create another API key. It is a reasonable guess: on plenty of services, keys are the unit of throttling, so a second key is a second budget. Here it does nothing at all. Every key, every product and every gateway on one account draws from a single requests-per-second allowance, and the API keys page says it in one line: creating more keys does not increase it, checked 2026-11-24.&lt;/p&gt;

&lt;p&gt;That sentence is worth sitting with, because it changes what the client has to be. If the limit cannot be multiplied by minting credentials, it has to be respected by something that can see the whole account's traffic. That thing is your code.&lt;/p&gt;

&lt;h2&gt;
  
  
  One account, one number
&lt;/h2&gt;

&lt;p&gt;A request is counted against the account's requests per second regardless of which key signed it. Ten workers with ten keys pointing at ten different endpoints is still one bucket. The practical consequence is not subtle: adding a worker to go faster does not add throughput, it adds contention for a number that did not move.&lt;/p&gt;

&lt;p&gt;There is a second-order effect that costs more than the slowdown. When several workers share an invisible budget, each of them individually behaves correctly while the account as a whole is over the limit. The failure lands on whichever request happened to be unlucky, so the logs show random refusals across services that each looked fine in isolation. Chasing that as a bug in one worker is a day lost.&lt;/p&gt;

&lt;h2&gt;
  
  
  The limit goes up with money, not with keys
&lt;/h2&gt;

&lt;p&gt;The allowance is raised by cumulative eligible top-ups, in USD, after the payment is confirmed as credited (checked 2026-11-24, rate limit docs):&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Cumulative eligible top-ups&lt;/th&gt;
&lt;th&gt;Account QPS becomes at least&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;under $3&lt;/td&gt;
&lt;td&gt;unchanged&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;≥ $3&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;≥ $50&lt;/td&gt;
&lt;td&gt;5&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;≥ $100&lt;/td&gt;
&lt;td&gt;10&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;≥ $200&lt;/td&gt;
&lt;td&gt;15&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;≥ $1,000&lt;/td&gt;
&lt;td&gt;50&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;≥ $10,000&lt;/td&gt;
&lt;td&gt;500&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Three details in that table do most of the work. Only credit-pack purchases and automatic top-ups count, and only once they are confirmed as credited; subscriptions, gifts and gift codes do not count, and a credit balance sitting in the account is not the same as USD paid. Non-USD payments are not counted as USD without conversion. Upgrades only raise the limit and never lower an existing higher one.&lt;/p&gt;

&lt;p&gt;The docs are also blunt about the ceiling, and the sentence is worth quoting because it is the one to bring to a meeting where someone asks for 200 requests per second on a $50 balance: this is not unlimited QPS.&lt;/p&gt;

&lt;h2&gt;
  
  
  What a refusal costs you
&lt;/h2&gt;

&lt;p&gt;A request over the limit is refused immediately with status 1029 and a &lt;code&gt;Retry-After&lt;/code&gt; header, and it is not charged (checked 2026-11-24). So the over-limit failure is the cheap kind. The response tells you how long to wait, and the attempt cost nothing.&lt;/p&gt;

&lt;p&gt;That is the opposite of the expensive failure, which is retrying a request that was never going to work. A 1000 for a bad parameter, a 1001 for a bad key, a 1020 for an empty balance: none of those get better with patience, and a retry loop that treats every non-zero status the same will spend your rate limit on them. The header &lt;code&gt;X-SerpBase-Retryable&lt;/code&gt; exists to settle that question without parsing message text, but you can also just decide it in code, which is what the queue below does.&lt;/p&gt;

&lt;h2&gt;
  
  
  Brake before you are refused
&lt;/h2&gt;

&lt;p&gt;Every response carries &lt;code&gt;X-RateLimit-Limit&lt;/code&gt;, the account's allowed rate, and &lt;code&gt;X-RateLimit-Remaining&lt;/code&gt;, what is left in the current second. Those two headers are the difference between a client that discovers the limit by being refused and one that never reaches it.&lt;/p&gt;

&lt;p&gt;The rule that matters: when &lt;code&gt;Remaining&lt;/code&gt; reads 0, the next request in that same second will be refused. Sleeping a second costs you a second. Not sleeping costs you a round trip that returns nothing, plus the retry. On a batch job the difference is measured in minutes over an hour.&lt;/p&gt;

&lt;p&gt;One thing to get right about the shape of the limit is that it is per second, not per minute. A burst of ten requests at the top of a minute looks identical to a steady stream to a per-minute budget and completely different to a per-second limiter. If your queue was designed around a per-minute allowance, it will pass a small test and fall over on a real backfill.&lt;/p&gt;

&lt;h2&gt;
  
  
  Checking the balance does not spend anything
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;GET /account/credits&lt;/code&gt; returns the balance on the account that owns the key, with &lt;code&gt;permanent_credits&lt;/code&gt; and &lt;code&gt;expiring_credits&lt;/code&gt; separated and &lt;code&gt;expiring_expires_at&lt;/code&gt; as a Unix timestamp, 0 when nothing is expiring (checked 2026-11-24, API keys page). It costs 0 credits, so polling it is free in the currency you care about.&lt;/p&gt;

&lt;p&gt;It is not free in the other currency. The endpoint is limited to 60 requests per minute per account, which is generous for a health check and far too low to call before every search. Wire it to a scheduled check, not to the request path.&lt;/p&gt;

&lt;p&gt;The key goes in the &lt;code&gt;X-API-Key&lt;/code&gt; header. That is not a style preference: the API keys page states that keys in the URL are refused, so &lt;code&gt;?api_key=&lt;/code&gt; in a query string will not authenticate, whatever a friendly error message elsewhere might suggest (checked 2026-11-24).&lt;/p&gt;

&lt;h2&gt;
  
  
  A queue that belongs on the client
&lt;/h2&gt;

&lt;p&gt;The whole design fits in one small class and one function. The class hands out slots at a fixed rate; the function sends a request, reads the status, and only resends what is worth resending.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;threading&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;time&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;

&lt;span class="no"&gt;BASE&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"https://api.serpbase.dev"&lt;/span&gt;
&lt;span class="no"&gt;KEY&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"YOUR_API_KEY"&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Pacer&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="s2"&gt;"""One limiter for the whole account, shared by every worker in the process."""&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;per_second&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;interval&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;1.0&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;per_second&lt;/span&gt;
        &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;_lock&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;threading&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Lock&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;_next&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;0.0&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;wait&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;_lock&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;now&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;monotonic&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;now&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;_next&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sleep&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;_next&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;now&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                &lt;span class="n"&gt;now&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;_next&lt;/span&gt;
            &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;_next&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;now&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;interval&lt;/span&gt;

&lt;span class="no"&gt;RETRYABLE&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="mi"&gt;1500&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1502&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1503&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1504&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;search&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pacer&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;q&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;attempts&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="n"&gt;params&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;attempt&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;attempts&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;pacer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;wait&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;r&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
            &lt;span class="no"&gt;BASE&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s2"&gt;"/google/search"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"X-API-Key"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;KEY&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"q"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;q&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="n"&gt;params&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="n"&gt;timeout&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;60&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;body&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;r&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="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;status&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;body&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"status"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;status&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;1029&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;                        &lt;span class="c1"&gt;# over the limit; not charged&lt;/span&gt;
            &lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sleep&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;float&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Retry-After"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&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="k"&gt;continue&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;status&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="no"&gt;RETRYABLE&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;                   &lt;span class="c1"&gt;# source failed; not charged&lt;/span&gt;
            &lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sleep&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;attempt&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;continue&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;status&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;                           &lt;span class="c1"&gt;# 1000/1001/1004/1020: fix it&lt;/span&gt;
            &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nc"&gt;RuntimeError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;body&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"error"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;status&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"X-RateLimit-Remaining"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"0"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sleep&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;1.0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;                       &lt;span class="c1"&gt;# the next request would be refused&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;body&lt;/span&gt;

    &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nc"&gt;RuntimeError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"gave up after %d attempts"&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="n"&gt;attempts&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Three decisions in that loop are deliberate. The pacer is a single object with a lock, so every worker that holds it contributes to one schedule instead of one schedule each. The 1029 branch reads &lt;code&gt;Retry-After&lt;/code&gt; rather than picking a backoff constant, because the server knows how long the wait is and a fixed two seconds is a guess. The fatal statuses raise immediately, so a typo in a parameter surfaces as an exception on the first call instead of three retries later.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;Remaining&lt;/code&gt; check sits after the successful return path rather than before the send. That is a small trade: it costs one extra second on the request that empties the bucket, and it saves the pacer from making a blocking decision on a header it does not need to read yet.&lt;/p&gt;

&lt;h2&gt;
  
  
  The same call in curl
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl -X POST &lt;span class="s2"&gt;"https://api.serpbase.dev/google/search"&lt;/span&gt; \
  -H &lt;span class="s2"&gt;"Content-Type: application/json"&lt;/span&gt; \
  -H &lt;span class="s2"&gt;"X-API-Key: $SERPBASE_API_KEY"&lt;/span&gt; \
  --max-time 60 \
  -d &lt;span class="s1"&gt;'{"q":"coffee shops","gl":"us","hl":"en"}'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;--max-time 60&lt;/code&gt; is there for a reason discussed below. The request is a POST with a JSON body, unlike the compatibility endpoint, which takes GET with query parameters.&lt;/p&gt;

&lt;h2&gt;
  
  
  Sizing the pacer to the work
&lt;/h2&gt;

&lt;p&gt;Set the pacer to the account's current limit, read from &lt;code&gt;X-RateLimit-Limit&lt;/code&gt; on the first response rather than hard-coded, because the limit moves when a top-up is confirmed and a stale constant will either waste capacity or trip the limiter.&lt;/p&gt;

&lt;p&gt;For a workload that touches more than one endpoint, remember that the credits are not uniform even though the rate limit is. A plain web search is one credit; the shopping, jobs, maps, marketplace and transcript engines cost more (checked 2026-11-24, per-endpoint pricing table). The QPS is shared across all of them, so a mixed workload is limited by the same number of requests while spending a different number of credits per request. Budget and throttle those separately.&lt;/p&gt;

&lt;p&gt;Last thing: a client timeout below 30 seconds is a self-inflicted wound. Every request ends on the server side within 30 seconds with a result or an error, and the slow ones are the ones a short timeout cuts off just before they succeed. Keep the client at 60 and put the tight budget where it belongs, in the request's own &lt;code&gt;timeout&lt;/code&gt; parameter, which the Google search endpoint accepts from 1 to 30 seconds and which returns status 1504 at once when the budget runs out, not charged.&lt;/p&gt;

&lt;p&gt;The rate limit docs, the QPS ladder and the balance endpoint are at &lt;a href="https://serpbase.dev/?utm_campaign=ops-222e35a2a81a&amp;amp;utm_medium=outreach&amp;amp;utm_source=opsbot" rel="noopener noreferrer"&gt;https://serpbase.dev/?utm_campaign=ops-222e35a2a81a&amp;amp;utm_medium=outreach&amp;amp;utm_source=opsbot&lt;/a&gt;&lt;/p&gt;

</description>
      <category>api</category>
      <category>webdev</category>
      <category>python</category>
      <category>performance</category>
    </item>
    <item>
      <title>SerpApi-compatible API: 20-line migration and three gotchas</title>
      <dc:creator>Petix Pleasure</dc:creator>
      <pubDate>Mon, 23 Nov 2026 02:16:36 +0000</pubDate>
      <link>https://dev.to/petix_pleasure_2bbaae7ce9/serpapi-compatible-api-20-line-migration-and-three-gotchas-j14</link>
      <guid>https://dev.to/petix_pleasure_2bbaae7ce9/serpapi-compatible-api-20-line-migration-and-three-gotchas-j14</guid>
      <description>&lt;p&gt;Every note about the SerpApi-compatible endpoint says the same thing: replace &lt;code&gt;https://serpapi.com/search.json&lt;/code&gt; with &lt;code&gt;https://api.serpbase.dev/google/serpapi/search.json&lt;/code&gt;, keep your parameters, keep your parser. That is true, and it is enough to get a 200 back on the first call. The engine table now covers 27 engines, which is what makes the move realistic for a workload that does more than plain web search.&lt;/p&gt;

&lt;p&gt;It is not enough for the second week. Three behaviours differ from SerpApi, and none of them raises on the happy path. One hands you a different page layout, one removes keys your code indexes into, and one reports failure with HTTP 200. All three pass a smoke test.&lt;/p&gt;

&lt;h2&gt;
  
  
  What actually stays the same
&lt;/h2&gt;

&lt;p&gt;27 engine names carry over, each running on a native endpoint and costing what that endpoint costs (checked 2026-11-23, per-endpoint credits table in the docs). The figures are not uniform: 12 of the 27 cost 1 credit and 14 cost 2. The remaining one is Google AI Mode, priced separately on its product page. A budget built on "one credit per call" is wrong for any workload that mixes them.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;engine&lt;/th&gt;
&lt;th&gt;runs on&lt;/th&gt;
&lt;th&gt;credits per request&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;google&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;/google/search&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;google_news&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;/google/news/search&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;amazon&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;/amazon/search&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Parameter names carry over as well: &lt;code&gt;q&lt;/code&gt;, &lt;code&gt;gl&lt;/code&gt;, &lt;code&gt;hl&lt;/code&gt;, &lt;code&gt;device&lt;/code&gt;, plus the per-engine ones such as &lt;code&gt;k&lt;/code&gt; and &lt;code&gt;amazon_domain&lt;/code&gt;. Requests are GET, as on SerpApi. The key goes in the &lt;code&gt;X-API-Key&lt;/code&gt; header, which keeps it out of URLs and logs.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# before&lt;/span&gt;
curl &lt;span class="s2"&gt;"https://serpapi.com/search.json?engine=google&amp;amp;q=coffee&amp;amp;gl=us&amp;amp;hl=en&amp;amp;api_key=$SERPAPI_KEY"&lt;/span&gt;

&lt;span class="c"&gt;# after: same query, same parameter names, key moved to the header&lt;/span&gt;
curl &lt;span class="s2"&gt;"https://api.serpbase.dev/google/serpapi/search.json?engine=google&amp;amp;q=coffee&amp;amp;gl=us&amp;amp;hl=en"&lt;/span&gt; \
  -H &lt;span class="s2"&gt;"X-API-Key: $SERPBASE_API_KEY"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;An engine outside that table is refused with 400 rather than mapped onto something close, which fails loudly at migration time.&lt;/p&gt;

&lt;p&gt;Pagination is the parameter to test before you move traffic. SerpApi's google engine pages with &lt;code&gt;start&lt;/code&gt;, an offset in multiples of ten (checked 2026-11-23). SerpBase's own google endpoint takes &lt;code&gt;page&lt;/code&gt;, 1-based, and the compatibility page does not say how the two map, so send one second-page request and look. Billing does carry over: each page is a separate request and a separate charge (checked 2026-11-23, billing doc).&lt;/p&gt;

&lt;p&gt;The boundary matters before you move anything. Not served: &lt;code&gt;output=html&lt;/code&gt; except on &lt;code&gt;engine=google&lt;/code&gt;; Maps place lookups, which go to &lt;code&gt;/google/maps/detail&lt;/code&gt;; Trends types other than &lt;code&gt;TIMESERIES&lt;/code&gt;; Play stores other than apps; SerpApi's account, archive and async APIs. &lt;code&gt;no_cache&lt;/code&gt;, &lt;code&gt;async&lt;/code&gt; and &lt;code&gt;json_restrictor&lt;/code&gt; are accepted and have no effect, so a request that sets &lt;code&gt;no_cache&lt;/code&gt; does not bypass a cache.&lt;/p&gt;

&lt;h2&gt;
  
  
  Gotcha 1: no device means phone results
&lt;/h2&gt;

&lt;p&gt;From the compatibility page:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;A google search that sets no device is not treated as desktop, as SerpApi does: it gets phone results, the same default as &lt;code&gt;/google/search&lt;/code&gt;, and &lt;code&gt;search_parameters&lt;/code&gt; then has no device field. Send &lt;code&gt;device=desktop&lt;/code&gt; for desktop results.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;SerpApi's google engine defaults to desktop (checked 2026-11-23), so migrated code usually never sends &lt;code&gt;device&lt;/code&gt;. Here the identical request returns the phone layout, and two things follow.&lt;/p&gt;

&lt;p&gt;The two layouts are not the same document. Some modules exist in one and not the other, so a parser written for desktop comes back with fewer sections and no error to log. &lt;code&gt;position&lt;/code&gt; is relative to the layout it was measured in. Your history is desktop, the new rows are mobile, the series bends, and the first suspicion is the API.&lt;/p&gt;

&lt;p&gt;You also cannot tell afterwards. When no device was sent, &lt;code&gt;search_parameters&lt;/code&gt; has no &lt;code&gt;device&lt;/code&gt; field at all. Code that reads &lt;code&gt;search_parameters["device"]&lt;/code&gt; fails on exactly the requests that need checking, and code that defaults a missing value to &lt;code&gt;desktop&lt;/code&gt; records the wrong answer.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;

&lt;span class="no"&gt;BASE&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"https://api.serpbase.dev"&lt;/span&gt;
&lt;span class="no"&gt;KEY&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;environ&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"SERPBASE_API_KEY"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="c1"&gt;# what you had on SerpApi: desktop, implicitly&lt;/span&gt;
&lt;span class="n"&gt;old&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="s2"&gt;"https://serpapi.com/search.json"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;params&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"engine"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"google"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"q"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"espresso machine"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"gl"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"us"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;timeout&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;60&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# the same call here returns phone results; ask for desktop&lt;/span&gt;
&lt;span class="n"&gt;new&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="no"&gt;BASE&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s2"&gt;"/google/serpapi/search.json"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"X-API-Key"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;KEY&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;params&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"engine"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"google"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"q"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"espresso machine"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"gl"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"us"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"device"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"desktop"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;timeout&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;60&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;new&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="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"search_parameters"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"device"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# 'desktop', when the field is echoed&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The default is documented for &lt;code&gt;engine=google&lt;/code&gt;. Read the parameter table of any other Google engine before assuming the same, and send &lt;code&gt;device&lt;/code&gt; explicitly wherever the layout matters.&lt;/p&gt;

&lt;h2&gt;
  
  
  Gotcha 2: missing keys are missing, not null
&lt;/h2&gt;

&lt;p&gt;Also from the compatibility page:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;A field SerpBase does not produce is left out rather than filled with a guess, so check for a key before reading it.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;SerpApi code in production usually carries one of three guards, and only one is correct:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;data["knowledge_graph"]["title"]&lt;/code&gt; raises &lt;code&gt;KeyError&lt;/code&gt; on the first query without a knowledge panel.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;if data.get("knowledge_graph") is not None:&lt;/code&gt; leaves the branch untaken, so the feature disappears and nothing is logged. This is the one that survives code review.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;data.get("knowledge_graph", {})&lt;/code&gt; is correct, and it degrades to empty rather than raising.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Nested fields behave the same way. &lt;code&gt;sitelinks&lt;/code&gt; exists only when a result has sitelinks, so &lt;code&gt;for s in hit["sitelinks"]&lt;/code&gt; raises on ordinary results and passes on the query you happened to test. The failure arrives when a new keyword class enters the queue.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;credits_charged&lt;/code&gt; is required but may be null, and null means the charge is still being settled. Code that does &lt;code&gt;if credits_charged &amp;gt; 0&lt;/code&gt; raises on that case; code that reads falsy as free counts an unsettled request as costing nothing.&lt;/p&gt;

&lt;p&gt;A dotted-path reader handles all of it without a guard per field:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;dig&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;obj&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;default&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;part&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;split&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"."&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="nb"&gt;isinstance&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;obj&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;dict&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="n"&gt;part&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;obj&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;default&lt;/span&gt;
        &lt;span class="n"&gt;obj&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;obj&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;part&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;obj&lt;/span&gt;

&lt;span class="n"&gt;panel&lt;/span&gt;     &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;dig&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"knowledge_graph.title"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;       &lt;span class="c1"&gt;# None when there is no panel&lt;/span&gt;
&lt;span class="n"&gt;sitelinks&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;dig&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;hit&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"sitelinks"&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="p"&gt;)&lt;/span&gt;                  &lt;span class="c1"&gt;# [] when the result has none&lt;/span&gt;
&lt;span class="n"&gt;outcome&lt;/span&gt;   &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;dig&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"search_metadata.status"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;      &lt;span class="c1"&gt;# "Error" means it ran and failed&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Before cutting traffic over, diff the key sets of both endpoints on twenty or thirty of your own queries. Values move between runs; key sets show which fields your parser was silently relying on.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;keys_old&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kt"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;old&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="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;keys_new&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kt"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;new&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="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"dropped:"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;sorted&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;keys_old&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;keys_new&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;h2&gt;
  
  
  Gotcha 3: two error shapes, one retry policy
&lt;/h2&gt;

&lt;p&gt;A refused request never ran: HTTP 400 for a bad parameter or an engine outside the table, 401 for the key, 429 for the rate limit, each with a body of &lt;code&gt;{"error": ...}&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;A search that ran and failed is different: HTTP 200, &lt;code&gt;search_metadata.status&lt;/code&gt; set to &lt;code&gt;"Error"&lt;/code&gt;, and no charge.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;raise_for_status()&lt;/code&gt; only catches the first shape. A 200 carrying &lt;code&gt;Error&lt;/code&gt; goes into your parser, &lt;code&gt;organic&lt;/code&gt; is missing or empty, and the pipeline records "no results": a failed call written down as a real answer. Generic retry decorators have the opposite problem: they retry 400 and 401 as though those were transient.&lt;/p&gt;

&lt;p&gt;The policy that fits both shapes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Retry 429, after waiting the number of seconds in &lt;code&gt;Retry-After&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Retry a 200 whose &lt;code&gt;search_metadata.status&lt;/code&gt; is &lt;code&gt;"Error"&lt;/code&gt;. Failed searches are not charged, so a resend costs nothing until one attempt succeeds.&lt;/li&gt;
&lt;li&gt;Do not retry 400 or 401. Fix the request.&lt;/li&gt;
&lt;li&gt;Cap attempts at three, so a retry storm cannot spend your rate limit on one query.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;One naming trap: the compatible path reports the outcome in &lt;code&gt;search_metadata.status&lt;/code&gt;, while the native endpoints put a numeric &lt;code&gt;status&lt;/code&gt; at the top where 0 means success. Code copied between the two doc sets checks the wrong one.&lt;/p&gt;

&lt;p&gt;For pacing, every response carries &lt;code&gt;X-RateLimit-Limit&lt;/code&gt; and &lt;code&gt;X-RateLimit-Remaining&lt;/code&gt;. When &lt;code&gt;Remaining&lt;/code&gt; reads 0, the next request that second will be refused, so sleep instead of finding out. The limit is per account, not per key (checked 2026-11-23, API keys doc), so a second key splits the same budget.&lt;/p&gt;

&lt;p&gt;Billing has one edge that looks like a bug: a request that reached the source and failed is not charged, while a request that succeeded with a "not found" answer is charged, because a confirmed absence is data. Both arrive as HTTP 200.&lt;/p&gt;

&lt;p&gt;Timeouts are the third place where a short setting looks harmless, and here there is measured data. SerpBase timed 970,882 successful Google searches over 2–8 November 2026, out of 1,061,676 requests (published 2026-11-09). Elapsed seconds:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;percentile&lt;/th&gt;
&lt;th&gt;page 1&lt;/th&gt;
&lt;th&gt;page 2 and later&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;p50&lt;/td&gt;
&lt;td&gt;1.9&lt;/td&gt;
&lt;td&gt;4.9&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;p90&lt;/td&gt;
&lt;td&gt;4.8&lt;/td&gt;
&lt;td&gt;21.3&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;p95&lt;/td&gt;
&lt;td&gt;7.0&lt;/td&gt;
&lt;td&gt;25.6&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The median makes a short timeout look safe; the tail sits on the later pages. A 5-second client timeout keeps 91.0% of first-page results and 50.7% of later ones; fifteen seconds keeps 98.8% and 79.0%. Nothing in the week took longer than 30 seconds, the slowest success was 29,999 ms, so a 60-second client timeout covers the server's own 30-second ceiling and waiting beyond it gains nothing. The sample counts only successes, covers one week on one provider, and excludes clients that hung up early.&lt;/p&gt;

&lt;p&gt;On the request side, the Google endpoints take &lt;code&gt;timeout&lt;/code&gt; of 1 to 30 seconds: retries start earlier to fit that budget and you get status 1504 at once, not charged. Hanging up on the client instead refunds the request but leaves you with no result and no error to act on.&lt;/p&gt;

&lt;h2&gt;
  
  
  The wrapper
&lt;/h2&gt;

&lt;p&gt;The function is twenty lines, counting from &lt;code&gt;def&lt;/code&gt; to the final &lt;code&gt;raise&lt;/code&gt;. The constant above it, &lt;code&gt;BASE&lt;/code&gt;, &lt;code&gt;KEY&lt;/code&gt;, &lt;code&gt;dig()&lt;/code&gt; and the imports come from the earlier snippets.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="no"&gt;COMPAT&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;BASE&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s2"&gt;"/google/serpapi/search.json"&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;search&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;engine&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;attempts&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="n"&gt;params&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;engine&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"google"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;params&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setdefault&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"device"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"desktop"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;          &lt;span class="c1"&gt;# gotcha 1&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;attempts&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;r&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;COMPAT&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"X-API-Key"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;KEY&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;timeout&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;60&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                         &lt;span class="n"&gt;params&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"engine"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;engine&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="n"&gt;params&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;status_code&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;429&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;                        &lt;span class="c1"&gt;# refused, not charged&lt;/span&gt;
            &lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sleep&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;float&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Retry-After"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&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="k"&gt;continue&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;status_code&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="mi"&gt;500&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;                        &lt;span class="c1"&gt;# server side, safe to retry&lt;/span&gt;
            &lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sleep&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;continue&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;status_code&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;400&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;401&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;                 &lt;span class="c1"&gt;# the request has to change&lt;/span&gt;
            &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nc"&gt;ValueError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;status_code&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;body&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;r&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="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nf"&gt;dig&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;body&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"search_metadata.status"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"Error"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;   &lt;span class="c1"&gt;# ran, failed, not charged&lt;/span&gt;
            &lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sleep&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;continue&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;body&lt;/span&gt;
    &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nc"&gt;RuntimeError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"{engine} still failing after {attempts} attempts"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The order of the checks is the point. 429 and 5xx leave before the body is parsed, 400 and 401 raise because no amount of waiting turns a bad parameter into a good one, and only a 200 goes on to &lt;code&gt;search_metadata.status&lt;/code&gt;. Pacing stays outside: this is one request, so it returns to whatever schedules your calls.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# constants from the earlier snippet: BASE, COMPAT, KEY, dig()&lt;/span&gt;
&lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;search&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"google"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;q&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"espresso machine"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;gl&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"us"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;hl&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"en"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;hit&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"organic"&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="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;hit&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"position"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;hit&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"link"&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;This does not make the two services identical. It puts the three differences in one place: &lt;code&gt;device&lt;/code&gt; is pinned where the layout matters, every read goes through &lt;code&gt;dig&lt;/code&gt;, and only the retryable shape is resent.&lt;/p&gt;

&lt;p&gt;The compatible path also serves no more than before: a Maps place lookup still calls &lt;code&gt;/google/maps/detail&lt;/code&gt;, Trends answers only &lt;code&gt;TIMESERIES&lt;/code&gt;, and &lt;code&gt;output=html&lt;/code&gt; works only on &lt;code&gt;engine=google&lt;/code&gt;. Those are route decisions, not parameters, so a wrapper cannot smooth them over.&lt;/p&gt;

&lt;p&gt;The same key reaches 44 callable endpoints across six categories, with 49 entries in the catalog and five paused and uncallable today. A new account starts with 500 free credits and no card, which is 500 google searches at 1 credit each (checked 2026-11-23).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://serpbase.dev/?utm_campaign=ops-222e35a2a81a&amp;amp;utm_medium=outreach&amp;amp;utm_source=opsbot" rel="noopener noreferrer"&gt;https://serpbase.dev/?utm_campaign=ops-222e35a2a81a&amp;amp;utm_medium=outreach&amp;amp;utm_source=opsbot&lt;/a&gt;&lt;/p&gt;

</description>
      <category>api</category>
      <category>python</category>
    </item>
    <item>
      <title>The cheapest Google SERP API is a budget question, not a headline price</title>
      <dc:creator>Petix Pleasure</dc:creator>
      <pubDate>Sun, 22 Nov 2026 03:11:07 +0000</pubDate>
      <link>https://dev.to/petix_pleasure_2bbaae7ce9/the-cheapest-google-serp-api-is-a-budget-question-not-a-headline-price-3ioi</link>
      <guid>https://dev.to/petix_pleasure_2bbaae7ce9/the-cheapest-google-serp-api-is-a-budget-question-not-a-headline-price-3ioi</guid>
      <description>&lt;p&gt;Every SERP API advertises a per-1,000-searches rate. That number tells you very little on its own. What you actually pay depends on four things the headline rate hides: the smallest purchase you are allowed to make, whether credits expire, whether failed requests are billed, and the rate limit attached to each tier.&lt;/p&gt;

&lt;p&gt;All SerpBase figures below were read from &lt;a href="https://serpbase.dev/pricing" rel="noopener noreferrer"&gt;serpbase.dev/pricing&lt;/a&gt; and the endpoint reference on 2026-11-22. Competitor figures were read the same day from &lt;a href="https://serper.dev/" rel="noopener noreferrer"&gt;serper.dev&lt;/a&gt; and &lt;a href="https://serpapi.com/pricing" rel="noopener noreferrer"&gt;serpapi.com/pricing&lt;/a&gt;. These pages change; re-check before you commit budget.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Minimum purchase decides whether the rate is reachable
&lt;/h2&gt;

&lt;p&gt;A $0.25 per 1,000 searches rate is meaningless if the smallest thing you can buy costs $100.&lt;/p&gt;

&lt;p&gt;If you are prototyping, you want to spend $10 and see real results. If the cheapest entry point is $50, you have committed five times what you planned before you know whether the output is usable.&lt;/p&gt;

&lt;p&gt;The smallest purchase at each of the three providers, as listed on 2026-11-22:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Provider&lt;/th&gt;
&lt;th&gt;Smallest purchase&lt;/th&gt;
&lt;th&gt;Free allowance&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;SerpBase&lt;/td&gt;
&lt;td&gt;$10&lt;/td&gt;
&lt;td&gt;500 credits, no card&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Serper&lt;/td&gt;
&lt;td&gt;$50&lt;/td&gt;
&lt;td&gt;2,500 queries&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;SerpApi&lt;/td&gt;
&lt;td&gt;$25/month&lt;/td&gt;
&lt;td&gt;250 searches/month&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;That first column is the one that decides most evaluations.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Expiry changes the effective price
&lt;/h2&gt;

&lt;p&gt;Prepaid credits that expire in six months are not the same product as credits that do not expire. If you buy 125,000 credits and use 40,000 before they lapse, you paid for 125,000 and got 40,000. The real per-search cost is roughly three times the advertised one.&lt;/p&gt;

&lt;p&gt;Serper states its credits are valid for 6 months. SerpApi sells monthly plans where searches reset each billing month. SerpBase states prepaid packs carry no calendar expiry, while its subscription plans are used within the month.&lt;/p&gt;

&lt;p&gt;That distinction is worth reading carefully rather than assuming one policy applies to the other.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Failed requests: the hidden multiplier
&lt;/h2&gt;

&lt;p&gt;Scraping Google fails sometimes. If a failed request consumes a credit, your effective cost scales with your failure rate, and a bad week costs more than a good one for the same amount of useful output.&lt;/p&gt;

&lt;p&gt;SerpBase's published rule is narrower than "failures are free", and it is worth quoting precisely: failures the platform can prove were never executed are refunded automatically. A timeout is treated differently, because the request may have completed with the result lost on the way back, so it is not refunded automatically. If you were charged and got no result, you open a ticket with the &lt;code&gt;request_id&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Practical consequence for a budget: distinguish your error types. A malformed-request or no-channel error is not a cost. A timeout is a cost until someone looks at it.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Rate limits are tiered, and they are a real constraint
&lt;/h2&gt;

&lt;p&gt;A low per-search price on a 2 QPS tier is not usable for a batch job that needs to finish tonight.&lt;/p&gt;

&lt;p&gt;SerpBase publishes the mechanism rather than just a table: cumulative confirmed top-ups raise your account QPS to at least $3 → 2 QPS, $50 → 5, $100 → 10, $200 → 15, $1,000 → 50, $10,000 → 500. The limit is per account, shared across all keys, and top-ups only raise it, never lower it.&lt;/p&gt;

&lt;p&gt;Serper's tiers advertise 50, 100, 200 and 300 queries per second on its $50, $375, $1,250 and $3,750 plans. SerpApi's plans state throughput in requests per hour: 200 on Starter ($25/month), 1,000 on Developer ($75), 3,000 on Production ($150), 6,000 on Big Data ($275).&lt;/p&gt;

&lt;p&gt;If you are comparing, convert everything to the same unit before you compare.&lt;/p&gt;

&lt;h2&gt;
  
  
  The SerpBase ladder, as of 2026-11-22
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Pack&lt;/th&gt;
&lt;th&gt;Price&lt;/th&gt;
&lt;th&gt;Credits&lt;/th&gt;
&lt;th&gt;Per 1k&lt;/th&gt;
&lt;th&gt;QPS&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Starter&lt;/td&gt;
&lt;td&gt;$10 one-time&lt;/td&gt;
&lt;td&gt;20,000&lt;/td&gt;
&lt;td&gt;$0.50&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Growth&lt;/td&gt;
&lt;td&gt;$50 one-time&lt;/td&gt;
&lt;td&gt;125,000&lt;/td&gt;
&lt;td&gt;$0.40&lt;/td&gt;
&lt;td&gt;5&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Pro&lt;/td&gt;
&lt;td&gt;$200 one-time&lt;/td&gt;
&lt;td&gt;570,000&lt;/td&gt;
&lt;td&gt;$0.35&lt;/td&gt;
&lt;td&gt;15&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Business&lt;/td&gt;
&lt;td&gt;$500 one-time&lt;/td&gt;
&lt;td&gt;1,500,000&lt;/td&gt;
&lt;td&gt;$0.33&lt;/td&gt;
&lt;td&gt;15&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Enterprise&lt;/td&gt;
&lt;td&gt;$1,000 one-time&lt;/td&gt;
&lt;td&gt;3,300,000&lt;/td&gt;
&lt;td&gt;$0.30&lt;/td&gt;
&lt;td&gt;50&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Starter Boost&lt;/td&gt;
&lt;td&gt;$3/month&lt;/td&gt;
&lt;td&gt;10,000&lt;/td&gt;
&lt;td&gt;$0.30&lt;/td&gt;
&lt;td&gt;no QPS upgrade&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Pro Monthly&lt;/td&gt;
&lt;td&gt;$100/month&lt;/td&gt;
&lt;td&gt;400,000&lt;/td&gt;
&lt;td&gt;$0.25&lt;/td&gt;
&lt;td&gt;10&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;One balance covers every endpoint, and the credit cost per request is fixed per endpoint, not per result. I checked the endpoint reference one by one on 2026-11-22 rather than trusting a range:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Endpoint&lt;/th&gt;
&lt;th&gt;Credits per request&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Google Web Search&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Google Images / News / Videos Search&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Google Search Autocomplete&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;DuckDuckGo Search&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Google AI Mode&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Google Trends&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Google Maps Search&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Reddit Post &amp;amp; Comments&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Reddit Search&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;So a credit is not always one search. Google Web Search is 1 credit; a Trends or Maps search is 2, which doubles its effective per-click price. Budget on the endpoint mix you will actually run, not on the headline search rate.&lt;/p&gt;

&lt;h2&gt;
  
  
  What you pay at four budgets
&lt;/h2&gt;

&lt;p&gt;Basis for this table: the lowest per-1,000 rate you can reach by spending that amount, using each provider's published prices on 2026-11-22. For SerpApi the figure is derived from its monthly plan tiers, since it does not sell a one-time pack.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;You spend&lt;/th&gt;
&lt;th&gt;SerpBase per 1k&lt;/th&gt;
&lt;th&gt;Serper per 1k&lt;/th&gt;
&lt;th&gt;SerpApi per 1k&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;$50&lt;/td&gt;
&lt;td&gt;$0.40&lt;/td&gt;
&lt;td&gt;$1.00&lt;/td&gt;
&lt;td&gt;$25.00&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;$375&lt;/td&gt;
&lt;td&gt;$0.35&lt;/td&gt;
&lt;td&gt;$0.75&lt;/td&gt;
&lt;td&gt;$9.17&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;$1,250&lt;/td&gt;
&lt;td&gt;$0.30&lt;/td&gt;
&lt;td&gt;$0.50&lt;/td&gt;
&lt;td&gt;$9.17&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;$3,750&lt;/td&gt;
&lt;td&gt;$0.30&lt;/td&gt;
&lt;td&gt;$0.30&lt;/td&gt;
&lt;td&gt;$9.17&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Read the shape rather than the individual cells. Serper's rate falls with volume across the whole range. SerpApi's lowest published tier tops out around $9.17 per 1,000 on its $275/month plan, so its column flattens. SerpBase drops fast at the bottom of the range and converges with Serper at the top.&lt;/p&gt;

&lt;p&gt;The gap that matters most for a new project is the first row: at $50 of budget you are comparing $0.40, $1.00 and $25.00 for the same nominal unit.&lt;/p&gt;

&lt;h2&gt;
  
  
  Compute your own break-even before you switch
&lt;/h2&gt;

&lt;p&gt;Do this with your real numbers, not the table:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;monthly_cost&lt;/span&gt;    &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;searches_per_month&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;rate_per_1k&lt;/span&gt;
&lt;span class="n"&gt;effective_rate&lt;/span&gt;  &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;rate_per_1k&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;failure_rate&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;     &lt;span class="c1"&gt;# only if failures are billed&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If your failure rate is 4% and failures are billed, a $0.40 rate behaves like $0.4167. If proven failures are refunded, the rate stays $0.40 and they only cost you time. Run both numbers against your actual failure rate.&lt;/p&gt;

&lt;p&gt;Multiply by the credit cost too, if the provider charges per endpoint. Two credits per request on a 1-credit headline rate is a 2x you will not see in the marketing table.&lt;/p&gt;

&lt;h2&gt;
  
  
  Migrating off SerpApi
&lt;/h2&gt;

&lt;p&gt;SerpBase publishes a SerpApi-compatible endpoint, so code written for SerpApi can run against it by changing the base URL and the key. The path is &lt;code&gt;https://api.serpbase.dev/google/serpapi/search.json&lt;/code&gt;, requests stay GET, and the key can go in the &lt;code&gt;api_key&lt;/code&gt; parameter or in the &lt;code&gt;X-API-Key&lt;/code&gt; header (the header keeps it out of URLs and logs).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;

&lt;span class="no"&gt;BASE&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"https://api.serpbase.dev/google/serpapi/search.json"&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;google_search&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;q&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;gl&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"us"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;hl&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"en"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;device&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"desktop"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;r&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="no"&gt;BASE&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"X-API-Key"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;environ&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"SERPBASE_API_KEY"&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="n"&gt;params&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"engine"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"google"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"q"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;q&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"gl"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;gl&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"hl"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;hl&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"device"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;device&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;timeout&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;raise_for_status&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;r&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="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"status"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nc"&gt;RuntimeError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"status={data.get('status')} request_id={data.get('request_id')}"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;

&lt;span class="n"&gt;res&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;google_search&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"cheapest google serp api"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;item&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"organic"&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="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"title"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"link"&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;Three things the documentation states that will bite you if you skip them:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;A field SerpBase does not produce is left out rather than filled with a guess. Check that a key exists before reading it.&lt;/li&gt;
&lt;li&gt;A Google search that sets no device returns phone results by default. Send &lt;code&gt;device=desktop&lt;/code&gt; if you want desktop layout.&lt;/li&gt;
&lt;li&gt;Not served through this compatibility path: &lt;code&gt;output=html&lt;/code&gt; (except for the plain Google engine), Maps place lookups (use &lt;code&gt;/google/maps/detail&lt;/code&gt; instead), Trends data types other than TIMESERIES, and SerpApi's account, archive and async APIs.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Make one paid call first and diff the JSON against what your parser expects. Compatible is not identical, and the schema is where migration bugs live.&lt;/p&gt;

&lt;h2&gt;
  
  
  Before you buy anything
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Read the rate limit on the tier you can afford, not the top tier, and convert it to the same unit your workload uses.&lt;/li&gt;
&lt;li&gt;Find the smallest purchase allowed. If it is more than you want to risk, that is your answer.&lt;/li&gt;
&lt;li&gt;Check expiry on prepaid credits, and reset behaviour on monthly plans.&lt;/li&gt;
&lt;li&gt;Ask, in writing, what happens to a failed request, and treat "timeout" and "never executed" as different answers.&lt;/li&gt;
&lt;li&gt;Read the credit cost of each endpoint you will call, then make one real call and diff the JSON against your parser.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Pricing pages change. The SerpBase numbers above are from 2026-11-22 and the competitor numbers from the same day, each with the source page linked above.&lt;/p&gt;

&lt;p&gt;If you want to test the response shape against your own code, SerpBase's free allowance is 500 credits with no card: &lt;a href="https://serpbase.dev/?utm_campaign=ops-222e35a2a81a&amp;amp;utm_medium=outreach&amp;amp;utm_source=opsbot" rel="noopener noreferrer"&gt;start here&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>api</category>
      <category>webdev</category>
      <category>pricing</category>
      <category>google</category>
    </item>
  </channel>
</rss>
