rpi-express_api v0.1.12
RPi-Express_API
Expressjs API for Raspberry Pis built for the interaction of the GPIO pins. It provides endpoints that makes controlling the RPi over a network / internet a breeze with your own personal project without having to worry about a backend.
Collaboration
If you are keen on this project, please join as a developer too! I have made a Slack workspace (invitation link) for communication purposes. In Slack you can send a message and I can add you as collaborator.
Features
- Works over LAN and internet.
- Simple web interface for interacting with API: https://coenraadhuman.github.io/RPi-Express_API/.
- Give user option between GPIO.BOARD and GPIO.BCM for use with GPIO.
- Give user gpio overview of their board.
- Board information.
- Upload custom scripts via API.
- Run uploaded python scripts via API.
Planned Future Features
- System information.
- Network information.
- Test read from pin and update documentation.
- Secure API with credentials.
- Give option to change user password on system.
- Create a Electron for web interface for all platforms.
Raspberry Pi Dependencies (Raspbian Buster Lite)
curl -sL https://deb.nodesource.com/setup_10.x | bash -
sudo apt install nodejs
sudo apt install python3-rpi.gpio
sudo apt install python3-gpiozero
sudo apt install git
Installation
The npm package is created using the master branch of the repository.
NPM Install
Below is the dependencies for the Buster required for the API to work and then the npm package. The API can be run by entering rpi-express_api
in the terminal.
sudo apt install python3-rpi.gpio
sudo apt install python3-gpiozero
sudo npm i -g rpi-express_api
Development Install
This installs all required dependencies and then clones the repository for use.
curl -sL https://github.com/coenraadhuman/RPi-Express_API/blob/develop/dev.script.sh | bash -
Suggested Startup
It is recommended to use PM2, daemon process manager for node for starting the API on each boot.
Routes
Either use your IPV4 address / DNS name with your port and finally the default route (http://192.168.1.10:3000/rpi-express_api
) to access the routes below:
Route | Endpoint | Description |
---|---|---|
/ | GET | Will return pinout output for RPi information. |
/activate/:option/:gpio_number | GET | Will set the setup pin as either "bcm" or "board", then set gpio mode to out and finally set output to 1. |
/deactivate/:option/:gpio_number | GET | Will set the setup pin as either "bcm" or "board", then set gpio mode to out and finally set output to 0. |
/mode/:option/:gpio_number | GET | Will set the setup pin as either "bcm" or "board" and return gpio mode. |
/toggle/:option/:gpio_number | GET | Will set the setup pin as either "bcm" or "board", then set output to inverse of previous value. |
/imports | GET | Returns a list of available python user scripts. |
/imports/upload | GET | Returns html page for user to use to upload single or multiple python scripts. |
/imports/uploadfile | POST | Send a single file via to save for use with Pi via API. |
/imports/uploadfiles | POST | Send multiple files via to save for use with Pi via API. |
/imports/execute/python/:script-name-and-arguments | GET | Execute python script uploaded by user via API. No need to add extension ('.py') for file name and use %20 for spaces. |
/imports/execute/bash/:script-name-and-arguments | GET | Execute sh script uploaded by user via API. No need to add extension ('.sh') for file name and use %20 for spaces. |
GPIO modes include:
- GPIO.IN
- GPIO.OUT
- GPIO.SPI
- GPIO.I2C
- GPIO.HARD_PWM
- GPIO.SERIAL
- GPIO.UNKNOWN
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago