{"id":21130408,"url":"https://github.com/serpapi/google-search-results-dotnet","last_synced_at":"2025-08-21T06:49:52.242Z","repository":{"id":46122804,"uuid":"188760699","full_name":"serpapi/google-search-results-dotnet","owner":"serpapi","description":"Google Search Results via SERP API DotNet Package","archived":false,"fork":false,"pushed_at":"2023-06-16T00:01:06.000Z","size":100,"stargazers_count":9,"open_issues_count":4,"forks_count":6,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-06-30T09:15:16.024Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C#","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":"MIT-LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-05-27T02:52:36.000Z","updated_at":"2025-02-27T11:11:42.000Z","dependencies_parsed_at":"2023-01-30T03:16:06.727Z","dependency_job_id":null,"html_url":"https://github.com/serpapi/google-search-results-dotnet","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/serpapi/google-search-results-dotnet","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serpapi%2Fgoogle-search-results-dotnet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serpapi%2Fgoogle-search-results-dotnet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serpapi%2Fgoogle-search-results-dotnet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serpapi%2Fgoogle-search-results-dotnet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/serpapi","download_url":"https://codeload.github.com/serpapi/google-search-results-dotnet/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serpapi%2Fgoogle-search-results-dotnet/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264375571,"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":[],"created_at":"2024-11-20T05:33:08.552Z","updated_at":"2025-07-09T01:33:29.466Z","avatar_url":"https://github.com/serpapi.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Search Results in Dotnet / CSharp / .Net powered by SerpApi.com\n\n[![test](https://github.com/serpapi/google-search-results-dotnet/workflows/test/badge.svg)](https://github.com/serpapi/google-search-results-dotnet/actions)\n[![NuGet version](https://badge.fury.io/nu/google-search-results-dotnet.svg)](https://badge.fury.io/nu/google-search-results-dotnet)\n\nThis Dotnet 3.1 package is meant to scrape and parse results from Google, Bing, Baidu, Yandex, Yahoo, Ebay and more using [SerpApi](https://serpapi.com).\n\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\n## Installation\n\nTo install the package.\n```bash\ndotnet add package google-search-results-dotnet --version 2.0.1\n```\n\nMore commands available at https://www.nuget.org/packages/google-search-results-dotnet\n\n## Quick start \n\nLet's run a search on Google.\n\n```csharp\nusing System;\nusing SerpApi;\nusing System.Net.Http;\nusing Newtonsoft.Json.Linq;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Threading.Tasks;\nusing System.Text.RegularExpressions;\n\nnamespace Baidu\n{\n  class Program\n  {\n\n    static void Main(string[] args)\n    {\n      // secret api key from https://serpapi.com/dashboard\n      String apiKey = \"\u003csecret_api_key\u003e\";\n\n      // Localized search for Coffee shop in Austin Texas\n      Hashtable ht = new Hashtable();\n      ht.Add(\"location\", \"Austin, Texas, United States\");\n      ht.Add(\"q\", \"Coffee\");\n      ht.Add(\"hl\", \"en\");\n      ht.Add(\"google_domain\", \"google.com\");\n\n      try\n      {\n         GoogleSearch search = new GoogleSearch(ht, apiKey);\n\n        Console.WriteLine(\"Search coffee in Austin, Texas on Google [1 credit]\");\n        JObject data = search.GetJson();\n        Console.WriteLine(\"local coffee shop\");\n        JArray coffeeShops = (JArray)data[\"local_results\"][\"places\"];\n        foreach (JObject coffeeShop in coffeeShops)\n        {\n          Console.WriteLine(\"Found: \" + coffeeShop[\"title\"]);\n        }\n        Console.WriteLine(\"organic result coffee shop\");\n        coffeeShops = (JArray)data[\"organic_results\"];\n        foreach (JObject coffeeShop in coffeeShops)\n        {\n          Console.WriteLine(\"Found: \" + coffeeShop[\"title\"]);\n        }\n\n        string id = (string)((JObject)data[\"search_metadata\"])[\"id\"];\n        Console.WriteLine(\"Search from the archive: \" + id + \". [0 credit]\");\n        JObject archivedSearch = search.GetSearchArchiveJson(id);\n        foreach (JObject coffeeShop in (JArray)archivedSearch[\"organic_results\"])\n        {\n          Console.WriteLine(\"Found: \" + coffeeShop[\"title\"]);\n        }\n\n        //  Get account information\n        Console.WriteLine(\"Account information: [0 credit]\");\n        JObject account = search.GetAccount();\n        Dictionary\u003cstring, string\u003e dictObj = account.ToObject\u003cDictionary\u003cstring, string\u003e\u003e();\n        foreach (string key in dictObj.Keys)\n        {\n          Console.WriteLine(key + \" = \" + dictObj[key]);\n        }\n\n        // close socket\n        search.Close()\n      }\n      catch (SerpApiSearchException ex)\n      {\n        Console.WriteLine(\"Exception:\");\n        Console.WriteLine(ex.ToString());\n      }\n    }\n  }\n}\n```\n\nThis example displays the top 3 coffee shop in Austin Texas found in the local_results.\nThen it displays all 10 coffee shop found in the regular google search named: organic_results.\n\n## Search API\n[Back-end documentation](https://serpapi.com/search-api) \n\n### Google search engine\n```csharp\nGoogleSearch search = GoogleSearch(parameter, apiKey);\nJObject data = search.GetJson();\n```\n\ntest: https://github.com/serpapi/google-search-results-dotnet/blob/master/test/google_search_test.cs  \ndoc: https://serpapi.com/search-api\n\n### Bing search engine\n```csharp\nBingSearch search = BingSearch(parameter, apiKey);\nJObject data = search.GetJson();\n```\n\nA full example is available here.\nhttps://github.com/serpapi/google-search-results-dotnet/blob/master/example/bing/  \ntest: https://github.com/serpapi/google-search-results-dotnet/blob/master/test/bing_search_test.cs  \ndoc: https://serpapi.com/bing-search-api\n\n\n### Baidu search engine\n```csharp\nBaiduSearch search = BaiduSearch(parameter, apiKey);\nJObject data = search.GetJson();\n```\n\nA full example is available here.\nhttps://github.com/serpapi/google-search-results-dotnet/blob/master/example/baidu/  \ntest: https://github.com/serpapi/google-search-results-dotnet/blob/master/test/baidu_search_test.cs  \ndoc: https://serpapi.com/baidu-search-api\n\n### Yahoo search engine\n```csharp\nYahooSearch search = YahooSearch(parameter, apiKey);\nJObject data = search.GetJson();\n```\ntest: https://github.com/serpapi/google-search-results-dotnet/blob/master/test/yahoo_search_test.cs  \ndoc: https://serpapi.com/yahoo-search-api  \n\n### Yandex search engine\n```csharp\nYandexSearch search = YandexSearch(parameter, apiKey);\nJObject data = search.GetJson();\n```\ntest: https://github.com/serpapi/google-search-results-dotnet/blob/master/test/yandex_search_test.cs  \ndoc: https://serpapi.com/yandex-search-api \n\n### Ebay search engine\n```csharp\nEbaySearch search = EbaySearch(parameter, apiKey);\nJObject data = search.GetJson();\n```\ntest: https://github.com/serpapi/google-search-results-dotnet/blob/master/test/ebay_search_test.cs  \ndoc: https://serpapi.com/ebay-search-api \n\n### Generic search for other search engine\nHere an example using walmart as search engine.\n```csharp\nSerpApiSearch search = SerpApiSearch(parameter, apiKey, \"walmart\")\n```\nsee: the list of engine supported from the [documentation](https://serpapi.com/search-api).\n\n## Location API\n\n```csharp\nHashtable ht = new Hashtable();\nGoogleSearch search = new GoogleSearch(ht, apiKey);\nJArray locations = search.GetLocation(\"Austin,TX\", 3);\nforeach (JObject location in locations)\n{\n  Console.WriteLine(location);\n}\n```\n\n## Search Archive API\n\n```csharp\nHashtable ht = new Hashtable();\nht.Add(\"q\", \"Coffee\");\nGoogleSearch search = new GoogleSearch(ht, apiKey);\n// search [1 credit]\nJObject data = search.GetJson();\n// get unique search id\nstring id = (string)((JObject)data[\"search_metadata\"])[\"id\"];\n// search from the archive using id [0 credit]\nJObject archivedSearch = search.GetSearchArchiveJson(id);\n```\n\n## Get Account API\n\n```csharp\nHashtable ht = new Hashtable();\nGoogleSearch search = new GoogleSearch(ht, apiKey);\nJObject account = search.GetAccount();\nDictionary\u003cstring, string\u003e dictObj = account.ToObject\u003cDictionary\u003cstring, string\u003e\u003e();\nforeach (string key in dictObj.Keys)\n{\n  Console.WriteLine(key + \" = \" + dictObj[key]);\n}\n```\n\n## Test\nThis library is fully unit tested.  \nThe tests can be used as implementation examples.  \nhttps://github.com/serpapi/google-search-results-dotnet/tree/master/test\n\n## Changes log\n### 2.0.1 - bug fix\n * Special characters encoding support.\n * Allow to modified parameter using ```search.paramaterContext```\n * Upgrade to netcoreapp3.1\n  \n### 2.0\n * Reduce class name to \u003cengine\u003eSearch \n\n### 1.5\n * Add support for Yandex, Ebay, Yahoo\n  \n### 1.4\n * Bug fix: Release Socket connection when requests finish. \n   Because Dotnet does not release the ressource when the HTTP Client is closed.\n * Add Yahoo support: YahooSearch\n * Create only one search for all the connection\n  \n### 1.3 \n * Add bing and baidu support\n * Allow custom HTTP timeout using: setTimeoutSeconds\n * Fix exception class visibility and renamed to SerpApiSearchException\n\n### 1.2\n * Initial release matching SerpApi 1.2 internal API\n\nTODO\n---\n * [ ] Add example for highly concurrent requests.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fserpapi%2Fgoogle-search-results-dotnet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fserpapi%2Fgoogle-search-results-dotnet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fserpapi%2Fgoogle-search-results-dotnet/lists"}