Skip to content

Getting Started

Kariem AbuAisheh edited this page Jun 14, 2024 · 39 revisions

Welcome to the GreenThumb usage guide! This page will help you understand how to use the GreenThumb application, including accessing various features and endpoints.

The Green Thumb Project (v1) is our initial version focused on promoting sustainable gardening. It includes community workshops, creating gardens, and a digital platform for gardening tips.

In the future, we plan to develop Green Thumb Project (v2). This new version will enhance and expand on v1 without changing the existing work. Improvements could include vertical gardening techniques, smart irrigation systems, and an upgraded digital platform with interactive forums and virtual garden tours.

By evolving the project, we aim to make sustainable gardening more accessible and efficient for all.

Accessing the Application

Once you have set up and started the application as described in the Home page, you can access it by using http://localhost:3000 in your postman or any API testing tool.

GUI Interface

We implemented a very simple GUI design to demonstrate our usage of the Mapbox external API and to show how server-side rendering works, we render our views on the server and send them back to the client. Server-side rendering is faster than client side, but it is not commonly used because it can become very complex and confusing for larger applications.

You can Login or Signup in the main screen

image

image

Users can see all available gardens in case they want to reserve a partnership or an event or just view its information.

image

Gardens are displayed as cards. When a garden is registered into the system, the owner must specify its longitude and latitude, so that it is shown in our Mapbox

image


API Endpoints

GreenThumb provides several RESTful API endpoints to interact with the system programmatically. Below are some of the key endpoints:


Note: for any GET request that is used to get All kind of data, such as get all resources, get all articles, get all partnerships etc... you can use our advanced filtering api as follows

/resource?sort=value&limit=value&value[operator]-value

example: GET /events?id=1 will get events that have id =1

GET /events?id[gt]=1 will get events that have id greater than 1

operators supported are: gt (greater than), gte (greater than or equal), It (less than), Ite (less than or equal)

GET /events?sort=id will get events and sort them Ascending by id, GET /events?sort=-id will get events and sort them Descending by id

GET /events?id[It]=2&limit=3 will return only 3 documents, with id less than 2


User Endpoints

  • Register a new user:
    • POST /GreenThumb/v1/users/signup
    • Request body:
{  
    "username": "Bdair2002",  
    "firstname": "Maohammad",  
    "lastname": "Bdair",  
    "email": "bdair@email.com",  
    "password": "12345",  
    "passwordconfirm": "12345"
}
  • Response:
{
    "status": "success",
    "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MSwiaWF0IjoxNzE4MzA1MzM5LCJleHAiOjE3MTgzOTE3Mzl9.eOyhzhykP_ZgzUcsNieJ_bSKqIEWjLXwQCpi5unEWDI",
    "data": {
        "user": {
            "role": "user",
            "id": 1,
            "username": "Bdair2002",
            "firstname": "Maohammad",
            "lastname": "Bdair",
            "email": "bdair@email.com",
            "updatedAt": "2024-06-13T19:02:18.532Z",
            "createdAt": "2024-06-13T19:02:18.532Z",
            "passwordChangedAt": 1718305337978
        }
    }
}
  • Login:
    • POST /GreenThumb/v1/users/login
    • Request body:
{
    "email": "bdair@email.com",
    "password": "12345"
}
  • Response :
{
    "status": "success",
    "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MSwiaWF0IjoxNzE4MzA1ODkwLCJleHAiOjE3MTgzOTIyOTB9.QyhaS-uGz1k0OkBA4QLkf6h_jWHQpmmZYkmQfRjFycE",
    "data": {
        "user": {
            "id": 1,
            "username": "Bdair2002",
            "firstname": "Maohammad",
            "lastname": "Bdair",
            "email": "bdair@email.com",
            "role": "user",
            "Event_ID": null,
            "createdAt": "2024-06-13T19:02:18.000Z",
            "updatedAt": "2024-06-13T19:02:18.000Z",
            "EventID": null
        }
    }
}
  • Forget Password:
    • POST /GreenThumb/v1/users/forgotPassword
    • Request body:
{"email" : "bdair@email.com"}
  • Response:
{
    "status": "success",
    "message": "Token sent to email!"
}
  • Reset Password:
    • POST /GreenThumb/v1/users/resetPassword/token
    • Request body:
{

    "password" : "123",
    "passwordconfirm": "123"
}
  • Response:
{
    "status": "success",
    "message": "Token sent to email!"
}

The followings work only if the user is logged in

  • Update Password:
    • POST /GreenThumb/v1/users/updatePassword
    • Request body:
{
    "passwordcurrent" : "12345"
    "password" : "123",
    "passwordconfirm": "123"
}
  • Get My information:
    • POST /GreenThumb/v1/users/me
    • Response:
{
    "status": "success",
    "data": {
        "data": {
            "id": 1,
            "username": "admin",
            "firstname": "adbo",
            "lastname": "last_name",
            "password": "$2b$12$/2CY3xyGIAg6Q2jhLZVhJ.uGsK1vzBp1o83demgxxC0UUql6uLZYK",
            "email": "admin@example.com",
            "role": "user",
            "Event_ID": null,
            "createdAt": "2024-06-13T21:36:18.000Z",
            "updatedAt": "2024-06-13T21:42:05.000Z",
            "EventID": null
        }
    }
}
  • Update My information:
    • POST /GreenThumb/v1/users/updateme
    • Request body
{
    "firstname":"adbo"
}
  • Response:
{
    "status": "success",
    "data": {
        "data": [
            1
        ]
    }
}
  • Delete My information:
    • Delete /GreenThumb/v1/users/deleteMe

The followings are only allowed for the admin

  • Get All Users
    • GET /GreenThumb/v1/users/
    • Response: All the users in the system

- **Get a specific user :**
  - `GET /GreenThumb/v1/users/id`
  - Response: 
```json
{
    "status": "success",
    "data": {
        "data": {
            "id": 1,
            "username": "admin",
            "firstname": "adbo",
            "lastname": "last_name",
            "password": "$2b$12$/2CY3xyGIAg6Q2jhLZVhJ.uGsK1vzBp1o83demgxxC0UUql6uLZYK",
            "email": "admin@example.com",
            "role": "user",
            "Event_ID": null,
            "createdAt": "2024-06-13T21:36:18.000Z",
            "updatedAt": "2024-06-14T08:22:44.000Z",
            "EventID": null
        }
    }
}
  • Update A user:
    • PATCH /GreenThumb/v1/users/1
    • Request body
{
    "firstname":"Ahmad"
}
  • Response:
{
    "status": "success",
    "data": {
        "data": [
            1
        ]
    }
}
  • Delete A User:
    • DELETE /GreenThumb/v1/users/1

Events Endpoints

  • Create an event:
    • POST /GreenThumb/v1/events/
    • request body:
{
    "Garden_ID": "5",
    "Volunteers":"2",
    "Description": "Cleaning Gardens"
}
  • Response:
{
    "status": "success",
    "data": {
        "data": {
            "id": 1,
            "Volunteers": "0",
            "Description": "Cleaning ",
            "updatedAt": "2024-06-14T08:33:00.671Z",
            "createdAt": "2024-06-14T08:33:00.671Z"
        }
    }
}
  • Get all events:
    • GET /GreenThumb/v1/events/
    • Request body: Empty
    • Response:
{
    "status": "success",
    "results": 2,
    "data": {
        "data": [
            {
                "id": 5,
                "Garden_ID": 5,
                "Volunteers": 2,
                "Description": "Cleaning Gardens",
                "createdAt": "2024-06-13T21:03:18.000Z",
                "updatedAt": "2024-06-13T22:09:13.000Z"
            },
            {
                "id": 6,
                "Garden_ID": 5,
                "Volunteers": 2,
                "Description": "Cleaning Gardens",
                "createdAt": "2024-06-13T21:15:17.000Z",
                "updatedAt": "2024-06-13T22:09:10.000Z"
            }
        ]
    }
}
  • Get events in a garden:
    • GET /GreenThumb/v1/events/garden/:id
    • Request body: Empty
    • Response:
[
    {
        "id": 5,
        "Garden_ID": 5,
        "Volunteers": 2,
        "Description": "Cleaning Gardens",
        "createdAt": "2024-06-13T21:03:18.000Z",
        "updatedAt": "2024-06-13T22:09:13.000Z"
    },
    {
        "id": 6,
        "Garden_ID": 5,
        "Volunteers": 2,
        "Description": "Cleaning Gardens",
        "createdAt": "2024-06-13T21:15:17.000Z",
        "updatedAt": "2024-06-13T22:09:10.000Z"
    }
]
  • Update an event:
    • PATCH /GreenThumb/v1/events/:id
    • request body:
{
    "Garden_ID": "5",
    "Volunteers":"2",
    "Description": "Cleaning Gardens"
}
  • Response: Status message

  • Delete an event:

    • DELETE /GreenThumb/v1/events/:id
    • Request body: Empty
    • Response: Status message

Resources Endpoints

  • Get all resources:
    • GET /GreenThumb/v1/resources/
    • Request body: Empty
    • Response:
{
    "status": "success",
    "results": 6,
    "data": {
        "data": [
            {
                "id": 20,
                "OwnerID": 1,
                "Tools": "machine 2",
                "Sold": false,
                "Description": "machine2 for sale",
                "createdAt": "2024-06-13T21:20:08.000Z",
                "updatedAt": "2024-06-13T21:20:08.000Z"
            },
            {
                "id": 21,
                "OwnerID": 1,
                "Tools": "machine 2",
                "Sold": false,
                "Description": "machine2 for sale",
                "createdAt": "2024-06-13T21:20:11.000Z",
                "updatedAt": "2024-06-13T21:20:11.000Z"
            },
            {
                "id": 22,
                "OwnerID": 1,
                "Tools": "machine 2",
                "Sold": false,
                "Description": "machine2 for sale",
                "createdAt": "2024-06-13T21:20:12.000Z",
                "updatedAt": "2024-06-13T21:20:12.000Z"
            },
            {
                "id": 23,
                "OwnerID": 1,
                "Tools": "machine 3",
                "Sold": false,
                "Description": "machine2 for sale",
                "createdAt": "2024-06-13T21:20:15.000Z",
                "updatedAt": "2024-06-13T21:20:15.000Z"
            },
            {
                "id": 24,
                "OwnerID": 1,
                "Tools": "Shovel",
                "Sold": true,
                "Description": "Shovel sold!",
                "createdAt": "2024-06-13T21:20:22.000Z",
                "updatedAt": "2024-06-13T21:30:11.000Z"
            },
            {
                "id": 25,
                "OwnerID": 1,
                "Tools": "machine 6",
                "Sold": false,
                "Description": "machine6 for sale",
                "createdAt": "2024-06-13T21:28:42.000Z",
                "updatedAt": "2024-06-13T21:28:42.000Z"
            },

        ]
    }
}
  • Create a resource:
    • PATCH /GreenThumb/v1/resources/
    • request body:
{ 
    "Tools": "machine 6",
    "Sold": "false",
    "Description": "machine6 for sale"
}
  • Response:
{
    "status": "success",
    "data": {
        "data": {
            "id": 25,
            "Tools": "machine 6",
            "Sold": false,
            "Description": "machine6 for sale",
            "OwnerID": 1,
            "updatedAt": "2024-06-13T22:36:10.258Z",
            "createdAt": "2024-06-13T22:36:10.258Z"
        }
    }
}
  • Update a resource:
    • PATCH /GreenThumb/v1/resources/:id
    • request body:
{
    "Tools": "Shovel",
    "Sold": "true",
    "Description": "Shovel sold!"
}
  • Response: Status message

  • Delete a resource:

    • DELETE /GreenThumb/v1/resources/:id
    • Request body: Empty
    • Response: Status message

Articles Endpoints

  • Get all articles:
    • GET /GreenThumb/v1/articles/
    • Request body: Empty
    • Response:
{
    "status": "success",
    "results": 2,
    "data": {
        "data": [
            {
                "id": 1,
                "Publisher_ID": 1,
                "Title": "Growing Conditions",
                "Description": "i followed the best growing conditions and my plots growed so fast!",
                "createdAt": "2024-06-13T22:27:12.000Z",
                "updatedAt": "2024-06-13T22:27:12.000Z"
            },
            {
                "id": 2,
                "Publisher_ID": 1,
                "Title": "Beware of Insects",
                "Description": "Insects can pose a threat to plants by spreading diseases and causing damage, so it's crucial to protect your plants from these pests.",
                "createdAt": "2024-06-13T22:30:50.000Z",
                "updatedAt": "2024-06-13T22:30:50.000Z"
            }
        ]
    }
}
  • Get articles by publisher:
    • GET /GreenThumb/v1/articles/publisher/:id
    • Request body: Empty
    • Response:
[
    {
        "id": 1,
        "Publisher_ID": 1,
        "Title": "Growing Conditions",
        "Description": "i followed the best growing conditions and my plots growed so fast!",
        "createdAt": "2024-06-13T22:27:12.000Z",
        "updatedAt": "2024-06-13T22:27:12.000Z"
    },
    {
        "id": 2,
        "Publisher_ID": 1,
        "Title": "Beware of Insects",
        "Description": "Insects can pose a threat to plants by spreading diseases and causing damage, so it's crucial to protect your plants.",
        "createdAt": "2024-06-13T22:30:50.000Z",
        "updatedAt": "2024-06-13T22:30:50.000Z"
    }
]
  • Create an article:
    • PATCH /GreenThumb/v1/articles/
    • request body:
{ 
    "Title": "Beware of Insects",
    "Description": "Insects can pose a threat to plants by spreading diseases and causing damage, so it's crucial to protect your plants."
}
  • Response:
{
    "status": "success",
    "data": {
        "data": {
            "id": 2,
            "Title": "Beware of Insects",
            "Description": "Insects can pose a threat to plants by spreading diseases and causing damage, so it's crucial to protect your plants",
            "Publisher_ID": 1,
            "updatedAt": "2024-06-13T22:30:50.912Z",
            "createdAt": "2024-06-13T22:30:50.912Z"
        }
    }
}
  • Update an article:
    • PATCH /GreenThumb/v1/articles/:id
    • request body:
{ 
    "Title": "i planted my last plot",
    "Description": "i planted carrot in my last plot i hope it grew well at the end of the season"
}
  • Response: Status message

  • Delete an article:

    • DELETE /GreenThumb/v1/articles/:id
    • Request body: Empty
    • Response: Status message

Gardens Endpoints

  • Add New Gardens:
    • POST /GreenThumb/v1/gardens/
    • Request body:
{
    "Name":"grenngardens1",
    "Location":"nublus",
    "Plots":3,
    "Sunlight":true,
    "SoilType":"red",
    "WaterSource":"test water source",
    "Latitude":"32.222668",
    "Longitude":"35.262146"
}
  • Response:
{
    "id": 13,
    "Name": "grenngardens1",
    "owner_id": 8,
    "Location": "nublus",
    "PlotsNumber": 3,
    "Sunlight": true,
    "SoilType": "red",
    "WaterSource": "test water source",
    "Latitude": "32.222668",
    "Longitude": "35.262146",
    "updatedAt": "2024-06-14T12:49:15.552Z",
    "createdAt": "2024-06-14T12:49:15.552Z"
}
  • Update Gardens:
    • PATCH /GreenThumb/v1/gardens/:Name
    • Request body:
{
    "NewName":"newgardens",
    "Location":"Tulkarm",
    "Sunlight":false,
    "SoilType":"reddd",
    "WaterSource":"test water source",
    "Latitude":"32.319199",
    "Longitude":"35.064320"
}
  • Response:
[
    1
]
  • GET All Gardens:
    • GET /GreenThumb/v1/gardens/
    • Request body: Empty
    • Response:
{
    "status": "success",
    "results": 5,
    "data": {
        "data": [
            {
                "id": 9,
                "Name": "grenn2",
                "owner_id": 5,
                "Location": "nublus",
                "PlotsNumber": 3,
                "Sunlight": true,
                "SoilType": "red",
                "WaterSource": "test water source",
                "Latitude": "32.222668",
                "Longitude": "35.262146",
                "createdAt": "2024-06-13T20:14:32.000Z",
                "updatedAt": "2024-06-13T20:14:32.000Z"
            },
            {
                "id": 10,
                "Name": "grenn3",
                "owner_id": 7,
                "Location": "nublus",
                "PlotsNumber": 3,
                "Sunlight": true,
                "SoilType": "red",
                "WaterSource": "test water source",
                "Latitude": "32.222668",
                "Longitude": "35.262146",
                "createdAt": "2024-06-13T20:53:26.000Z",
                "updatedAt": "2024-06-13T20:53:26.000Z"
            },
            {
                "id": 13,
                "Name": "grenngardens1",
                "owner_id": 8,
                "Location": "nublus",
                "PlotsNumber": 3,
                "Sunlight": true,
                "SoilType": "red",
                "WaterSource": "test water source",
                "Latitude": "32.222668",
                "Longitude": "35.262146",
                "createdAt": "2024-06-14T12:49:15.000Z",
                "updatedAt": "2024-06-14T12:49:15.000Z"
            }
        ]
    }
}
  • GET My Gardens:
    • GET /GreenThumb/v1/gardens/MyGardens
    • Request body: Empty
    • Response:
[
    {
        "id": 13,
        "Name": "grenngardens1",
        "owner_id": 8,
        "Location": "nublus",
        "PlotsNumber": 3,
        "Sunlight": true,
        "SoilType": "red",
        "WaterSource": "test water source",
        "Latitude": "32.222668",
        "Longitude": "35.262146",
        "createdAt": "2024-06-14T12:49:15.000Z",
        "updatedAt": "2024-06-14T12:49:15.000Z"
    }
]
  • GET Gardens By Name:
    • GET /GreenThumb/v1/gardens/:Name
    • Request body: Empty
    • Response:
{
    "id": 10,
    "Name": "grenn3",
    "owner_id": 7,
    "Location": "nublus",
    "PlotsNumber": 3,
    "Sunlight": true,
    "SoilType": "red",
    "WaterSource": "test water source",
    "Latitude": "32.222668",
    "Longitude": "35.262146",
    "createdAt": "2024-06-13T20:53:26.000Z",
    "updatedAt": "2024-06-13T20:53:26.000Z"
}
  • DElETE Gardens:
    • DElETE /GreenThumb/v1/gardens/:Name
    • Request body: Empty
    • Response: 204 Status message

Plots Endpoints

  • Plant The Plot:
    • POST /GreenThumb/v1/plots/:id/Crops/:Type
    • Request body: Empty
    • Response:
{
    "Crop_ID": 7,
    "Plot_ID": "10",
    "Garden_ID": 4,
    "Planting_Date": "2024-06-14T17:49:56.532Z",
    "Harvested": false,
    "Type": "mango",
    "updatedAt": "2024-06-14T17:49:56.578Z",
    "createdAt": "2024-06-14T17:49:56.578Z"
}
  • Harvest Plot:

    • PATCH /GreenThumb/v1/plots/:id/Crops
    • Request body: Empty
    • Response: 'Harvested Successfully'
  • Update Plot:

    • PATCH /GreenThumb/v1/plots/:id
    • Request body:
{
   
    "Crop":"orange",
    "Planting_Date":"2024-06-13 19:47:06"
    
}
  • Response:
[
    1
]
  • Get All Plots:
    • GET /GreenThumb/v1/plots
    • Request body: Empty
    • Response:
{
   "status": "success",
   "results": 1,
   "data": {
       "data": [
           {
               "Plot_ID": 10,
               "Garden_ID": 4,
               "Available": true,
               "Crop": null,
               "Planting_Date": null,
               "Harvested_Date": null,
               "createdAt": "2024-06-14T17:49:00.000Z",
               "updatedAt": "2024-06-14T17:49:00.000Z"
           }
       ]
   }
}
  • Get Plots By Garden Id:
    • GET /GreenThumb/v1/plots/garden/:id
    • Request body: Empty
    • Response:
[
    {
        "Plot_ID": 10,
        "Garden_ID": 4,
        "Available": false,
        "Crop": "orange",
        "Planting_Date": "2024-06-13T16:47:06.000Z",
        "Harvested_Date": "2024-06-14T17:50:48.000Z",
        "createdAt": "2024-06-14T17:49:00.000Z",
        "updatedAt": "2024-06-14T17:52:00.000Z"
    }
]
  • Get Plots By Id:
    • GET /GreenThumb/v1/plots/:id
    • Request body: Empty
    • Response:
{
    "Plot_ID": 10,
    "Garden_ID": 4,
    "Available": false,
    "Crop": "orange",
    "Planting_Date": "2024-06-13T16:47:06.000Z",
    "Harvested_Date": "2024-06-14T17:50:48.000Z",
    "createdAt": "2024-06-14T17:49:00.000Z",
    "updatedAt": "2024-06-14T17:52:00.000Z"
}
  • Delete Plot Using Id:

    • DELETE /GreenThumb/v1/plots/:id
    • Request body: Empty
    • Response: 'Respones 204 no content '
  • Get The Rotation Of The Plot:

    • GET /GreenThumb/v1/plots/1/Rotation
    • Request body: Empty
    • Response:
[
    {
        "Crop_ID": 8,
        "Garden_ID": 4,
        "Plot_ID": 10,
        "Type": "orange",
        "Harvested": false,
        "Planting_Date": "2024-06-13T16:47:06.000Z",
        "Harvested_Date": null,
        "createdAt": "2024-06-14T17:51:34.000Z",
        "updatedAt": "2024-06-14T17:52:00.000Z"
    },
    {
        "Crop_ID": 7,
        "Garden_ID": 4,
        "Plot_ID": 10,
        "Type": "mango",
        "Harvested": true,
        "Planting_Date": "2024-06-14T17:49:56.000Z",
        "Harvested_Date": "2024-06-14T17:50:48.000Z",
        "createdAt": "2024-06-14T17:49:56.000Z",
        "updatedAt": "2024-06-14T17:50:48.000Z"
    }
]

Crops Endpoints

  • Get /GreenThumb/v1/crops:
    • Request body: Empty
    • Response:
{
    "status": "success",
    "results": 2,
    "data": {
        "data": [
            {
                "Crop_ID": 9,
                "Garden_ID": 6,
                "Plot_ID": 11,
                "Type": "mango",
                "Harvested": true,
                "Planting_Date": "2024-06-14T17:57:41.000Z",
                "Harvested_Date": "2024-06-14T17:57:49.000Z",
                "createdAt": "2024-06-14T17:57:41.000Z",
                "updatedAt": "2024-06-14T17:57:49.000Z"
            },
            {
                "Crop_ID": 10,
                "Garden_ID": 6,
                "Plot_ID": 11,
                "Type": "apple",
                "Harvested": true,
                "Planting_Date": "2024-06-14T17:57:55.000Z",
                "Harvested_Date": "2024-06-14T17:57:57.000Z",
                "createdAt": "2024-06-14T17:57:55.000Z",
                "updatedAt": "2024-06-14T17:57:57.000Z"
            }
        ]
    }
}
  • Delete Crops:

    • DELETE /GreenThumb/v1/crops/:id
    • Request body: Empty
    • Response: 'Request 204 no content'
  • Update Crop:

    • PATCH /GreenThumb/v1/crops/:id
    • Request body:
{
    "garden_id":"6",
    "plot_id":"11",
    "Type":"orange",
    "harvest_date":"2024-06-13 19:47:06",
    "planting_date":"2024-06-13 19:47:06"

}
  • Response:
{
    "status": "success"
}
  • Get Crops By Garden Id:
    • GET /GreenThumb/v1/crops/garden/:id
    • Request body: Empty
    • Response:
[
    {
        "Crop_ID": 9,
        "Garden_ID": 6,
        "Plot_ID": 11,
        "Type": "mango",
        "Harvested": true,
        "Planting_Date": "2024-06-13T16:47:06.000Z",
        "Harvested_Date": "2024-06-13T16:47:06.000Z",
        "createdAt": "2024-06-14T17:57:41.000Z",
        "updatedAt": "2024-06-14T17:59:52.000Z"
    },
    {
        "Crop_ID": 10,
        "Garden_ID": 6,
        "Plot_ID": 11,
        "Type": "apple",
        "Harvested": true,
        "Planting_Date": "2024-06-14T17:57:55.000Z",
        "Harvested_Date": "2024-06-14T17:57:57.000Z",
        "createdAt": "2024-06-14T17:57:55.000Z",
        "updatedAt": "2024-06-14T17:57:57.000Z"
    }
]
  • Get Crops By Plot Id:
    • GET /GreenThumb/v1/crops/plot/:id
    • Request body: Empty
    • Response:
[
    {
        "Crop_ID": 9,
        "Garden_ID": 6,
        "Plot_ID": 11,
        "Type": "mango",
        "Harvested": true,
        "Planting_Date": "2024-06-13T16:47:06.000Z",
        "Harvested_Date": "2024-06-13T16:47:06.000Z",
        "createdAt": "2024-06-14T17:57:41.000Z",
        "updatedAt": "2024-06-14T17:59:52.000Z"
    },
    {
        "Crop_ID": 10,
        "Garden_ID": 6,
        "Plot_ID": 11,
        "Type": "apple",
        "Harvested": true,
        "Planting_Date": "2024-06-14T17:57:55.000Z",
        "Harvested_Date": "2024-06-14T17:57:57.000Z",
        "createdAt": "2024-06-14T17:57:55.000Z",
        "updatedAt": "2024-06-14T17:57:57.000Z"
    }
]

External API Endpoints

  • Get Weather Data:
    • GET /GreenThumb/v1/externalapi/weather/latlon
    • Request body:
{
    "id": 11
}
  • Response:
{
    "garden": {
        "owner_id": 8,
        "Location": "nublus",
        "Latitude": "32.222668",
        "Longitude": "35.262146"
    },
    "weather": {
        "cod": "200",
        "message": 0,
        "cnt": 40,
        "list": [
            {
                "dt": 1718366400,
                "main": {
                    "temp": 31.77,
                    "feels_like": 30.35,
                    "temp_min": 31.77,
                    "temp_max": 35.82,
                    "pressure": 1008,
                    "sea_level": 1008,
                    "grnd_level": 951,
                    "humidity": 28,
                    "temp_kf": -4.05
                },
                "weather": [
                    {
                        "id": 800,
                        "main": "Clear",
                        "description": "clear sky",
                        "icon": "01d"
                    }
                ],
                "clouds": {
                    "all": 0
                },
                "wind": {
                    "speed": 5.97,
                    "deg": 297,
                    "gust": 3.53
                },
                "visibility": 10000,
                "pop": 0,
                "sys": {
                    "pod": "d"
                },
                "dt_txt": "2024-06-14 12:00:00"
            },
            {
                "dt": 1718377200,
                "main": {
                    "temp": 32.12,
                    "feels_like": 30.84,
                    "temp_min": 32.12,
                    "temp_max": 32.81,
                    "pressure": 1008,
                    "sea_level": 1008,
                    "grnd_level": 950,
                    "humidity": 29,
                    "temp_kf": -0.69
                },
                "weather": [
                    {
                        "id": 800,
                        "main": "Clear",
                        "description": "clear sky",
                        "icon": "01d"
                    }
                ],
                "clouds": {
                    "all": 0
                },
                "wind": {
                    "speed": 4.19,
                    "deg": 297,
                    "gust": 4.94
                },
                "visibility": 10000,
                "pop": 0,
                "sys": {
                    "pod": "d"
                },
                "dt_txt": "2024-06-14 15:00:00"
            }
        ],
"city": {
            "id": 282615,
            "name": "Nablus",
            "coord": {
                "lat": 32.2227,
                "lon": 35.2621
            },
            "country": "PS",
            "population": 130326,
            "timezone": 10800,
            "sunrise": 1718332317,
            "sunset": 1718383603
        }
}
}
  • Get Climate Data:
    • GET /GreenThumb/v1/externalapi/weather/climate
    • Request body:
{
    "id": 11
}
  • Response:
{
    "garden": {
        "owner_id": 8,
        "Location": "nublus",
        "Latitude": "32.222668",
        "Longitude": "35.262146"
    },
    "weather": {
        "timelines": {
            "minutely": [
                {
                    "time": "2024-06-14T11:01:00Z",
                    "values": {
                        "cloudBase": null,
                        "cloudCeiling": null,
                        "cloudCover": 0,
                        "dewPoint": 18.38,
                        "freezingRainIntensity": 0,
                        "humidity": 34,
                        "precipitationProbability": 0,
                        "pressureSurfaceLevel": 944.35,
                        "rainIntensity": 0,
                        "sleetIntensity": 0,
                        "snowIntensity": 0,
                        "temperature": 36.88,
                        "temperatureApparent": 38.78,
                        "uvHealthConcern": 3,
                        "uvIndex": 8,
                        "visibility": 16,
                        "weatherCode": 1000,
                        "windDirection": 300.88,
                        "windGust": 6.31,
                        "windSpeed": 5.63
                    }
                },
                {
                    "time": "2024-06-14T11:02:00Z",
                    "values": {
                        "cloudBase": null,
                        "cloudCeiling": null,
                        "cloudCover": 0,
                        "dewPoint": 18.38,
                        "freezingRainIntensity": 0,
                        "humidity": 34.05,
                        "precipitationProbability": 0,
                        "pressureSurfaceLevel": 944.2,
                        "rainIntensity": 0,
                        "sleetIntensity": 0,
                        "snowIntensity": 0,
                        "temperature": 36.85,
                        "temperatureApparent": 38.74,
                        "uvHealthConcern": 3,
                        "uvIndex": 8,
                        "visibility": 16,
                        "weatherCode": 1000,
                        "windDirection": 300.88,
                        "windGust": 6.33,
                        "windSpeed": 5.63
                    }
                },
                {
                    "time": "2024-06-14T11:03:00Z",
                    "values": {
                        "cloudBase": null,
                        "cloudCeiling": null,
                        "cloudCover": 0,
                        "dewPoint": 18.38,
                        "freezingRainIntensity": 0,
                        "humidity": 34.1,
                        "precipitationProbability": 0,
                        "pressureSurfaceLevel": 944.06,
                        "rainIntensity": 0,
                        "sleetIntensity": 0,
                        "snowIntensity": 0,
                        "temperature": 36.82,
                        "temperatureApparent": 38.71,
                        "uvHealthConcern": 3,
                        "uvIndex": 8,
                        "visibility": 16,
                        "weatherCode": 1000,
                        "windDirection": 300.88,
                        "windGust": 6.34,
                        "windSpeed": 5.63
                    }
                }
            ]
        },
 "location": {
            "lat": 32.222668,
            "lon": 35.262146
        }
      }
   }
  • Get Garden Soil Data:
    • GET /GreenThumb/v1/externalapi/soil/latlon
    • Request body:
{
    "id": 11
}
  • Response:
{
    "garden": {
        "owner_id": 8,
        "Location": "nublus",
        "Latitude": "32.222668",
        "Longitude": "35.262146"
    },
    "soilData": {
        "type": "Feature",
        "geometry": {
            "type": "Point",
            "coordinates": [
                35.262146,
                32.222668
            ]
        },
        "properties": {
            "layers": [
                {
                    "name": "clay",
                    "unit_measure": {
                        "d_factor": 10,
                        "mapped_units": "g/kg",
                        "target_units": "%",
                        "uncertainty_unit": ""
                    },
                    "depths": [
                        {
                            "range": {
                                "top_depth": 0,
                                "bottom_depth": 5,
                                "unit_depth": "cm"
                            },
                            "label": "0-5cm",
                            "values": {
                                "mean": null,
                                "uncertainty": null
                            }
                        }
                    ]
                },
                {
                    "name": "sand",
                    "unit_measure": {
                        "d_factor": 10,
                        "mapped_units": "g/kg",
                        "target_units": "%",
                        "uncertainty_unit": ""
                    },
                    "depths": [
                        {
                            "range": {
                                "top_depth": 0,
                                "bottom_depth": 5,
                                "unit_depth": "cm"
                            },
                            "label": "0-5cm",
                            "values": {
                                "mean": null,
                                "uncertainty": null
                            }
                        }
                    ]
                }
            ]
        },
        "query_time_s": 0.3025691509246826
    }
}
  • Search Plants:
    • GET /GreenThumb/v1/externalapi/soil/plants
    • Request body:
{
  "plantName": "Sunflower"
}
  • Response:
{
    "data": [
        {
            "id": 21381,
            "common_name": "Sunflower",
            "slug": "helianthus-annuus",
            "scientific_name": "Helianthus annuus",
            "year": 1753,
            "bibliography": "Sp. Pl.: 904 (1753)",
            "author": "L.",
            "status": "accepted",
            "rank": "species",
            "family_common_name": "Aster family",
            "genus_id": 130,
            "image_url": "https://bs.plantnet.org/image/o/e92bdbc5adc4e91cc0c5aa8e9f102833a28bc6e3",
            "synonyms": [
                "Helianthus annuus var. pumilus",
                "Helianthus annuus var. convolutus",
                "Helianthus annuus var. apicalis",
                "Helianthus annuus var. basalis",
                "Helianthus aridus",
                "Helianthus annuus var. pallescens",
                "Helianthus annuus var. niger",
                "Helianthus annuus var. lenticularis",
                "Helianthus pumilus",
                "Helianthus annuus var. reversus",
                "Helianthus lenticularis var. aridus",
                "Helianthus annuus f. lenticularis",
                "Helianthus annuus var. latibasis",
                "Helianthus annuus var. tortuosus",
                "Helianthus annuus var. indicus",
                "Helianthus annuus subsp. texanus",
                "Helianthus annuus f. fallax",
                "Helianthus annuus var. semivinosus",
                "Helianthus annuus var. ruberrimus",
                "Helianthus annuus subsp. lenticularis",
                "Helianthus annuus var. vinosus",
                "Helianthus macrocarpus",
                "Helianthus petiolaris",
                "Helianthus ultiflorus",
                "Helianthus annuus var. aridus",
                "Helianthus erythrocarpus",
                "Helianthus annuus var. coronatus",
                "Helianthus annuus var. chrysanthemoides",
                "Helianthus indicus",
                "Helianthus annuus var. primulinus",
                "Helianthus aridus var. citrinus",
                "Helianthus annuus var. californicus",
                "Helianthus annuus var. passiflora",
                "Helianthus annuus var. macrocarpus",
                "Helianthus annuus var. revolutus",
                "Helianthus platycephalus",
                "Helianthus ovatus",
                "Helianthus jaegeri",
                "Helianthus annuus californicus",
                "Helianthus lenticularis var. primulinus",
                "Helianthus lenticularis var. angustus",
                "Helianthus lindheimerianus",
                "Helianthus annuus lenticularis",
                "Helianthus annuus subsp. jaegeri",
                "Helianthus annuus var. trizonatus",
                "Helianthus lenticularis",
                "Helianthus annuus var. flavobasis",
                "Helianthus annuus var. texanus",
                "Helianthus annuus var. dilutus",
                "Helianthus annuus f. silvester",
                "Helianthus annuus var. selene",
                "Helianthus annuus var. vinosissimus",
                "Helianthus grandiflorus"
            ],
            "genus": "Helianthus",
            "family": "Asteraceae",
            "links": {
                "self": "/api/v1/species/helianthus-annuus",
                "plant": "/api/v1/plants/helianthus-annuus",
                "genus": "/api/v1/genus/helianthus"
            }
        },
        {
            "id": 12566,
            "common_name": "Divergent sunflower",
            "slug": "helianthus-divaricatus",
            "scientific_name": "Helianthus divaricatus",
            "year": 1753,
            "bibliography": "Sp. Pl.: 906 (1753)",
            "author": "L.",
            "status": "accepted",
            "rank": "species",
            "family_common_name": "Aster family",
            "genus_id": 130,
            "image_url": "https://bs.plantnet.org/image/o/564e7c09244dcfbf336c5784f63ec99c3cdb1bb6",
            "synonyms": [
                "Helianthus divaricatus var. angustifolius",
                "Helianthus divaricatus var. latifolius",
                "Helianthus divaricatus var. scaberrimus",
                "Helianthus truncatus",
                "Helianthus divaricatus var. ternatus",
                "Helianthus leiostemon"
            ],
            "genus": "Helianthus",
            "family": "Asteraceae",
            "links": {
                "self": "/api/v1/species/helianthus-divaricatus",
                "plant": "/api/v1/plants/helianthus-divaricatus",
                "genus": "/api/v1/genus/helianthus"
            }
        },
    ],
    "links": {
        "self": "/api/v1/plants/search?q=Sunflower",
        "first": "/api/v1/plants/search?page=1&q=Sunflower",
        "next": "/api/v1/plants/search?page=2&q=Sunflower",
        "last": "/api/v1/plants/search?page=5&q=Sunflower"
    },
    "meta": {
        "total": 90
    }
}

Happy gardening with GreenThumb!