Avançar para o conteúdo principal

How to Use the SerpApi API with Go: Complete Tutorial for Beginners# How to Use the SerpApi API with

How to Search Google Jobs in Real-Time with Go and SerpApi

  •Suggested slug: `go-serpapi-google-jobs-tutorial` •Full Post:* > Searching for jobs manually on Google Jobs is slow. What if you could monitor "Golang Developer" jobs in Luanda, Lisbon, and remote with just a few lines of Go? > > I'm °Pires  Aurélio , a Go Developer Advocate focused on the Lusophone community. I work 100% with written, async communication, which is why my focus is on crystal-clear documentation. > > •LinkedIn: https://www.linkedin.com/in/pires-aurélio-511330385 > •Full code: https://github.com/Aureliopires186/go-serpapi-examples > > •Why SerpApi instead of direct scraping? > > •If you try to do `http.Get` on Google, you will get a CAPTCHA in 2 minutes. SerpApi solves that and returns clean JSON, with official Go support. > > • Practical Tutorial > > In my repository, I created the `01-google-jobs` example that is already production-ready. > > •1. Set your API Key: > ```bash > export SERPAPI_KEY=your...

How to Use the SerpApi API with Go: Complete Tutorial for Beginners

How to Use the SerpApi API with Go: Complete Tutorial for Beginners# How to Use the SerpApi API with Go: Complete Tutorial for Beginners


Hey devs! Today I'm going to show you how to integrate SerpApi with Go in less than 10 minutes.

If you want to extract data from Google without the headache, this tutorial is for you.


## What is SerpApi?


SerpApi is an API that extracts data from Google, Bing, Amazon, and other search engines.

It handles CAPTCHAs and layout changes for you. Clients include Nvidia, Shopify, and Adobe.


## Step 1: Get Your API Key


1. Go to: serpapi.com

2. Create a free account. You get 100 searches/month.


## Step 2: Create the Go Project


Create 2 files:


### 1. `go.mod`

go

module github.com/youruser/serpapi-go-search


go 1.21



### 2. `main.go`

go

package main


import (

 "encoding/json"

 "fmt"

 "io"

 "log"

 "net/http"

 "net/url"

 "os"

)


type SearchResult struct {

 OrganicResults []OrganicResult json:"organic_results"

}


type OrganicResult struct {

 Title string json:"title"

 Link string json:"link"

 Snippet string json:"snippet"

}


func main() {

 apiKey := os.Getenv("SERPAPI_KEY")

 if apiKey == "" {

  log.Fatal("Error: Set SERPAPI_KEY. Ex: export SERPAPI_KEY=your_key")

 }

 query := "Go developer jobs Brazil"

 fmt.Printf("Searching for: %s\n", query)

 results, err := searchGoogle(query, apiKey)

 if err!= nil {

  log.Fatal(err)

 }


 for i, result := range results.OrganicResults {

  if i >= 3 { break }

  fmt.Printf("%d. %s\n", i+1, result.Title)

  fmt.Printf(" %s\n", result.Link)

  fmt.Printf(" %s\n", result.Snippet)

 }

}


func searchGoogle(query string, apiKey string) (*SearchResult, error) {

 params := url.Values{}

 params.Add("engine", "google")

 params.Add("q", query)

 params.Add("api_key", apiKey)

 params.Add("hl", "en") // English results

 resp, err := http.Get("https://serpapi.com/search?" + params.Encode())

 if err!= nil {

  return nil, err

 }

 defer resp.Body.Close()


 body, _ := io.ReadAll(resp.Body)

 var result SearchResult

 json.Unmarshal(body, &result)

 return &result, nil

}



## Step 3: Run the Project


In your terminal:

bash

export SERPAPI_KEY=your_api_key_here

go run main.go



## Full Code on GitHub


I left the complete project here: [github.com/Aureliopires186/SerpApi-Go-Search](https://github.com/Aureliopires186/SerpApi-Go-Search)


## Conclusion


With 30 lines of Go you can already extract Google data professionally.

SerpApi is perfect for developers who want to focus on the product instead of solving CAPTCHAs.


Got any questions? Hit me up on Telegram: [@PiresAurelio](https://t.me/PiresAurelio)


What tutorial do you want next? Comment below 👇


#go #golang #serpapi #api #programming #tutorial


https://blogspotangola.blogspot.com/2026/08/how-to-use-serpapi-api-with-go-complete.html






Comentários

Pires Aurélio