{"id":22835227,"url":"https://github.com/jchristn/restwrapper","last_synced_at":"2025-04-06T07:14:34.947Z","repository":{"id":38008764,"uuid":"63818361","full_name":"jchristn/RestWrapper","owner":"jchristn","description":"RestWrapper is a simple C# class library to help simplify sending REST API requests and retrieving responses (RESTful HTTP and HTTPS)","archived":false,"fork":false,"pushed_at":"2024-10-29T06:46:12.000Z","size":18190,"stargazers_count":26,"open_issues_count":0,"forks_count":8,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-10-29T07:09:18.750Z","etag":null,"topics":["api","http","http-client","http-server","https","nuget","rest","rest-api","restclient","restwrapper"],"latest_commit_sha":null,"homepage":"","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/jchristn.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":"CODE_OF_CONDUCT.md","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},"funding":{"github":["jchristn"],"custom":["https://paypal.me/joelchristner"]}},"created_at":"2016-07-20T22:14:48.000Z","updated_at":"2024-10-29T06:46:15.000Z","dependencies_parsed_at":"2024-01-16T19:31:50.187Z","dependency_job_id":"a6567c9b-8fea-48a5-aebb-41f455155f9b","html_url":"https://github.com/jchristn/RestWrapper","commit_stats":{"total_commits":54,"total_committers":1,"mean_commits":54.0,"dds":0.0,"last_synced_commit":"7f1b4df9c436006f5e4de7cc45e3b872c22b466c"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jchristn%2FRestWrapper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jchristn%2FRestWrapper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jchristn%2FRestWrapper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jchristn%2FRestWrapper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jchristn","download_url":"https://codeload.github.com/jchristn/RestWrapper/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247445681,"owners_count":20939961,"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":["api","http","http-client","http-server","https","nuget","rest","rest-api","restclient","restwrapper"],"created_at":"2024-12-12T22:08:45.071Z","updated_at":"2025-04-06T07:14:34.773Z","avatar_url":"https://github.com/jchristn.png","language":"C#","readme":"![alt tag](https://raw.githubusercontent.com/jchristn/RestWrapper/master/assets/icon.ico)\n\n# RestWrapper\n\n[![NuGet Version](https://img.shields.io/nuget/v/RestWrapper.svg?style=flat)](https://www.nuget.org/packages/RestWrapper/) [![NuGet](https://img.shields.io/nuget/dt/RestWrapper.svg)](https://www.nuget.org/packages/RestWrapper) \n\nA simple C# class library to help simplify sending REST API requests and retrieving responses (RESTful HTTP and HTTPS)\n\n## Special Thanks\n\nThanks go out to the community for their help in making this library great!\n\n@nhaberl @jmkinzer @msasanmh @lanwah @nhaberl \n\n## New in v3.1.x\n\n- Minor breaking changes\n- Better internal support for chunked-transfer encoding\n- Remove non-async methods\n\n## Test Apps\n\nTest projects are included which will help you exercise the class library.\n \n## Examples\n\n```csharp\n// simple GET example\nusing RestWrapper;\nusing System.IO;\n\nusing (RestRequest req = new RestRequest(\"http://www.google.com/\"))\n{\n\tusing (RestResponse resp = await req.SendAsync())\n\t{\n\t\tConsole.WriteLine(\"Status: \" + resp.StatusCode);\n\t\t// response data is in resp.Data\n\t}\n}\n```\n\n```csharp\n// simple POST example\nusing RestWrapper;\nusing System.IO;\n\nusing (RestRequest req = new RestRequest(\"http://127.0.0.1:8000/api\", HttpMethod.POST))\n{\n\tusing (RestResponse resp = await req.SendAsync(\"Hello, world!\"))\n\t{\n\t\tConsole.WriteLine(\"Status : \" + resp.StatusCode);\n\t\t// response data is in resp.Data\n\t}\n}\n```\n\n```csharp\n// sending form data\nusing RestWrapper;\n\nusing (RestRequest req = new RestRequest(\"http://127.0.0.1:8000/api\", HttpMethod.POST))\n{\n\tDictionary\u003cstring, string\u003e form = new Dictionary\u003cstring, string\u003e();\n\tform.Add(\"foo\", \"bar\");\n\tform.Add(\"hello\", \"world how are you\");\n\n\tusing (RestResponse resp = await req.SendAsync(form))\n\t{\n\t\tConsole.WriteLine(\"Status : \" + resp.StatusCode);\n\t}\n}\n```\n\n```csharp\n// deserializing JSON\nusing RestWrapper;\n\nusing (RestRequest req = new RestRequest(\"http://127.0.0.1:8000/api\"))\n{\n\tusing (RestResponse resp = await req.SendAsync())\n\t{\n\t\tMyObject obj = resp.DataFromJson\u003cMyObject\u003e();\n\t}\n}\n```\n\n## A Note on Performance and 'localhost'\n\nRestWrapper uses the underlying `HttpWebRequest and `HttpWebResponse classes from `System.Net`.  When using `localhost` as the target URL, you may notice in Wireshark that `HttpWebRequest` will first attempt to connect to the IPv6 loopback address, and not all services listen on IPv6.  **This can create a material delay of more than 1 second**.  In these cases, it is recommended that you use `127.0.0.1` instead of `localhost` for these cases.\n\n## Basic Telemetry\n\nThe `RestResponse` object contains a property called `Time` that can be useful for understanding how long a request took to complete.\n\n```csharp\nRestRequest req = new RestRequest(\"https://www.cnn.com\");\nRestResponse resp = req.Send();\nConsole.WriteLine(\"Start    : \" + resp.Time.Start);\nConsole.WriteLine(\"End      : \" + resp.Time.End);\nConsole.WriteLine(\"Total ms : \" + resp.Time.TotalMs + \"ms\");\n```\n\n## Deserializing Response Data\n\nThe method `RestResponse.DataFromJson\u003cT\u003e()` will deserialize using `System.Text.Json`.  You can override the `RestResponse.SerializationHelper` property with your own implementation of `ISerializationHelper` if you wish to use your own deserializer.  Thank you @nhaberl for the suggestion.\n\n## Version History\n\nPlease refer to CHANGELOG.md for version history.\n","funding_links":["https://github.com/sponsors/jchristn","https://paypal.me/joelchristner"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjchristn%2Frestwrapper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjchristn%2Frestwrapper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjchristn%2Frestwrapper/lists"}