Skip to content

Navigation Menu

Sign in
Sign up

Latest commit

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

pymavrest logo

pymavrest

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

Project strengths โœจ

  • 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 pymavlink and mavsdk backends and can switch automatically when needed ๐Ÿ”„.
  • Highly configurable via config.json โš™๏ธ.
  • Easy one-command install on mini-computers like Raspberry Pi ๐Ÿ–ฅ๏ธ.

Production prerequisite ๐Ÿ›ซ

For production deployments, install and configure mavlink-router:

https://github.com/mavlink-router/mavlink-router

Data flow and API example ๐Ÿ“ก

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).

Install (one command) โš™๏ธ

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.

Installer arguments ๐Ÿงฉ

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 with systemd
    • false: 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 -- --help

Configure config.json (important for production) ๐Ÿ› ๏ธ

Before 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

config.json parameters ๐Ÿ“˜

See README_config.md for full details. Main sections:

  • general
    • log_level: logging level (DEBUG, INFO, ...)
    • is_production: production behavior flag
  • drone.properties
    • URI: MAVLink source (example: tcp://127.0.0.1:14550)
    • FLIGHT_MODES: mode code mapping
    • battery_cap_mah: battery capacity metadata
    • serial_number: optional drone identifier
  • external_devices
    • Device configs such as gps and sms (type, COM, baud, enabled)
  • requests
    • ping_check_by_host, timeout, retries
  • rest_api
    • port, host, global_prefix, global_timeout
    • as_https, ssl_keyfile_dir, ssl_certfile_dir
  • auth
    • enabled, jwt_secret, jwt_token_expire_minutes, jwt_algorithm
    • users[] with username, password, permission, active, is_admin
  • health_check
    • enabled, push_to_server, send_sms_in_fail
    • route, flight_info_route, update_interval_sec
  • server
    • base_url
    • auth: username, password, route, type
  • sms
    • recipient

Run manually (test or production) โ–ถ๏ธ

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.

About

Secure Python async REST API for MAVLink drone telemetry and control.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Contributors

Languages

AltStyle ใซใ‚ˆใฃใฆๅค‰ๆ›ใ•ใ‚ŒใŸใƒšใƒผใ‚ธ (->ใ‚ชใƒชใ‚ธใƒŠใƒซ) /