Wanted to test a typescript implementation and specially easily scaling it. The service in itself is stateless and push consistency the datastore, which is redis.
I used the thompson-sampling implementation from this repository because i'm no math expert but other implemtation can be easily added (see src/bandits/impls/
).
The service expose a simple API that expose the MAB logic so you can built on it, here are the endpoints:
Method | HTTP request | Description |
---|---|---|
create | PUT /bandits/{id} | |
get | GET /bandits/{id} | |
pick | GET /bandits/{id}/pick/{pickId}?count={count} | You can use count if you want to make multiple pick within the same request |
reward | GET /bandits/{id}/reward/{arm} | |
update | POST /bandits/{id} |
All URIs are relative to http://localhost/api