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 pymavlinkThis 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 pymavrestSee 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 pymavlinkOr with mavsdk:
uv run -p 3.12 main.py -c config.json --backend mavsdkFor long-running production systems, prefer systemd mode (--prod true) so service restarts are managed automatically.
