Skip to content

New Official SDKs for TypeScript, Python and Go

SerpKite
Get API key

Go · go get serpkite

Go + SerpKite

The official SerpKite Go module: typed params and responses, context-aware calls, automatic retries with backoff on 429 and 5xx, and every vertical from web search to Maps and webpages.

Overview

What Go is, and where SerpKite fits

go get github.com/serpkite/serpkite-go gives you package serpkite. serpkite.NewClient() reads SERPKITE_API_KEY; options like WithAPIKey, WithBaseURL, WithHTTPClient and WithMaxRetries override the defaults.

Every call takes a context.Context, which bounds the total time across retries. API errors are *serpkite.Error with Status, Code, Message and RequestID.

Setup

Set it up in 3 steps

  1. 1

    Get an API key

    Sign up (no card), create a key in the dashboard and export it as SERPKITE_API_KEY. New accounts get 2,500 free credits, then 1,000 every month.

    export SERPKITE_API_KEY=skt_live_…
  2. 2

    Add the module

    Standard library HTTP under the hood.

    go get github.com/serpkite/serpkite-go
  3. 3

    Search

    Call c.Search(ctx, serpkite.SearchParams{Q: …}); res.Meta.CreditsUsed is what the call cost.

Code

main.go

Go
package main

import (
	"context"
	"errors"
	"fmt"
	"os"
	"time"

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

func main() {
	ctx, cancel := context.WithTimeout(context.Background(), 90*time.Second)
	defer cancel()

	c := serpkite.NewClient() // reads SERPKITE_API_KEY

	res, err := c.Search(ctx, serpkite.SearchParams{Q: "golang context timeout", Country: "us"})
	if err != nil {
		var apiErr *serpkite.Error
		if errors.As(err, &apiErr) {
			fmt.Fprintln(os.Stderr, apiErr.Status, apiErr.Code, apiErr.Message, apiErr.RequestID)
		}
		os.Exit(1)
	}
	for _, r := range res.Results {
		fmt.Println(r.Position, r.Domain, r.Title)
	}
	fmt.Printf("used %v credits\n", res.Meta.CreditsUsed)

	// Markdown for an LLM prompt
	md, err := c.SearchMarkdown(ctx, serpkite.SearchParams{Q: "golang context timeout"})
	if err == nil {
		fmt.Println(md[:200])
	}
}

FAQ

Go and SerpKite: common questions

Start building

Give your Go project Google search

2,500 free credits, then 1,000 every month. No credit card.