AIShub collector gets data from AIShub network and stores it to the MySQL database for later use. The script is written in Python 3.
The collector contains three scripts:
aishub-collector.py
gets current data from AIShub API (see [http://www.aishub.net/api]) and stores it totemp
table. You should call this script as often as you wish to get a snapshot of vessels in your area.aishub-downsampler.py
1) reads thetemp
table, 2) writes the last entry of every ship toaisdata
and cleans thetemp
table.aishub-stations.py
Reads the station network (Station ID, name, uptime and location) from AIShub network website. There is no API for retrieving station data.
- Python 3
pymysql
(Debian/Ubuntu packagepython3-pymysql
)numpy
(Debian/Ubuntu packagepython3-numpy
)
- Create and edit
settings.json
based on samplesettings.sample.json
. You need to fill your AIShub username to the AIShub URL and enter your MySQL credentials. - Create MySQL database, e.g.:
mysql -u root -p <database.sql
- Set
cron
to executeaishub-collector.py
every ~2 minutes andaishub-downsampler.py
as often as you wish to store the data (e.g. every 24 hours). - Set
cron
to executeaishub-stations.py
(e.g. weekly). - Profit!