{"id":21130471,"url":"https://github.com/serpapi/google-search-results-golang","last_synced_at":"2025-07-09T01:33:28.724Z","repository":{"id":57492341,"uuid":"119324059","full_name":"serpapi/google-search-results-golang","owner":"serpapi","description":"Google Search Results GoLang API","archived":false,"fork":false,"pushed_at":"2024-03-25T11:34:16.000Z","size":65,"stargazers_count":67,"open_issues_count":0,"forks_count":19,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-04-04T14:21:48.664Z","etag":null,"topics":["golang","golang-api","serp-api"],"latest_commit_sha":null,"homepage":"https://serpapi.com","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/serpapi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-01-29T03:01:17.000Z","updated_at":"2025-04-03T15:57:38.000Z","dependencies_parsed_at":"2022-09-02T00:22:00.871Z","dependency_job_id":"fee285ec-dad7-4806-bdde-a88a6bee7944","html_url":"https://github.com/serpapi/google-search-results-golang","commit_stats":null,"previous_names":["serpapi/google_search_results_golang"],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/serpapi/google-search-results-golang","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serpapi%2Fgoogle-search-results-golang","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serpapi%2Fgoogle-search-results-golang/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serpapi%2Fgoogle-search-results-golang/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serpapi%2Fgoogle-search-results-golang/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/serpapi","download_url":"https://codeload.github.com/serpapi/google-search-results-golang/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serpapi%2Fgoogle-search-results-golang/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264375566,"owners_count":23598402,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["golang","golang-api","serp-api"],"created_at":"2024-11-20T05:34:01.649Z","updated_at":"2025-07-09T01:33:28.317Z","avatar_url":"https://github.com/serpapi.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Google Search Results GoLang API\n\n![test](https://github.com/serpapi/google-search-results-golang/workflows/Go/badge.svg)\n\nThis Golang package enables to scrape and parse results from Google, Bing, Baidu, Yahoo, Yandex, Ebay, Google Schoolar and more using [SerpApi](https://serpapi.com).\n \nThis project is an implementation of SerpApi in Golang 1.12\nThere is no dependency for this project.\n\nThis Go module is meant to scrape and parse Google results using [SerpApi](https://serpapi.com).\nThe following services are provided:\n * [Search API](https://serpapi.com/search-api)\n * [Location API](https://serpapi.com/locations-api)\n * [Search Archive API](https://serpapi.com/search-archive-api)\n * [Account API](https://serpapi.com/account-api)\n\nSerpApi provides a [script builder](https://serpapi.com/demo) to get you started quickly.\n\nAn implementation example is provided here.\n\u003e demo/demo.go\n\nYou take a look to our test. \n\u003e test/google_seach_results_test.go\n\n[The full documentation is available here.](https://serpapi.com/search-api)\n\n\n## Installation\n\nGo 1.10+ must be already installed.\n```bash\ngo get -u github.com/serpapi/google-search-results-golang\n```\n\n## Quick start\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\tg \"github.com/serpapi/google-search-results-golang\"\n)\n\nparameter := map[string]string{\n    \"q\":            \"Coffee\",\n    \"location\":     \"Portland\"\n}\n\nquery := NewGoogleSearch(parameter, api)\n// Many search engine available: bing, yahoo, baidu, googemaps, googleproduct, googlescholar, ebay, walmart, youtube..\n\nrsp, err := query.json()\nresults := rsp[\"organic_results\"].([]interface{})\nfirst_result := results[0].(map[string]interface{})\nfmt.Println(ref[\"title\"].(string))\n```\n\nThis example runs a search about \"coffee\" using your secret api key.\n\nThe SerpApi service (backend)\n - searches on Google using the search: q = \"coffee\"\n - parses the messy HTML responses\n - return a standardizes JSON response\n - Format the request\n - Execute GET http request against SerpApi service\n - Parse JSON response into a deep hash\nEt voila..\n\nAlternatively, you can search:\n - Bing using NewBingSearch method\n - Baidu using NewBaiduSearch method\n\nSee the [playground to generate your code.](https://serpapi.com/playground)\n\n## Example\n * [Search API capability](#search-api-capability)\n * [Example by specification](#example-by-specification)\n * [Location API](#location-api)\n * [Search Archive API](#search-archive-api)\n * [Account API](#account-api)\n\n### Search API capability\n```go\nparameter = {\n  \"q\": \"query\",\n  \"google_domain\": \"Google Domain\",\n  \"location\": \"Location Requested\",\n  \"device\": device,\n  \"hl\": \"Google UI Language\",\n  \"gl\": \"Google Country\",\n  \"safe\": \"Safe Search Flag\",\n  \"num\": \"Number of Results\",\n  \"start\": \"Pagination Offset\",\n  \"api_key\": \"Your SERP API Key\",\n  \"tbm\": \"nws|isch|shop\",\n  \"tbs\": \"custom to be search criteria\",\n  \"async\": true|false,  // allow async \n  \"output\": \"json|html\" // output format\n}\n\n// api_key from https://serpapi.com/dashboard\napi_key := \"your personal API key\"\n\n// set search engine: google|yahoo|bing|ebay|yandex\nengine := \"yahoo\"\n\n// define the search search\nsearch := NewSearch(engine, parameter, api_key)\n\n// override an existing parameter\nsearch.parameter[\"location\"] = \"Portland,Oregon,United States\"\n\n// search format return as raw html\ndata, err := search.GetHTML()\n\n// search format returns a json\ndata, err := search.GetJSON()\n```\n\n(the full documentation)[https://serpapi.com/search-api]\n\nFull example: [https://github.com/serpapi/google-search-results-golang/blob/master/demo/demo.go]\n\nsee below for more hands on examples.\n\n### Location API\n\n```go\nvar locationList SerpResponseArray\nvar err error\nlocationList, err = search.GetLocation(\"Austin\", 3)\n\nif err != nil {\n  log.Println(err)\n}\nlog.Println(locationList)\n```\nrsp contains the first 3 location matching Austin (Texas, Texas, Rochester)\n\n### Search Archive API\n\nRun a search then get search result from the archive using the search archive API.\n```go\nparameter := map[string]string{\n  \"q\":        \"Coffee\",\n  \"location\": \"Portland\"\n  }\n\nsearch := NewGoogleSearch(parameter, \"your user key\")\nrsp, err := search.GetJSON()\n\nif err != nil {\n  log.Println(\"unexpected error\", err)\n}\n\nsearchID := rsp[\"search_metadata\"].(map[string]interface{})[\"id\"].(string)\nsearchArchive, err := search.GetSearchArchive(searchID)\nif err != nil {\n  log.Println(err)\n  return\n}\n\nsearchIDArchive := searchArchive[\"search_metadata\"].(map[string]interface{})[\"id\"].(string)\nif searchIDArchive != searchID {\n  log.Println(\"search_metadata.id do not match\", searchIDArchive, searchID)\n}\n\nlog.Println(searchIDArchive)\n```\nit prints the search ID from the archive.\n\n### Account API\n```go\nvar data SearchResult\nvar err error\ndata, err = search.GetAccount()\n\nif err != nil {\n  log.Println(err)\n  return\n}\nlog.Println(data)\n```\ndata contains the account information.\n\n### Example by specification\n\nWe love true open source, continuous integration and Test Drive Development (TDD). \n We are using \"go test\" to test our infrastructure around the clock\n  to achieve the best QoS (Quality Of Service).\n \nThe directory test/ includes specification/examples.\n\nTo run the test from bash using make\n```bash\nexport API_KEY=\"your secret key\"\nmake test\n```\n\n### Error management\n\nThis library follows the basic error management solution provided by Go.\n A simple error is returned in case something goes wrong. \n The error wraps a simple error message.\n \n## Change log\n * 3.2\n   - add naver search\n   - add apple store search\n * 3.1\n   - Add home depot search engine\n * 3.0\n   - Naming convention change.\n   - Rename Client to Search\n   - Fix lint issue\n   - Add walmart and youtube\n * 2.1 \n    - Add support for Yandex, Ebay, Yahoo\n    - create HTTP search only once per SerpApiClient\n * 2.0 Rewrite fully the implementation\n        to be more scalable in order to support multiple engines.\n * 1.3 Add support for Bing and Baidu\n * 1.2 Export NewGoogleSearch outside of the package.\n\n## Conclusion\n\nSerpApi supports mutiple search engines and subservices all available for this Golang search.\n\nFor example: Using Google search.\nTo enable a type of search, the field tbm (to be matched) must be set to:\n\n * isch: Google Images API.\n * nws: Google News API.\n * shop: Google Shopping API.\n * any other Google service should work out of the box.\n * (no tbm parameter): regular Google search.\n\nThe field `tbs` allows to customize the search even more.\n\n[The full documentation is available here.](https://serpapi.com/search-api)\n\n## Contributing\n\nContributions are welcome, feel to submit a pull request!\n\nTo run the tests:\n\n```bash\nmake test\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fserpapi%2Fgoogle-search-results-golang","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fserpapi%2Fgoogle-search-results-golang","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fserpapi%2Fgoogle-search-results-golang/lists"}