# `Cauldron2D.Net.Api`
[🔗](https://github.com/jaman/cauldron/blob/v0.1.3/cauldron_2d_net/lib/cauldron_2d/net/api.ex#L1)

What a client on another machine asks a server over plain HTTP, as a plug a game
forwards a path to: a token for a name and password (`POST /token`, with `register:
true` to make the account first), the arenas (`GET /arenas`) as a lobby lists them,
how the server is keeping up (`GET /stats`), and the boards (`GET /leaders?period=day|
week|all&metric=<name>&arena=<name>`) when the game keeps a ledger.

    forward "/api", Cauldron2D.Net.Api, login: &MyGame.Web.Auth.login/2, register: &MyGame.Web.Auth.register/2, token: &MyGame.Web.Auth.token/1, ledger: MyGame.Ledger

## Options

  * `:login` — a function of a name and a password, `{:ok, name}` or `:error`. Required
  * `:register` — a function of a name and a password, `{:ok, name}` or `{:error, reason}`.
    Default: registration refused
  * `:token` — a function from a name to the token a socket connects with. Required
  * `:ledger` — a `Cauldron2D.Ledger` for the boards. Default: none, `GET /leaders` is 404

# `arena_json`

```elixir
@spec arena_json(map()) :: map()
```

An arena as the API lists it: strings for the id and the kind, no world.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
