npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

pi-arest

v1.6.3

Published

Implementation of the aREST API for the Raspberry Pi

Downloads

17

Readme

pi-aREST

Version 1.6.2

Overview

A simple Node.js package that implements a REST API for the Raspberry Pi.

It is designed to be universal and currently supports REST calls via HTTP, either using Ethernet or WiFi.

Raspberry Pi boards running aREST can also be accessed from anywhere in the world via an API available at cloud.arest.io. Check the rest of this file and the cloud example for more details.

If you want to know more about aREST, go over to http://arest.io/.

Contents

  • index.js: the package file.
  • examples: several examples using the pi-aREST package

Supported hardware

The library is at the moment compatible with all the Raspberry Pi boards, including the Raspberry Pi 3 and Raspberry Pi Zero.

Requirements

To use the library with your Raspberry Pi board, you will need to have Node.js installed on your Pi. You can find the procedure to install Node.js your Pi at:

https://learn.adafruit.com/node-embedded-development/installing-node-dot-js

Once this is done, you can install pi-aREST in your project with:

sudo npm install pi-arest --unsafe-perm

Quick test (Ethernet/WiFi)

  1. Connect a LED & resistor to pin number 7 of your Raspberry Pi board (GPIO4)
  2. Open the basic example sketch
  3. Install the express module with: sudo npm install express
  4. Start pi-aREST with sudo basic.js
  5. Get the IP address of your board with ifconfig
  6. Go to a web browser and type rpi_ip_address/digital/7/1 and the LED should turn on

Cloud Access quick test (Ethernet/WiFi)

  1. Connect a LED & resistor to pin number 7 of your Raspberry Pi board (GPIO4)
  2. Open the cloud example sketch
  3. Modify the sketch with an unique ID for your board
  4. Install the express module with: sudo npm install express
  5. Start pi-aREST with sudo cloud.js
  6. Go to a web browser and type cloud.arest.io/board_id/digital/7/1 and the LED should turn on

API documentation

The API currently supports three type of commands: digital, variables, and functions.

Digital

Digital is to write or read on digital pins on the Raspberry Pi. For example:

  • /digital/8/0 sets pin number 8 to a low state
  • /digital/8/1 sets pin number 8 to a high state
  • /digital/8 reads value from pin number 8 in JSON format (note that for compatibility reasons, /digital/8/r produces the same result)

Variables

You can also directly call variables that are defined in your Node.js application.

To access a variable in your sketch, you have to declare it first, and then call it with a REST call. For example, if your aREST instance is called "piREST" and the variable "temperature":

  • piREST.variable("temperature",temperature); declares the temperature in the Node.js application
  • /temperature returns the value of the variable in JSON format

Functions

You can also directly call functions that are defined in your Node.js application.

To access a function in your sketch, you have to declare it first, and then call it with a REST call. For example, if your aREST instance is called "piREST" and the function "motor":

  • piREST.function("motor",motor); declares the function in the Node.js application
  • /motor executes the function

Get data about the board

You can also access a description of all the variables that were declared on the board with a single command. This is useful to automatically build graphical interfaces based on the variables exposed to the API. This can be done via the following calls:

  • / or /id
  • The names & types of the variables will then be stored in the variables field of the returned JSON object