jhalter / mobius

A Hotline server implemented in Golang for macOS, Linux, and Windows operating systems
MIT License
73 stars 8 forks source link

Mobius API #29

Open aptonline opened 2 years ago

aptonline commented 2 years ago

I appreciate this may be way out of the scope of what you are trying to achieve with Mobius but it occurred to me it would be useful for the sever to have its own API that you could use to query activity on the server. For example, to find out how many users are online, the status of the server, any new posts, messages or files that have been uploaded. This could then be used in other , more modern, enviroments such as home assistant or as an alternative to having to trawl the logs for data.

From an iPhone users perspective, having a widget/shortcut combo that shows me stats of the server when away from home would be a great addition. This is only scratching the surface of what an API could do.

jhalter commented 2 years ago

Thanks for the suggestion. I've intended to do something like this for my own use and plan to work on it after I get through more of the feature parity tasks.

My thought is to add an optional command line argument like --stat-port=5503 that will expose an HTTP endpoint that returns JSON with whatever info seems useful.

aptonline commented 2 years ago

For reference here are the stats that are shown within the official 1.9.1 server: Screenshot 2022-06-09 at 21 38 36

jhalter commented 2 years ago

I'm hoping to render exactly that window on my Pi server, so I'll definitely collect those stats in addition to others:

IMG_6113

The text is a bit too small on a 1.54" display though, may need to upgrade.

jhalter commented 2 months ago

I've added a couple of new HTTP API endpoint in #143 that provide missing functionality to reload the configuration and send shutdown messages, but I think I'll leave it at that for now.

aptonline commented 1 month ago

Great stuff, would be helpful to be able to see via the API the server version as well if thats easy to implement :)

EDIT: turns out I'm running 0.12.3 and didn't realise it 👎🏼

aptonline commented 1 month ago

All up-to-date now :)