0.1.12 • Published 4 years ago

rpi-express_api v0.1.12

Weekly downloads
-
License
GPL-3.0
Repository
github
Last release
4 years ago

github issues github forks github stars github licence npm version npm dependecies npm devDependencies

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:

RouteEndpointDescription
/GETWill return pinout output for RPi information.
/activate/:option/:gpio_numberGETWill set the setup pin as either "bcm" or "board", then set gpio mode to out and finally set output to 1.
/deactivate/:option/:gpio_numberGETWill set the setup pin as either "bcm" or "board", then set gpio mode to out and finally set output to 0.
/mode/:option/:gpio_numberGETWill set the setup pin as either "bcm" or "board" and return gpio mode.
/toggle/:option/:gpio_numberGETWill set the setup pin as either "bcm" or "board", then set output to inverse of previous value.
/importsGETReturns a list of available python user scripts.
/imports/uploadGETReturns html page for user to use to upload single or multiple python scripts.
/imports/uploadfilePOSTSend a single file via to save for use with Pi via API.
/imports/uploadfilesPOSTSend multiple files via to save for use with Pi via API.
/imports/execute/python/:script-name-and-argumentsGETExecute 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-argumentsGETExecute 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
0.1.12

4 years ago

0.1.10

4 years ago

0.1.11

4 years ago

0.1.9

4 years ago

0.1.8

4 years ago

0.1.7

4 years ago

0.1.6

4 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.0.10

5 years ago

0.0.9

5 years ago

0.0.8

5 years ago

0.0.7

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago