Git Product home page Git Product logo

onbo-assign's Introduction

Climate Change API

The Climate Change API is a Node.js Express backend that allows you to manage climate data and calculate climate change based on various parameters such as temperature, humidity, and chances of rain. This README provides instructions on setting up and running the API.

Table of Contents

Getting Started

These instructions will help you set up and run the Climate Change API on your local machine for development and testing purposes.

Prerequisites

Before getting started, make sure you have the following software installed on your system:

Installation

  1. Clone this repository to your local machine:

    git clone https://github.com/your-username/climate-change-api.git
  2. Install all the dependencies:

    npm i
  3. Create a .env file in the project root and set your environment variables. You can use .env.example as a template.

  4. Start the server:

    npm start

    The server will be running on http://localhost:5000 or at the port you have specified in the .env file.

API Endpoints

1. Save Climate Data

  • URL: /api/climate-data/add-data
  • Method: POST
  • Payload:
    {
    "climate": "hot" | "humid" | "rainy" | "cold",
    "area_code": 111,
    "temperature": 25,
    "humidity": 88,
    "chances_of_rain": 40
    }
  • Response:
    {
    "success": true | false,
    "error": "If success is false, this will be set else it will be null and it's value would be the reason why the saving of data failed",
    "data": {
        "id": "any_random_unique_id"
    }
    }

2. Fetch All Saved Records

  • URL: /api/climate-data
  • Method: GET
  • Response: An array of climate data records

3. Fetch Records of a Particular Area

  • URL: /api/climate-data/area/:area_code
  • Method: GET
  • Response: An array of climate data records for the specified area code

4. Fetch Records of a Particular Climate of a Particular Area

  • URL: /api/climate-data/area/:area_code/climate/:climate
  • Method: GET
  • Response: An array of climate data records for the specified area code and climate

5. Calculate Climate Change

  • URL: /api/climate-data/climate-change

  • Method: POST

  • Payload:

    {
    "from_climate": "hot" | "humid" | "rainy" | "cold",
    "to_climate": "hot" | "humid" | "rainy" | "cold",
    "area_code": xxx
    }
  • Response:

    {
    "climateDelta": "hot -> cold",
    "temperatureDelta": -67,
    "humidityDelta": 79,
    "rainChancesDelta": 20,
    "climateChangeIndex": "(delta Temp * delta Humidity)/delta rainChances"
    }

Please replace xxx with the actual area code you want to use when hitting the endpoints.

Seeding Data

To seed data for testing, you can run the seed.js script:

node seed.js

This will insert sample data into your database.

onbo-assign's People

Contributors

pcoder23 avatar

Watchers

 avatar

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.