{"id":14960612,"url":"https://github.com/ivanmurzak/unity-network-rest","last_synced_at":"2025-10-24T18:32:00.765Z","repository":{"id":113845081,"uuid":"442910255","full_name":"IvanMurzak/Unity-Network-REST","owner":"IvanMurzak","description":"REST plugin for client app/game to communicate with single or multiple remote servers using SOLID principles and clean code. Only JSON format is supported for data sending/receiving.","archived":false,"fork":false,"pushed_at":"2024-01-23T00:03:45.000Z","size":89,"stargazers_count":8,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-10-10T10:20:10.676Z","etag":null,"topics":["http","rest","unity","unity-plugin"],"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/IvanMurzak.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":"2021-12-29T22:58:16.000Z","updated_at":"2024-05-15T19:00:29.000Z","dependencies_parsed_at":"2024-09-29T06:19:08.668Z","dependency_job_id":null,"html_url":"https://github.com/IvanMurzak/Unity-Network-REST","commit_stats":{"total_commits":27,"total_committers":1,"mean_commits":27.0,"dds":0.0,"last_synced_commit":"ba3485fa61f0131c3ddead8cdfa2613550eee71b"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IvanMurzak%2FUnity-Network-REST","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IvanMurzak%2FUnity-Network-REST/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IvanMurzak%2FUnity-Network-REST/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IvanMurzak%2FUnity-Network-REST/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/IvanMurzak","download_url":"https://codeload.github.com/IvanMurzak/Unity-Network-REST/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219868059,"owners_count":16555878,"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":["http","rest","unity","unity-plugin"],"created_at":"2024-09-24T13:22:36.765Z","updated_at":"2025-10-24T18:32:00.117Z","avatar_url":"https://github.com/IvanMurzak.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Unity Network REST\n\n![npm](https://img.shields.io/npm/v/extensions.unity.network) [![openupm](https://img.shields.io/npm/v/extensions.unity.network?label=openupm\u0026registry_uri=https://package.openupm.com)](https://openupm.com/packages/extensions.unity.network/) ![License](https://img.shields.io/github/license/IvanMurzak/Unity-Network-REST) [![Stand With Ukraine](https://raw.githubusercontent.com/vshymanskyy/StandWithUkraine/main/badges/StandWithUkraine.svg)](https://stand-with-ukraine.pp.ua)\n\nREST plugin for client app/game to communicate with single or multiple remote servers using SOLID principles and clean code. Only JSON format is supported for data sending/receiving.\n\n### Features\n- :white_check_mark: Supported REST requests\n  - ✔️ GET\n  - ✔️ POST\n  - ✔️ PUT\n  - ✔️ DELETE\n- :white_check_mark: JSON serialization/deserialization\n- :white_check_mark: Headers control\n- :white_check_mark: Requests in a dedicated background thread\n\n# How to install - Option 1 (RECOMMENDED)\n\n- Install [ODIN Inspector](https://odininspector.com/)\n- Install [OpenUPM-CLI](https://github.com/openupm/openupm-cli#installation)\n- Open the command line in Unity project folder\n- `openupm add extensions.unity.network`\n\n# How to install - Option 2\n\n- Install [ODIN Inspector](https://odininspector.com/)\n- Add this code to \u003ccode\u003e/Packages/manifest.json\u003c/code\u003e\n```json\n{\n  \"dependencies\": {\n    \"extensions.unity.network\": \"1.4.3\",\n  },\n  \"scopedRegistries\": [\n    {\n      \"name\": \"package.openupm.com\",\n      \"url\": \"https://package.openupm.com\",\n      \"scopes\": [\n        \"extensions.unity\",\n        \"com.cysharp\",\n        \"com.neuecc\"\n      ]\n    }\n  ]\n}\n```\n\n# How to use\n## STEP 1: Create Server representation as ScriptableObject instance\nCreate a class for representing the server, let's call it ``RemoteServerSO``. Extend the class from ``NetworkSO``. Press the right mouse click on the project in Unity Editor, and create a new instance of server representation using the menu: ``Tools/Remote Server``. Select the instance and put it into the server endpoint. We will use the instance for sending requests to the server.\n```C#\n[CreateAssetMenu(fileName = \"RemoteServer\", menuName = \"Tools/Remote Server\", order = 0)]\npublic class RemoteServerSO : NetworkSO\n{\n\n}\n```\n\n## STEP 2: Create request\nLet's imagine the server by the Endpoint ``api/data`` returns the JSON.\n\n\u003cdetails\u003e\n    \u003csummary\u003eJSON body - response from a server\u003c/summary\u003e\n\u003cpre\u003e\u003ccode lang=\"json\"\u003e{\n    \"title\": \"My Title\",\n    \"description\": \"Some description is here\"\n}\u003c/pre\u003e\u003c/code\u003e\n\u003c/details\u003e\n\n\u003cdetails\u003e\n    \u003csummary\u003eC# representation of the server data response\u003c/summary\u003e\n\u003cpre\u003e\u003ccode lang=\"CSharp\"\u003e{\n    [OdinSerialize] public string title { get; set; }\n    [OdinSerialize] public string description { get; set; }\n}\u003c/pre\u003e\u003c/code\u003e\n\u003c/details\u003e\n\nEach unique request in REST API should be represented as a C# class. Let's create one GET request as an example. Need to override ``Endpoint`` for this specific request.\n```C#\npublic class GetDataRequest : RequestGet\u003cData\u003e\n{\n    protected override string Endpoint =\u003e $\"api/data\";\n\n    public GetDataRequest(RemoteServerSO remote) : base(remote) { }\n}\n``` \n### Optional data processing\nIf needed to process received data from the request, need to override ``OnDataReceived``\n```C#\npublic class GetDataRequest : RequestGet\u003cData\u003e\n{\n    protected override string Endpoint =\u003e $\"api/data\";\n\n    public GetDataRequest(RemoteServerSO remote) : base(remote) { }\n    \n    protected override UniTask OnDataReceived(Data data)\n    {\n        // doing something with data\n        return base.OnDataReceived(data);\n    }\n}\n``` \n\n## STEP 3: Send request\nCreating request instance and providing server instance\n```C#\nvar request = new GetRemoteConfigs(remoteServer);\n```\n\n### Option 1 - just send a request\n```C#\nrequest.SendRequest().Forget();\n```\n\n### Option 2 - send request and wait for a response with valid data deserialization\n```C#\nvar data = (await request.SendRequest()).ResponseData;\n```\n\n### Option 3 - send and subscribe on callback\n```C#\nrequest.SubscribeOnSuccess(data =\u003e\n{\n    // doing something with data\n}, this).SendRequest().Forget();\n```\n\n# Request callbacks\nSubscription should be done before calling ``SendRequest()``\n```C#\n// Response received, data successfully serialized from JSON to C# object\nrequest.SubscribeOnSuccess(data =\u003e\n{\n    // doing something with data\n}, this);\n\n// Response received, raw JSON data provided\nrequest.SubscribeOnSuccessRaw(rawJson =\u003e\n{\n    // doing something\n}, this);\n\n// Response received, JSON can't be deserialized for any reason\nrequest.SubscribeOnSerializationError(rawJson =\u003e\n{\n    // doing something\n}, this);\n\n// HTTP error\nrequest.SubscribeOnHttpError(httpError =\u003e\n{\n    // doing something\n}, this);\n\n// Network error, related to an internet connection, can't reach the server at all\nrequest.SubscribeOnNetworkError(networkError =\u003e\n{\n    // doing something\n}, this);\n\n// Progress is a float number in the range from 0.0f to 1.0f\nrequest.SubscribeOnProgress(progress =\u003e\n{\n    // doing something with data\n}, this);\n\n// Request completed with boolean \"success\" status (true or false)\nrequest.SubscribeOnComplete(success =\u003e\n{\n    // doing something with data\n}, this);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fivanmurzak%2Funity-network-rest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fivanmurzak%2Funity-network-rest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fivanmurzak%2Funity-network-rest/lists"}