Giter Club home page Giter Club logo

dht22-api's Introduction

Table of Contents

  1. dht22-API
  2. Requirements
  3. Setup
  4. GET and POST requests description
    1. GET request
    2. POST request

dht22-API

A simple API written in Go for the temperature and humidity dht22 sensor. It supports GET and POST requests

Requirements

  • Go 1.14 or higher
  • MongoDB
  • mongo-go-driver

OR

  • docker
  • docker-compose

Setup

Due to a license issue many Linux distributions removed MongoDB from their official repositories, as result it is easier to set up the project with Docker rather than compiling MongoDB ourselves.

  1. Install docker and docker-compose on Arch based distributions

    $ pacman -S docker docker-compose
    
  2. Get the source code

    $ git clone [email protected]:KNaiskes/dht22-API.git
    $ cd dht22-API
    
  3. Run project

    1. Start docker

      $ sudo systemctl start docker
      
    2. Run project

      It will take some time the first time you run this command as it will have to pull the Go and MongoDB images

      $ docker-compose up # You may have to run this command with sudo
      

      Visit localhost:8080/measurements to verify that everything work as they should, you are expected to see an empty list

GET and POST requests description

GET request

Path Result
/measurements Returns a list with all measurements or an empty list
/measurements/{id} Returns the one measurement with the specified {id} or 404
/measurements/{name} Returns all measurements from the sensor with the specified {name} or an empty list

POST request

POST request consists of three optional parameters (id is assigned automatically by the server).

Example of POST request with cURL

curl -d '{

    "name":"basement",
    "temperature":"17.25",
    "humidity":"21.33"

}' -H "Content-Type: application/json" -X POST http://localhost:8080/measurements

dht22-api's People

Contributors

dependabot[bot] avatar knaiskes avatar

Watchers

 avatar

Forkers

dt021

dht22-api's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.