https://github.com/iam1337/extapi
Simple Web Api for Unity
https://github.com/iam1337/extapi
Last synced: about 1 month ago
JSON representation
Simple Web Api for Unity
- Host: GitHub
- URL: https://github.com/iam1337/extapi
- Owner: Iam1337
- License: mit
- Created: 2024-06-13T13:23:15.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2024-12-10T08:37:45.000Z (5 months ago)
- Last Synced: 2025-03-24T08:47:13.438Z (about 2 months ago)
- Language: C#
- Size: 64.5 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# extApi - Simple Http Server for Unity
Created by [iam1337](https://github.com/iam1337)

[](https://github.com/Iam1337/extApi/actions/workflows/ci.yml)
[](https://openupm.com/packages/com.iam1337.extapi/)
[](https://github.com/Iam1337/extApi/blob/master/LICENSE)
[](https://github.com/semantic-release/semantic-release)### Table of Contents
- [Introduction](#introduction)
- [Installation](#installation)
- [Examples](#examples)
- [Author Contacts](#author-contacts)## Introduction
extApi - It is a simple Http Server, which requires a minimum of specific code to work with.### Features:
## Installation
**Old school**Just copy the [Assets/extApi](Assets/extApi) folder into your Assets directory within your Unity project.
**OpenUPM**
Via [openupm-cli](https://github.com/openupm/openupm-cli):
```
openupm add com.iam1337.extapi
```Or if you don't have it, add the scoped registry to manifest.json with the desired dependency semantic version:
```
"scopedRegistries": [
{
"name": "package.openupm.com",
"url": "https://package.openupm.com",
"scopes": [
"com.iam1337.extapi",
]
}
],
"dependencies": {
"com.iam1337.extapi": "1.0.0"
}
```## Examples
To make a simple Web Api, the following lines are enough:
```csharp
// Create Api Server
_api = new Api();
_api.AddController(new ApiController()); // <--- Add controller
_api.Listen(8080, IPAddress.Any, IPAddress.Loopback);// Simple controller example
[ApiRoute("api")]
public class ApiController
{
[ApiGet("vector/{x}/{y}/{z}")] // GET /api/vector/1/2.5/5
public ApiResult GetVector(float x, float y, float z)
{
return ApiResult.Ok(new Vector3(x, y, z));
}[ApiPost("vector")] // POST /api/vector { "x": 1.0, "y": 2.5, "z": 5.0 }
public ApiResult GetVector([ApiBody] Vector vector)
{
// TODO: ...
}
}
```## Author Contacts
\> [telegram.me/iam1337](http://telegram.me/iam1337)
\> [[email protected]](mailto:[email protected])## License
This project is under the MIT License.