# OpenAPI spec

> SerpKite's API is described by an OpenAPI 3.1 document: generate typed clients, import it into Postman, Insomnia or Bruno, or give it to an LLM.

The contract for `api.serpkite.com` is a single OpenAPI 3.1 file. It is the source of truth the API is built from: when an endpoint or field changes, this file changes first.

- **Download:** [https://serpkite.com/openapi/serp-api.yaml](https://serpkite.com/openapi/serp-api.yaml)
- **Format:** OpenAPI 3.1.0, YAML
- **Contract version:** 1.5.2 (the HTTP API remains `/v1`)

```bash
curl -O https://serpkite.com/openapi/serp-api.yaml
```

## What's in it

- **Servers:** `https://api.serpkite.com`.
- **Security scheme:** `bearer` (`Authorization: Bearer skt_live_…`). GET requests may also pass `?api_key=`.
- **Every endpoint:** `/v1/search`, `/v1/images`, `/v1/videos`, `/v1/news`, `/v1/maps`, `/v1/places`, `/v1/place`, `/v1/reviews`, `/v1/shopping`, `/v1/scholar`, `/v1/patents`, `/v1/autocomplete`, `/v1/webpage`, `/v1/extract`, `/v1/map`, `/v1/crawl`, `/v1/crawl/{id}`, `/v1/monitors`, `/v1/monitors/{id}`, monitor `/runs` and `/run`, `/v1/rank`, `POST /v1/batches`, `/v1/batches/{id}`, `/v1/account`, `/v1/status`, `/customsearch/v1`, plus the no-login `/playground/search` demo and the `/v1/mcp` endpoint.
- **Request schemas:** `SearchRequest` (shared by the search verticals), `PlaceRequest`, `ReviewsRequest`, `WebpageRequest`, `ExtractRequest`, `MapRequest`, `CrawlRequest`, `MonitorCreateRequest`, `MonitorUpdateRequest`, `RankRequest`, `BatchCreateRequest`.
- **Response schemas:** one per search vertical (`SearchResponse`, `NewsResponse`, `PlacesResponse` for maps, places and place…), sharing the `request` / `results` / `meta` envelope (`RequestEcho`, `Meta`), plus `WebpageResponse`, `ExtractResponse`, `MapResponse`, `TaskCreated`, `CrawlTask`, `Monitor`, `MonitorRunList`, `RankResponse`, `Batch`, `BatchCreateResponse`, `Account`, `Status`, `CSEResponse` and the `Error` shape.
- **Headers:** `X-Credits-Used`, `X-Credits-Remaining`, `X-Cost-USD`, `X-Cache`, `X-Latency-Ms` and `X-Tokens-Estimate` on every billed response.
- **Alternate content types:** `text/markdown` responses for `format: "markdown"`.

The dashboard backend (`app-api.serpkite.com`) is an internal API for the SerpKite dashboard and is not part of the public contract.

Site APIs and monitors have their own JSON envelopes. Search `format: "markdown"` returns a text body; extract and crawl `format: "markdown"` select Markdown content inside JSON. Follow the response schema for the endpoint rather than assuming every response has `request`, `results` and `meta`.

## Generate a client

For TypeScript, Python and Go, use the [official SDKs](https://serpkite.com/docs/sdks), whose TypeScript types and Python models are generated from this spec. SDK clients and Go types are maintained by hand, with contract checks for Go. For other languages, or if you want your own types, generators produce good clients from the spec.

TypeScript types with [openapi-typescript](https://openapi-ts.dev), used with `openapi-fetch`:

```bash
npx openapi-typescript https://serpkite.com/openapi/serp-api.yaml -o src/serpkite.d.ts
```

Go with [oapi-codegen](https://github.com/oapi-codegen/oapi-codegen):

```bash
go install github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen@latest
curl -sO https://serpkite.com/openapi/serp-api.yaml
oapi-codegen -generate types,client -package serpkite serp-api.yaml > serpkite/client.gen.go
```

Python, Java, C#, Ruby, PHP and more with [OpenAPI Generator](https://openapi-generator.tech):

```bash
npx @openapitools/openapi-generator-cli generate \
  -i https://serpkite.com/openapi/serp-api.yaml \
  -g python \
  -o ./serpkite-client
```

Some generators struggle with OpenAPI 3.1 `oneOf` unions, such as the job-or-error entries of `BatchCreateResponse` or the engine-or-list `engine` parameter. If one does, keep the generated models and send requests with your own thin wrapper.

## Import into an API client

- **Postman:** **Import → Link**, paste `https://serpkite.com/openapi/serp-api.yaml`. Set the collection's auth to **Bearer Token** with your key.
- **Insomnia:** **Create → Import → From URL**, paste the same URL.
- **Bruno:** **Import Collection → OpenAPI V3 Spec**, choose the downloaded file.

Keep the key in an environment variable of the tool, not in the saved requests you share.

## Use it with an LLM

The spec is compact enough to paste into a model's context when you ask it to write integration code. For the prose docs as well, use [llms.txt](https://serpkite.com/llms.txt) (an index) or [llms-full.txt](https://serpkite.com/llms-full.txt) (every docs page as Markdown), or add `.md` to any docs URL.

## Versioning

The HTTP API uses `/v1`; the OpenAPI document currently has contract version `1.5.2`. Additive changes can update the contract version without changing the URL prefix. Parse responses tolerantly and ignore unknown fields. Breaking changes will get a new version and advance notice in the [API changelog](https://serpkite.com/docs/changelog).