# Official SDKs

> Official SerpKite SDKs for TypeScript, Python (sync and async) and Go, plus native LangChain and CrewAI packages. Install, quickstart, options, errors and batches for each.

SerpKite ships official, typed clients for the three languages most agents are written in, and native packages for the two most-used agent frameworks. They are generated from the [OpenAPI spec](https://serpkite.com/docs/openapi), so they track the v1 API exactly, and each one is open source in its own repository under [github.com/serpkite](https://github.com/serpkite).

| Package | Install | Source |
| --- | --- | --- |
| TypeScript / JavaScript | `npm install serpkite` | [serpkite/serpkite-js](https://github.com/serpkite/serpkite-js) |
| Python (sync + async) | `pip install serpkite` | [serpkite/serpkite-python](https://github.com/serpkite/serpkite-python) |
| Go | `go get github.com/serpkite/serpkite-go` | [serpkite/serpkite-go](https://github.com/serpkite/serpkite-go) |
| LangChain | `pip install langchain-serpkite` | [serpkite/langchain-serpkite](https://github.com/serpkite/langchain-serpkite) |
| CrewAI | `pip install "serpkite[crewai]"` | [serpkite/serpkite-python](https://github.com/serpkite/serpkite-python) (the `serpkite.crewai` module) |

Every SDK reads the key from the `SERPKITE_API_KEY` environment variable by default, sends it as `Authorization: Bearer`, retries `429` and `5xx` responses with backoff, and returns the same `results` / `meta` envelope the HTTP API does.

```bash
export SERPKITE_API_KEY="skt_live_..."
```

## TypeScript

Zero dependencies. Works on Node.js 18+, Bun, Deno and edge runtimes (Cloudflare Workers, Vercel Edge).

```bash
npm install serpkite
```

```ts
import { SerpKite } from "serpkite";

const sk = new SerpKite(); // reads SERPKITE_API_KEY
const res = await sk.search({ q: "best espresso machine", country: "us" });
console.log(res.results[0].title, res.meta.credits_used);

// Markdown for an LLM context window: returns a string
const md = await sk.search({ q: "best espresso machine", format: "markdown" });
```

Options: `new SerpKite({ apiKey, baseUrl, timeoutMs, maxRetries })`.

Every endpoint has a method: `sk.search`, `sk.images`, `sk.videos`, `sk.news`, `sk.maps`, `sk.places`, `sk.reviews`, `sk.shopping`, `sk.scholar`, `sk.patents`, `sk.autocomplete`, `sk.lens`, `sk.webpage`, `sk.rank` and `sk.account`. Parameters use the API's snake_case names (`country`, `language`, `include_content`, `place_id`…).

Batches and errors:

```ts
import { SerpKite, SerpKiteError } from "serpkite";

const sk = new SerpKite();
const { batches } = await sk.batches.create({
  endpoint: "search",
  requests: [{ q: "espresso grinder" }, { q: "burr grinder" }],
});
const done = await sk.batches.wait(batches[0].id); // polls until done or failed

try {
  await sk.search({ q: "" });
} catch (err) {
  if (err instanceof SerpKiteError) console.error(err.status, err.code, err.message, err.requestId);
}
```

The API sends `Access-Control-Allow-Origin: *`, so the SDK also works in a browser. Don't ship a production key to browsers; proxy through your backend or use a key with a low monthly limit.

## Python

Built on `httpx` and pydantic v2, fully typed, Python 3.9+. `SerpKite` is synchronous; `AsyncSerpKite` has the same methods for asyncio.

```bash
pip install serpkite
```

```python
from serpkite import SerpKite

sk = SerpKite()  # reads SERPKITE_API_KEY
res = sk.search("best espresso machine", country="us")
print(res.results[0].title, res.meta.credits_used)

md = sk.search("best espresso machine", format="markdown")  # str
```

Options: `SerpKite(api_key=..., base_url=..., timeout=..., max_retries=...)`.

Methods: `sk.search`, `sk.images`, `sk.videos`, `sk.news`, `sk.maps`, `sk.places`, `sk.reviews(place_id=...)`, `sk.shopping`, `sk.scholar`, `sk.patents`, `sk.autocomplete`, `sk.lens(url)`, `sk.webpage(url)`, `sk.rank(q, domain)` and `sk.account()`.

Async, running several queries concurrently:

```python
import asyncio
from serpkite import AsyncSerpKite

async def main() -> None:
    sk = AsyncSerpKite()
    queries = ["vector database", "rag evaluation", "mcp server"]
    pages = await asyncio.gather(*(sk.search(q, format="compact") for q in queries))
    for q, page in zip(queries, pages):
        print(q, page.results[0].link)

asyncio.run(main())
```

Batches and errors:

```python
import serpkite
from serpkite import SerpKite

sk = SerpKite()
job = sk.batches.create(endpoint="search", requests=[{"q": "espresso grinder"}, {"q": "burr grinder"}])
done = sk.batches.wait(job.batches[0].id)

try:
    sk.search("")
except serpkite.SerpKiteError as err:
    print(err.status, err.code, err.message, err.request_id)
```

## Go

Package `serpkite`, module `github.com/serpkite/serpkite-go`.

```bash
go get github.com/serpkite/serpkite-go
```

```go
package main

import (
	"context"
	"fmt"
	"log"

	serpkite "github.com/serpkite/serpkite-go"
)

func main() {
	ctx := context.Background()
	c := serpkite.NewClient() // reads SERPKITE_API_KEY

	res, err := c.Search(ctx, serpkite.SearchParams{Q: "best espresso machine", Country: "us"})
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(res.Results[0].Title, res.Meta.CreditsUsed)

	md, err := c.SearchMarkdown(ctx, serpkite.SearchParams{Q: "best espresso machine"})
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(md)
}
```

Options: `serpkite.NewClient(serpkite.WithAPIKey(key), serpkite.WithBaseURL(url), serpkite.WithHTTPClient(hc), serpkite.WithMaxRetries(n))`.

Methods: `c.Search`, `c.Images`, `c.Videos`, `c.News`, `c.Maps`, `c.Places`, `c.Reviews`, `c.Shopping`, `c.Scholar`, `c.Patents`, `c.Autocomplete`, `c.Lens`, `c.Webpage`, `c.Rank`, `c.Account`, and `c.Batches.Create`, `c.Batches.Get`, `c.Batches.Wait`.

Errors are returned as `*serpkite.Error` with `Status`, `Code`, `Message` and `RequestID`:

```go
var apiErr *serpkite.Error
if errors.As(err, &apiErr) && apiErr.Code == "insufficient_credits" {
	// top up at https://app.serpkite.com/billing
}
```

## LangChain

`langchain-serpkite` provides tools, a retriever and a document loader for LangChain and LangGraph.

```bash
pip install langchain-serpkite
```

```python
from langchain_serpkite import (
    SerpKiteAPIWrapper,
    SerpKiteRetriever,
    SerpKiteSearch,
    SerpKiteSearchResults,
    SerpKiteWebpageLoader,
)

tool = SerpKiteSearch()              # returns Markdown, token-lean, for agents
results = SerpKiteSearchResults()    # returns a JSON list of results
retriever = SerpKiteRetriever(k=5, include_content=2)  # -> list[Document]
docs = SerpKiteWebpageLoader(["https://example.com"]).load()
```

Pass `tool` or `results` to any agent (`create_react_agent`, LangGraph tool nodes). `SerpKiteRetriever` returns the top results as `Document`s, with the page Markdown as content when `include_content` is set. More in the [LangChain integration](https://serpkite.com/integrations/langchain).

## CrewAI

The CrewAI tool ships as an extra of the Python SDK.

```bash
pip install "serpkite[crewai]"
```

```python
from crewai import Agent
from serpkite.crewai import SerpKiteSearchTool

tool = SerpKiteSearchTool()  # optional: endpoint="news", country="de", num=10
agent = Agent(
    role="Researcher",
    goal="Find current, sourced facts",
    backstory="You check the live web before answering.",
    tools=[tool],
)
```

More in the [CrewAI integration](https://serpkite.com/integrations/crewai).

## MCP

For Claude, Cursor, VS Code and other MCP clients you don't need an SDK at all: connect the remote MCP server at `https://api.serpkite.com/v1/mcp` with your key in an `Authorization: Bearer` header. See [MCP server](https://serpkite.com/docs/mcp).

## Other languages

Every language with an HTTP client can call SerpKite directly:

1. `POST https://api.serpkite.com/v1/<endpoint>` with a JSON object body and `Content-Type: application/json`.
2. Send the key as `Authorization: Bearer skt_live_…`.
3. On a non-2xx status, read `error.code` from the body and retry only `429`, `5xx` and timeouts.

To generate a typed client, feed the [OpenAPI 3.1 spec](https://serpkite.com/openapi/serp-api.yaml) to your generator of choice (openapi-generator, oapi-codegen, openapi-typescript…). See [OpenAPI spec](https://serpkite.com/docs/openapi).

Other frameworks and automation tools have their own pages: [LlamaIndex](https://serpkite.com/integrations/llamaindex), [Vercel AI SDK](https://serpkite.com/integrations/vercel-ai-sdk), [OpenAI Agents SDK](https://serpkite.com/integrations/openai-agents-sdk), [n8n](https://serpkite.com/integrations/n8n) and more under [Integrations](https://serpkite.com/integrations).