> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.auxiliar.ai/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.auxiliar.ai/_mcp/server.

# Search via SerpApi

GET https://auxiliar-api-gateway.your-subdomain.workers.dev/serpapi

Proxies to `https://serpapi.com/search`, injecting the secret `api_key` as the first query
parameter. `GET` only. Every control travels in the query string and is forwarded verbatim;
nothing is defaulted by the gateway (SerpApi itself defaults `engine` to `google`). A
client-supplied `api_key` query param is dropped.


Reference: https://docs.auxiliar.ai/api-reference/api-reference/serp-api/search

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: gateway
  version: 1.0.0
paths:
  /serpapi:
    get:
      operationId: search
      summary: Search via SerpApi
      description: >
        Proxies to `https://serpapi.com/search`, injecting the secret `api_key`
        as the first query

        parameter. `GET` only. Every control travels in the query string and is
        forwarded verbatim;

        nothing is defaulted by the gateway (SerpApi itself defaults `engine` to
        `google`). A

        client-supplied `api_key` query param is dropped.
      tags:
        - subpackage_serpApi
      parameters:
        - name: engine
          in: query
          description: >-
            Search engine to use. SerpApi defaults this to `google` when
            omitted.
          required: false
          schema:
            type: string
        - name: q
          in: query
          description: The search query.
          required: false
          schema:
            type: string
        - name: location
          in: query
          description: Geographic location to originate the search from.
          required: false
          schema:
            type: string
        - name: output
          in: query
          description: >-
            Response format — `json` (default) or `html` for the raw results
            page.
          required: false
          schema:
            $ref: '#/components/schemas/SerpapiGetParametersOutput'
        - name: Authorization
          in: header
          description: >
            A per-client bearer token issued by the gateway operator. Send it as

            `Authorization: Bearer <token>`. The token is validated against a
            hashed allowlist in

            Cloudflare KV; a missing or unknown token returns `401`. This token
            is stripped before the

            request is forwarded upstream, so it never leaves the gateway.
          required: true
          schema:
            type: string
      responses:
        '200':
          description: >
            The upstream's response, passed through unchanged (status, headers,
            and body). Shown here as

            JSON; the exact shape is defined by the upstream provider.
          content:
            application/json:
              schema:
                type: object
                additionalProperties:
                  description: Any type
        '404':
          description: >
            Unknown path, or a method the matched route does not allow (e.g. an
            unlisted `/serper/<endpoint>`).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
servers:
  - url: https://auxiliar-api-gateway.your-subdomain.workers.dev
    description: Deployed Worker
  - url: http://localhost:8787
    description: Local development (wrangler dev)
components:
  schemas:
    SerpapiGetParametersOutput:
      type: string
      enum:
        - json
        - html
      title: SerpapiGetParametersOutput
    Error:
      type: object
      properties:
        error:
          type: string
          description: Human-readable error message.
      required:
        - error
      title: Error
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >
        A per-client bearer token issued by the gateway operator. Send it as

        `Authorization: Bearer <token>`. The token is validated against a hashed
        allowlist in

        Cloudflare KV; a missing or unknown token returns `401`. This token is
        stripped before the

        request is forwarded upstream, so it never leaves the gateway.

```

## Examples



**Response**

```json
{
  "searchParameters": {
    "q": "apple inc",
    "type": "search"
  },
  "organic": [
    {
      "title": "Apple",
      "link": "https://www.apple.com/",
      "position": 1
    }
  ]
}
```

**SDK Code**

```python Serper /search (truncated)
import requests

url = "https://auxiliar-api-gateway.your-subdomain.workers.dev/serpapi"

querystring = {"engine":"google","q":"coffee","location":"Austin, Texas, United States","output":"json"}

headers = {"Authorization": "Bearer <token>"}

response = requests.get(url, headers=headers, params=querystring)

print(response.json())
```

```javascript Serper /search (truncated)
const url = 'https://auxiliar-api-gateway.your-subdomain.workers.dev/serpapi?engine=google&q=coffee&location=Austin%2C+Texas%2C+United+States&output=json';
const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Serper /search (truncated)
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "https://auxiliar-api-gateway.your-subdomain.workers.dev/serpapi?engine=google&q=coffee&location=Austin%2C+Texas%2C+United+States&output=json"

	req, _ := http.NewRequest("GET", url, nil)

	req.Header.Add("Authorization", "Bearer <token>")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Serper /search (truncated)
require 'uri'
require 'net/http'

url = URI("https://auxiliar-api-gateway.your-subdomain.workers.dev/serpapi?engine=google&q=coffee&location=Austin%2C+Texas%2C+United+States&output=json")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'

response = http.request(request)
puts response.read_body
```

```java Serper /search (truncated)
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.get("https://auxiliar-api-gateway.your-subdomain.workers.dev/serpapi?engine=google&q=coffee&location=Austin%2C+Texas%2C+United+States&output=json")
  .header("Authorization", "Bearer <token>")
  .asString();
```

```php Serper /search (truncated)
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://auxiliar-api-gateway.your-subdomain.workers.dev/serpapi?engine=google&q=coffee&location=Austin%2C+Texas%2C+United+States&output=json', [
  'headers' => [
    'Authorization' => 'Bearer <token>',
  ],
]);

echo $response->getBody();
```

```csharp Serper /search (truncated)
using RestSharp;

var client = new RestClient("https://auxiliar-api-gateway.your-subdomain.workers.dev/serpapi?engine=google&q=coffee&location=Austin%2C+Texas%2C+United+States&output=json");
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "Bearer <token>");
IRestResponse response = client.Execute(request);
```

```swift Serper /search (truncated)
import Foundation

let headers = ["Authorization": "Bearer <token>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://auxiliar-api-gateway.your-subdomain.workers.dev/serpapi?engine=google&q=coffee&location=Austin%2C+Texas%2C+United+States&output=json")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```