{"id":20266346,"url":"https://github.com/whitesharx/httx","last_synced_at":"2025-06-26T07:04:00.520Z","repository":{"id":37804745,"uuid":"232530343","full_name":"whitesharx/httx","owner":"whitesharx","description":"⚡️ X-force HTTP/REST library for Unity ⚡️","archived":false,"fork":false,"pushed_at":"2022-07-19T09:20:04.000Z","size":314,"stargazers_count":25,"open_issues_count":2,"forks_count":0,"subscribers_count":6,"default_branch":"develop","last_synced_at":"2025-06-14T21:50:07.200Z","etag":null,"topics":["csharp","dotnet","http","rest","unity","unity3d"],"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/whitesharx.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-01-08T09:46:48.000Z","updated_at":"2023-05-16T21:17:17.000Z","dependencies_parsed_at":"2022-06-23T12:34:17.136Z","dependency_job_id":null,"html_url":"https://github.com/whitesharx/httx","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/whitesharx/httx","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whitesharx%2Fhttx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whitesharx%2Fhttx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whitesharx%2Fhttx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whitesharx%2Fhttx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/whitesharx","download_url":"https://codeload.github.com/whitesharx/httx/tar.gz/refs/heads/develop","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whitesharx%2Fhttx/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262018760,"owners_count":23245619,"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":["csharp","dotnet","http","rest","unity","unity3d"],"created_at":"2024-11-14T12:08:48.530Z","updated_at":"2025-06-26T07:04:00.501Z","avatar_url":"https://github.com/whitesharx.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n\u003ch1 align=\"center\"\u003eHttx\u003c/h1\u003e\n\n\u003ch3 align=\"center\"\u003e⚡️ X-Force HTTP/REST library for Unity ⚡️\u003c/h3\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca aria-label=\"License\" href=\"https://github.com/whitesharx/httx/blob/develop/LICENSE.md\"\u003e\n    \u003cimg alt=\"\" src=\"https://img.shields.io/static/v1?label=LICENSE\u0026message=MIT\u0026style=for-the-badge\u0026labelColor=000000\u0026color=blue\"\u003e\n  \u003c/a\u003e\n\n  \u003ca aria-label=\"CodeClimate\" href=\"https://codeclimate.com/github/whitesharx/httx/maintainability\"\u003e\n    \u003cimg alt=\"\" src=\"https://img.shields.io/static/v1?label=maintainability\u0026message=A\u0026style=for-the-badge\u0026labelColor=000000\u0026color=green\u0026logo=code-climate\"\u003e\n  \u003c/a\u003e\n\n  \u003ca aria-label=\"NPM\" href=\"https://www.npmjs.com/package/com.whitesharx.httx\"\u003e\n    \u003cimg alt=\"\" src=\"https://img.shields.io/npm/v/com.whitesharx.httx/latest?label=NPM\u0026style=for-the-badge\u0026labelColor=000000\u0026color=CB3837\u0026logo=npm\"\u003e\n  \u003c/a\u003e\n\n  \u003ca aria-label=\"Unity\" href=\"https://forum.unity.com/threads/httx-x-force-http-rest-library.1192855/\"\u003e\n    \u003cimg alt=\"\" src=\"https://img.shields.io/static/v1?label=Unity\u0026message=Forum\u0026style=for-the-badge\u0026labelColor=000000\u0026color=CCCCCC\u0026logo=unity\"\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n\u003cbr\u003e\n\n * Zero dependency, built for **Unity**\n * **Simple**, DSL-like API to compose your requests\n * Includes reliable memory, disk and native AssetBundle **cache** support\n * Easily **extensible** for your custom needs\n\n## Quick Start\n\nYou need **Unity 2019.x** or newer\n\n### Install Httx with Package Manger (NPM Package)\n\nHttx distributed as standard [Unity Package](https://docs.unity3d.com/Manual/PackagesList.html)\nYou can install this package using Unity Package Manager, just add the\nfollowing to your `Packages/manifest.json`:\n\nAdd official [NPM](https://www.npmjs.com/) registry with WhiteSharx scope, or simply\nadd `com.whitesharx` scope if you already have NPM registry added:\n\n```json\n{\n  \"scopedRegistries\": [\n    {\n      \"name\": \"Official NPM Registry\",\n      \"url\": \"https://registry.npmjs.org/\",\n      \"scopes\": [ \"com.whitesharx\" ]\n    }\n  ]\n}\n```\n\nAdd `com.whitesharx.httx` package to your dependencies (see repo tags to pick the version):\n\n```json\n{\n  \"dependencies\": {\n    \"com.whitesharx.httx\": \"x.x.x\"\n  }\n}\n```\n\n### Install Httx with Package Manger (Git url)\n\nOr, your can simply install it from git url (see repo tags to pick the version):\n\n```json\n{\n  \"dependencies\": {\n    \"com.whitesharx.httx\": \"https://github.com/whitesharx/httx.git#x.x.x\"\n  }\n}\n```\n\n### Add preserve rule for linker\n\nPreserve `Httx` assembly contents in your `Assets/link.xml`:\n\n```xml\n\u003clinker\u003e\n  \u003cassembly fullname=\"Httx\" preserve=\"all\"/\u003e\n\u003c/linker\u003e\n```\n\n### Initialize context\n\nFirst, you need to initaize `Context` to make HTTP requests. If you\ndo not need any fine-tune customization it's just one line of code:\n\n```csharp\nContext.InitializeDefault(1, () =\u003e { /* Ready to go callback */ });\n```\n\nTo give you more detailed example, suppose you want to do it from MonoBehaviour:\n\n```csharp\npublic class YourMonoBehaviour : MonoBehaviour {\n  // XXX: Versioning exists to manage caching.\n  private const int Version = 1;\n\n  private void Awake() {\n    Context.InitializeDefault(Version, OnContextReady);\n  }\n\n  private async void OnContextReady() {\n    // Here you can safely make HTTP requests using Httx.\n  }\n}\n```\n\n### Make your first HTTP requests\n\nNow you are ready to make HTTP requests. Suppose you realized that you desperetly need to\ndownload whole Google...as text. Here you go:\n\n```csharp\nvar text = await new As\u003cstring\u003e(new Get(new Text(\"https://google.com\")));\n```\n\nOk, that's was fun. But now, let's take a look at more serious stuff you can do with Httx\nstarting with simple requests:\n\n```csharp\n// Make simple GET request for text data.\nvar text = await new As\u003cstring\u003e(new Get(new Text(url)));\n\n// Make GET request for JSON data and parse it to your model with default JSONUtility.\nvar user = await new As\u003cUser\u003e(new Get(new Json(url)));\n\n// Make POST request with JSON payload and parse JSON model as response.\nvar credentials = await new As\u003cCredentials\u003e(new Post(new Json\u003cUser\u003e(url, new User(\"John Doe\"))));\n```\n\nTake a look at some even more complicated stuff:\n\n```csharp\n// Make POST request that requires basic authorization.\nvar token = await new As\u003cToken\u003e(new Post(new Basic(new Json\u003cUser\u003e(url, user), name, password)));\n\n// Make POST request that requires bearer authorization.\nvar credentials = await new As\u003cCredentials\u003e(new Put(new Bearer(new Json\u003cUser\u003e(url, user), token)));\n```\n\nHighly decorated requests become a bit messy. You can use **Fluent API** to build more complex requests.\nYou can rewrite two requests above with Fluent API like this:\n\n```csharp\n// Make POST request that requires basic authorization.\nvar token = await new Json\u003cUser\u003e(url, user)\n    .Post()\n    .Basic(name, password)\n    .As\u003cToken\u003e();\n\n// Make POST request that requires bearer authorization.\nvar credentials = await new Json\u003cUser\u003e(url, user)\n    .Post()\n    .Bearer(token)\n    .As\u003cCredentials\u003e();\n```\n\nLet's examine some caching capabilities. Httx supports **in-memory** and **disk** caching out of\nthe box. Also it supports native Unity **AssetBundle** caching:\n\n```csharp\n// Download a picture and also cache it on disk.\n// Next request to this url will be offline.\nvar texture = await new new Texture(url)\n    .Get()\n    .Cache(Storage.Disk)\n    .As\u003cTexture2D\u003e();\n\n// Download some \"hot\" data and cache it for a few seconds in memory.\n// Requests to this urls made in next 4 seconds will hit only memory in-cache.\nvar bytes = new Bytes(url)\n    .Get()\n    .Cache(Storage.Memory, TimeSpan.FromSeconds(4))\n    .As\u003cbyte[]\u003e();\n```\n\nHttx also supports Unity AssetBundles out of the box:\n\n```csharp\n// Download asset bundle. Local or remote urls supported.\nvar bundle = await new As\u003cAssetBundle\u003e(new Get(new Bundle(url)));\n\n// Download asset bundle and cache it on disk. Next request will hit offline file.\nvar bundle = await new As\u003cAssetBundle\u003e(new Cache(new Get(new Bundle(url)), Storage.Native));\n\n// Download asset bundle and display progress while downloading\nvar onProgress = new Progress\u003cfloat\u003e(value =\u003e { /* Implementation */ });\nvar bundle = await new As\u003cAssetBundle\u003e(new Get(new Bundle(url), onProgress));\n```\n\n## Documentation\n\nThere's more stuff under the hood. Please check detailed documentation and examples to\nunderstand how this librarty could fit your needs.\n\n* [Documentation](https://github.com/whitesharx/httx/wiki/Home)\n* [Examples](https://github.com/whitesharx/httx/wiki/Examples)\n\n## License\n\nHttx is available under the [MIT](https://en.wikipedia.org/wiki/MIT_License) license.\n\n\u003cp align=\"center\"\u003e\n  Made with 🖤 at \u003ca aria-label=\"WhiteSharx\" href=\"https://whitesharx.com\"\u003eWhiteSharx\u003c/a\u003e\n\u003c/p\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwhitesharx%2Fhttx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwhitesharx%2Fhttx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwhitesharx%2Fhttx/lists"}