* **UPDATE ***

A new and improved API has been released, check it out!

RaspiMon API

A simple API for monitoring your raspberry pi.

Installation

Clone the repository:

$ git clone git@github.com:raekw0n/raspi-mon-api.git

Create the virtual environment:

$ pip virtualenv piMonitor

Activate the virtual environment:

$ source piMonitor/bin/activate

Install the project’s dependencies:

$ pip install -r requirements.txt

How it Works

It’s incredibly simple, just submit a GET request to your chosen endpoint to receive data, which will always be returned in JSON format, then you can consume that data with whatever library/language you’re using and use it to display information about your Pi.

Endpoints

GET /system

Returns a JSON object containing core system information, including:

Please refer to the system.json test file for a detailed example.

GET /network

Returns a JSON object containing network information, including:

Please refer to the network.json test file for a detailed example.

GET /network/counter/<interface>

(e.g. /network/counter/wlan0)

Streams a JSON representation of kB/s sent/received for the chosen interface

Apache Configuration

Firstly, make sure you have libapache2-mod-wsgi installed:

$ sudo apt install libapache2-mod-wsgi

Then create and enable your new virtualhost configuration:

<VirtualHost *:80>
    ServerName api.raspberrypi.local
    ServerAlias www.api.raspberrypi.local
    WSGIScriptAlias / /var/www/flaskapps/rasPiMon/raspimon.wsgi
    <Directory /var/www/flaskapps/rasPiMon>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride all
            Require all granted
    </Directory>
    ErrorLog /var/log/apache2/api.raspberrypi.local-error.log
    CustomLog /var/log/apache2/api.raspberrypi.local-access.log combined
</VirtualHost>
$ sudo a2ensite api.raspberrypi.local.conf
$ sudo systemctl reload apache2

A working example client can be downloaded from here.

License

RaspiMon API is open-sourced software licensed under the MIT license.