Skip to content

ClemRz/raspi-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Raspberry PI REST API

By Clément Ronzon. Licensed under MIT License.

This is a small REST API I wrote for a Raspberry Pi Zero W. I use it to dialogue with several home-made ESP8266-based IoT devices in my house.

Deployment with docker-compose

Requirements

Docker version 19.03.0+

Steps

Clone this repository on your machine:

$ git clone https://github.com/ClemRz/raspi-api.git
$ cd raspi-api

Make sure you rename src/.env.example to src/.env and fill in the information.

Launch the services:

$ sudo docker-compose up

Test the API: http://localhost:8081/api/--TODO--

API reference --TODO--

  • Protocol: REST
  • Endpoint: /
  • URL format: /api/device/{device ID}/entry
  • Methods: POST
  • Authentication: none
  • Mandatory fields:
    • device ID:
      • Description: ID of the device
      • Type: string
    • Body:
      • Type: JSON
      • Format: [["key1", "value1"],["key2", "value2"], ...]

Examples --TODO--

Request: /api/device/123abc/entry

Body: [["key1", "value1"],["key2", "value2"]]

Response:

{
   "status": "success"
}

Request: /api/device/123abc/entry

Body: [["key1", "value1"],["key2", "value2"

Response:

{
   "error": {
       "message": "Syntax error",
       "code": 4
   }
}

Troubleshooting

If you get a 404 or an empty array as a response of the API then maybe something went wrong during the setup.

When using docker-compose, the logs are mapped to the log folder at the root of the project (volume). There you will find Apache's logs.

About

REST API for Raspberry PI

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published