wrappers/rest-api/README.md
This Python library provides a convenient wrapper to interact with the [RealSense REST API], a FastAPI-based service that exposes the functionality of the RealSense SDK (librealsense) over a network.
It simplifies remote control and data streaming from RealSense devices by handling communication protocols for:
All endpoints and supported features are documented and available for interactive exploration at the /docs endpoint using the built-in OpenAPI (Swagger) UI.
Create a virtual environment:
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
Install dependencies:
python3 install.py
This installs the packages listed in requirements.txt and, if pyrealsense2
is not already importable, also pulls it from PyPI. If you already have
pyrealsense2 installed (locally built, system package, or any pip install),
the script leaves it untouched.
Run API server:
You can start the server using either method:
python main.py
Or use the shell script (Linux/macOS):
./start_server.sh
The API server will start on http://localhost:8000
Verify the API:
Open your browser and navigate to http://localhost:8000/docs to explore the API documentation via Swagger UI.
For a modern web-based UI to interact with RealSense devices:
Prerequisites:
Navigate to the React viewer directory:
cd tools/react-viewer
Install dependencies:
npm install
Configure environment (if needed):
Copy .env.example to .env and adjust settings if your API server runs on a different port.
Start the REST API server (in one terminal):
# From wrappers/rest-api directory
python main.py
Start the React viewer (in another terminal):
# From wrappers/rest-api/tools/react-viewer directory
npm run dev
Open in browser:
Navigate to http://localhost:3000
For more details about the React viewer features and development, see tools/react-viewer/README.md.
The run_tests.py helper at the rest-api root runs both the backend pytest suite and the React viewer Vitest suite:
# From wrappers/rest-api:
python run_tests.py # run both backend + frontend
python run_tests.py --backend # backend pytest only
python run_tests.py --frontend # react-viewer Vitest only
You can also run each suite directly:
# Backend (FastAPI / pytest)
pytest tests/
# Frontend (React viewer / Vitest)
cd tools/react-viewer && npm test
For React viewer end-to-end Playwright tests and full setup details, see
tools/react-viewer/tests/INSTALLATION.md.
For comprehensive testing with test extras (from the repository root):
pip3 install -r wrappers/rest-api/requirements.txt -r unit-tests/wrappers/rest-api/requirements.txt
Note: Basic 3D point cloud visualization and IMU data viewing are available in the React viewer.