pymavrest is a high-performance REST server for MAVLink-based drones ๐.
It lets you read telemetry over HTTP and send flight commands over HTTP.
It is a Python alternative to mavlink2rest with a strong async architecture ๐ฐ๏ธ:
https://github.com/mavlink/mavlink2rest
- Fully async and high performance โก.
- Supports VTOL, multirotor, and other MAVLink-capable vehicles ๐.
- Compatible with PX4, ArduPilot, and other MAVLink firmwares ๐ฉ๏ธ.
- Read telemetry data via HTTP and send drone commands via HTTP ๐.
- Built-in auth and multi-user access control (JWT + user permissions) ๐.
- Uses
pymavlinkandmavsdkbackends and can switch automatically when needed ๐. - Highly configurable via
config.jsonโ๏ธ. - Easy one-command install on mini-computers like Raspberry Pi ๐ฅ๏ธ.
For production deployments, install and configure mavlink-router:
https://github.com/mavlink-router/mavlink-router
Architecture:
Drone ๐ <-> mavlink-router ๐ก <-> pymavrest ๐ฐ๏ธ <-> REST Clients ๐
Example request (flight_details):
curl http://localhost:8080/api/v1/messages/flight_details \
-H "Authorization: Bearer <token>"Returns aggregated telemetry including:
- flight mode ๐งญ
- battery state ๐
- GPS position ๐
- speed and attitude ๐๏ธ
- RC status ๐ฎ
- EKF status ๐
- connection flags ๐
- mission summary ๐บ๏ธ
Note: use the port configured in config.json (rest_api.port). The default in this project is 10821.
OpenAPI docs are available at ๐:
http://127.0.0.1:10821/docs
The port may differ depending on your config.json (rest_api.port).
Run installer directly with curl:
curl -fsSL https://raw.githubusercontent.com/hadif1999/pymavrest/master/scripts/install.sh | bash -s -- --prod true --backend pymavlink
This installs dependencies, syncs the repo into ~/app by default, and in production mode deploys/runs pymavrest.service.
scripts/install.sh supports:
--branch <name>: Git branch to clone/pull. Default:master--app-dir <path>: Install/update directory. Default:$HOME/app--prod <true|false>:true: deploy and run withsystemdfalse: install only (do not start app)- Default:
true
--backend <pymavlink|mavsdk>: Backend passed to runtime. Default:pymavlink-h,--help: show full help
Help example:
curl -fsSL https://raw.githubusercontent.com/hadif1999/pymavrest/master/scripts/install.sh | bash -s -- --helpBefore production use, edit your config.json values for your environment.
At minimum, update drone connection, auth secrets/users, server endpoints, and networking.
If running as a service, restart after config changes:
sudo systemctl restart pymavrest
See README_config.md for full details. Main sections:
generallog_level: logging level (DEBUG,INFO, ...)is_production: production behavior flag
drone.propertiesURI: MAVLink source (example:tcp://127.0.0.1:14550)FLIGHT_MODES: mode code mappingbattery_cap_mah: battery capacity metadataserial_number: optional drone identifier
external_devices- Device configs such as
gpsandsms(type,COM,baud,enabled)
- Device configs such as
requestsping_check_by_host,timeout,retries
rest_apiport,host,global_prefix,global_timeoutas_https,ssl_keyfile_dir,ssl_certfile_dir
authenabled,jwt_secret,jwt_token_expire_minutes,jwt_algorithmusers[]withusername,password,permission,active,is_admin
health_checkenabled,push_to_server,send_sms_in_failroute,flight_info_route,update_interval_sec
serverbase_urlauth:username,password,route,type
smsrecipient
You can run directly with uv run main.py for testing or production-like manual operation:
cd ~/app uv run -p 3.12 main.py -c config.json --backend pymavlink
Or with mavsdk:
uv run -p 3.12 main.py -c config.json --backend mavsdk
For long-running production systems, prefer systemd mode (--prod true) so service restarts are managed automatically.