Introduction
API documentation for hydroponic operations and performance tracking
This documentation aims to provide all the information you need to work with our Hydroponic Farm Operations API.
<aside>As you scroll, you'll see code examples for working with the API in different programming languages in the dark area to the right (or as part of the content on mobile).
You can switch the language used with the tabs at the top right (or from the nav menu at the top left on mobile).</aside>
Authenticating requests
To authenticate requests, include an Authorization header with the value "Bearer {YOUR_JWT_TOKEN}".
All authenticated endpoints are marked with a requires authentication badge in the documentation below.
You can retrieve your JWT token by logging in via the /api/login endpoint.
Authentication
APIs for user authentication
Login
Authenticate a user and return JWT tokens.
Example request:
curl --request POST \
"http://localhost/api/login" \
--header "Content-Type: application/json" \
--header "Accept: application/json" \
--data "{
\"email\": \"admin@example.com\",
\"password\": \"password\"
}"
const url = new URL(
"http://localhost/api/login"
);
const headers = {
"Content-Type": "application/json",
"Accept": "application/json",
};
let body = {
"email": "admin@example.com",
"password": "password"
};
fetch(url, {
method: "POST",
headers,
body: JSON.stringify(body),
}).then(response => response.json());Example response (200):
{
"user": {
"id": "uuid",
"name": "Admin User",
"role": "SUPER_ADMIN",
"email": "admin@example.com",
"farm_id": null,
"permissions": []
},
"access_token": "jwt-token",
"token_type": "bearer",
"expires_in": 3600
}
Example response (401):
{
"error": "Invalid credentials"
}
Received response:
Request failed with error:
Tip: Check that you're properly connected to the network.
If you're a maintainer of ths API, verify that your API is running and you've enabled CORS.
You can check the Dev Tools console for debugging information.
Register
requires authentication
Register a new user.
Example request:
curl --request POST \
"http://localhost/api/register" \
--header "Authorization: Bearer {YOUR_JWT_TOKEN}" \
--header "Content-Type: application/json" \
--header "Accept: application/json" \
--data "{
\"name\": \"John Doe\",
\"email\": \"john@example.com\",
\"password\": \"password123\",
\"role\": \"FARMER\",
\"farm_id\": \"uuid\",
\"permissions\": [
\"consequatur\"
]
}"
const url = new URL(
"http://localhost/api/register"
);
const headers = {
"Authorization": "Bearer {YOUR_JWT_TOKEN}",
"Content-Type": "application/json",
"Accept": "application/json",
};
let body = {
"name": "John Doe",
"email": "john@example.com",
"password": "password123",
"role": "FARMER",
"farm_id": "uuid",
"permissions": [
"consequatur"
]
};
fetch(url, {
method: "POST",
headers,
body: JSON.stringify(body),
}).then(response => response.json());Example response (201):
{
"id": "uuid",
"name": "John Doe",
"email": "john@example.com",
"role": "FARMER",
"permissions": []
}
Received response:
Request failed with error:
Tip: Check that you're properly connected to the network.
If you're a maintainer of ths API, verify that your API is running and you've enabled CORS.
You can check the Dev Tools console for debugging information.
Refresh token
requires authentication
Refresh the JWT token.
Example request:
curl --request POST \
"http://localhost/api/refresh" \
--header "Authorization: Bearer {YOUR_JWT_TOKEN}" \
--header "Content-Type: application/json" \
--header "Accept: application/json"const url = new URL(
"http://localhost/api/refresh"
);
const headers = {
"Authorization": "Bearer {YOUR_JWT_TOKEN}",
"Content-Type": "application/json",
"Accept": "application/json",
};
fetch(url, {
method: "POST",
headers,
}).then(response => response.json());Example response (200):
{
"access_token": "new-jwt-token",
"token_type": "bearer",
"expires_in": 3600
}
Received response:
Request failed with error:
Tip: Check that you're properly connected to the network.
If you're a maintainer of ths API, verify that your API is running and you've enabled CORS.
You can check the Dev Tools console for debugging information.
Logout
requires authentication
Invalidate the user's token.
Example request:
curl --request POST \
"http://localhost/api/logout" \
--header "Authorization: Bearer {YOUR_JWT_TOKEN}" \
--header "Content-Type: application/json" \
--header "Accept: application/json"const url = new URL(
"http://localhost/api/logout"
);
const headers = {
"Authorization": "Bearer {YOUR_JWT_TOKEN}",
"Content-Type": "application/json",
"Accept": "application/json",
};
fetch(url, {
method: "POST",
headers,
}).then(response => response.json());Example response (200):
{
"message": "Successfully logged out"
}
Received response:
Request failed with error:
Tip: Check that you're properly connected to the network.
If you're a maintainer of ths API, verify that your API is running and you've enabled CORS.
You can check the Dev Tools console for debugging information.
Get current user
requires authentication
Get the authenticated user's information.
Example request:
curl --request GET \
--get "http://localhost/api/me" \
--header "Authorization: Bearer {YOUR_JWT_TOKEN}" \
--header "Content-Type: application/json" \
--header "Accept: application/json"const url = new URL(
"http://localhost/api/me"
);
const headers = {
"Authorization": "Bearer {YOUR_JWT_TOKEN}",
"Content-Type": "application/json",
"Accept": "application/json",
};
fetch(url, {
method: "GET",
headers,
}).then(response => response.json());Example response (200):
{
"id": "uuid",
"name": "Admin User",
"email": "admin@example.com",
"role": "SUPER_ADMIN",
"farm_id": null,
"permissions": []
}
Received response:
Request failed with error:
Tip: Check that you're properly connected to the network.
If you're a maintainer of ths API, verify that your API is running and you've enabled CORS.
You can check the Dev Tools console for debugging information.
Farms
APIs for managing farms
List farms
requires authentication
Get a list of all farms.
Example request:
curl --request GET \
--get "http://localhost/api/farms" \
--header "Authorization: Bearer {YOUR_JWT_TOKEN}" \
--header "Content-Type: application/json" \
--header "Accept: application/json"const url = new URL(
"http://localhost/api/farms"
);
const headers = {
"Authorization": "Bearer {YOUR_JWT_TOKEN}",
"Content-Type": "application/json",
"Accept": "application/json",
};
fetch(url, {
method: "GET",
headers,
}).then(response => response.json());Example response (200):
[
{
"id": "uuid",
"name": "Farm 1",
"status": "ACTIVE",
"location": "Location 1",
"created_at": "2023-01-01T00:00:00.000000Z",
"updated_at": "2023-01-01T00:00:00.000000Z"
}
]
Received response:
Request failed with error:
Tip: Check that you're properly connected to the network.
If you're a maintainer of ths API, verify that your API is running and you've enabled CORS.
You can check the Dev Tools console for debugging information.
Create farm
requires authentication
Create a new farm.
Example request:
curl --request POST \
"http://localhost/api/farms" \
--header "Authorization: Bearer {YOUR_JWT_TOKEN}" \
--header "Content-Type: application/json" \
--header "Accept: application/json" \
--data "{
\"name\": \"New Farm\",
\"status\": \"ACTIVE\",
\"location\": \"City, Country\"
}"
const url = new URL(
"http://localhost/api/farms"
);
const headers = {
"Authorization": "Bearer {YOUR_JWT_TOKEN}",
"Content-Type": "application/json",
"Accept": "application/json",
};
let body = {
"name": "New Farm",
"status": "ACTIVE",
"location": "City, Country"
};
fetch(url, {
method: "POST",
headers,
body: JSON.stringify(body),
}).then(response => response.json());Example response (201):
{
"id": "uuid",
"name": "New Farm",
"status": "ACTIVE",
"location": "City, Country",
"created_at": "2023-01-01T00:00:00.000000Z",
"updated_at": "2023-01-01T00:00:00.000000Z"
}
Received response:
Request failed with error:
Tip: Check that you're properly connected to the network.
If you're a maintainer of ths API, verify that your API is running and you've enabled CORS.
You can check the Dev Tools console for debugging information.
Get farm
requires authentication
Get a specific farm by ID.
Example request:
curl --request GET \
--get "http://localhost/api/farms/uuid" \
--header "Authorization: Bearer {YOUR_JWT_TOKEN}" \
--header "Content-Type: application/json" \
--header "Accept: application/json"const url = new URL(
"http://localhost/api/farms/uuid"
);
const headers = {
"Authorization": "Bearer {YOUR_JWT_TOKEN}",
"Content-Type": "application/json",
"Accept": "application/json",
};
fetch(url, {
method: "GET",
headers,
}).then(response => response.json());Example response (200):
{
"id": "uuid",
"name": "Farm 1",
"status": "ACTIVE",
"location": "Location 1",
"created_at": "2023-01-01T00:00:00.000000Z",
"updated_at": "2023-01-01T00:00:00.000000Z"
}
Received response:
Request failed with error:
Tip: Check that you're properly connected to the network.
If you're a maintainer of ths API, verify that your API is running and you've enabled CORS.
You can check the Dev Tools console for debugging information.
Update farm
requires authentication
Update a specific farm.
Example request:
curl --request PUT \
"http://localhost/api/farms/uuid" \
--header "Authorization: Bearer {YOUR_JWT_TOKEN}" \
--header "Content-Type: application/json" \
--header "Accept: application/json" \
--data "{
\"name\": \"Updated Farm\",
\"status\": \"MAINTENANCE\",
\"location\": \"New City\"
}"
const url = new URL(
"http://localhost/api/farms/uuid"
);
const headers = {
"Authorization": "Bearer {YOUR_JWT_TOKEN}",
"Content-Type": "application/json",
"Accept": "application/json",
};
let body = {
"name": "Updated Farm",
"status": "MAINTENANCE",
"location": "New City"
};
fetch(url, {
method: "PUT",
headers,
body: JSON.stringify(body),
}).then(response => response.json());Example response (200):
{
"id": "uuid",
"name": "Updated Farm",
"status": "MAINTENANCE",
"location": "New City",
"created_at": "2023-01-01T00:00:00.000000Z",
"updated_at": "2023-01-01T00:00:00.000000Z"
}
Received response:
Request failed with error:
Tip: Check that you're properly connected to the network.
If you're a maintainer of ths API, verify that your API is running and you've enabled CORS.
You can check the Dev Tools console for debugging information.
Delete farm
requires authentication
Delete a specific farm.
Example request:
curl --request DELETE \
"http://localhost/api/farms/uuid" \
--header "Authorization: Bearer {YOUR_JWT_TOKEN}" \
--header "Content-Type: application/json" \
--header "Accept: application/json"const url = new URL(
"http://localhost/api/farms/uuid"
);
const headers = {
"Authorization": "Bearer {YOUR_JWT_TOKEN}",
"Content-Type": "application/json",
"Accept": "application/json",
};
fetch(url, {
method: "DELETE",
headers,
}).then(response => response.json());Example response (200):
{
"message": "Farm deleted"
}
Received response:
Request failed with error:
Tip: Check that you're properly connected to the network.
If you're a maintainer of ths API, verify that your API is running and you've enabled CORS.
You can check the Dev Tools console for debugging information.