# README
YakAPI Server
The YakAPI Server is meant to run on Rovers to provide an API for it. It is extensible by allowing implementation specific software to participate in a Rover software ecosystem.
Usage
yakapi
acts as a http server that presents a JSON API
API
The JSON API is versioned, so start with /v1
and you'll receive a nice hello:
$ curl -s http://localhost:8080/v1 | jq . { "name": "YakAPI (development)", "uptime": 1, "resources": [ { "name": "metrics", "ref": "/metrics" }, { "name": "ci", "ref": "/v1/ci" }, { "name": "cam", "ref": "/v1/cam/capture" }, { "name": "project", "ref": "https://github.com/rhettg/yakapi" } ] }
### Development
YakAPI lives by [scripts-to-rule-them-all](https://github.com/github/scripts-to-rule-them-all) rules.
But dependencies and setup are limited. Really you should be able to go out of the box with:
```ShellSession
$ script/server
2022-05-13T03:09:53.020Z INFO yakapi/main.go:218 starting {"version": "1.0.0", "port": "8080"}
Production
Sky is the limit, but for easy integration a Dockerfile
is provided that is easily customized by environment variables.
$ docker build -f Dockerfile -t yakapi:latest .
...
$ docker run --rm \
-p 80:8080 \
-e YAKAPI_NAME="My Rover" \
-e YAKAPI_REDIS_URL="127.0.0.1:6379" \
-e YAKAPI_CAM_CAPTURE_PATH="/var/cam/capture.jpeg" \
-v /var/cam:/var/cam \
yakapi:latest
...
Configuration
Configuration is primarily through environment variables
YAKAPI_PORT
[default8080
] port for api server to listen onYAKAPI_NAME
[defaultYakBot
] name for roverYAKAPI_PROJECT_URL
[defaulthttps://github.com/The-Yak-Collective/yakrover
] URL for more informationYAKAPI_CAM_CAPTURE_PATH
path to image for camera.
Components
Metrics
Metrics are served in prometheus format:
$ curl -s http://localhost:8080/metrics
# HELP yakapi_processed_ops_total The total number of processed requests
# TYPE yakapi_processed_ops_total counter
yakapi_processed_ops_total 0
...
ci (command injection)
This service translates commands into motor settings. There are two streams that a implementation must interact with:
ci
stream of accepted commandsci:result
results of executing commands
cam
The camera component can current serve an image if placed in a configured path.