Fertilizantes
Los fertilizantes representan los productos nutricionales utilizados en los cultivos. Esta API permite gestionar el inventario, composicion nutricional y programas de fertilizacion.
La API de Fertilizantes es actualmente una implementacion mocked.
El modelo de Fertilizante
- Name
id- Type
- string
- Description
Identificador unico.
- Name
name- Type
- string
- Description
Nombre del producto.
- Name
brand- Type
- string
- Description
Marca comercial.
- Name
type- Type
- FertilizerType
- Description
Tipo de fertilizante.
- Name
nutrients- Type
- FertilizerNutrient[]
- Description
Nutrientes y porcentajes.
- Name
type- Type
- NutrientType
- Description
Tipo de nutriente.
- Name
percentage- Type
- number
- Description
Porcentaje en formula.
- Name
npk- Type
- object
- Description
Valores NPK.
- Name
nitrogen- Type
- number
- Description
Nitrogeno (N).
- Name
phosphorus- Type
- number
- Description
Fosforo (P).
- Name
potassium- Type
- number
- Description
Potasio (K).
- Name
organic- Type
- boolean
- Description
Si es organico.
- Name
concentration- Type
- number
- Description
Dosis recomendada (ml/L o g/L).
- Name
unit- Type
- string
- Description
Unidad de medida:
mlog.
- Name
stock- Type
- number
- Description
Cantidad en inventario.
- Name
stockUnit- Type
- string
- Description
Unidad de stock:
ml,g,L,kg.
- Name
recommendedStages- Type
- PlantStage[]
- Description
Etapas recomendadas de uso.
Ejemplo de fertilizante
{
"id": "fert-001",
"name": "Bio Grow",
"brand": "BioBizz",
"type": "GROW",
"nutrients": [
{ "type": "NITROGEN", "percentage": 4.0 },
{ "type": "PHOSPHORUS", "percentage": 3.0 },
{ "type": "POTASSIUM", "percentage": 6.0 }
],
"npk": {
"nitrogen": 4,
"phosphorus": 3,
"potassium": 6
},
"organic": true,
"concentration": 4,
"unit": "ml",
"stock": 1000,
"stockUnit": "ml",
"pricePerUnit": 0.02,
"recommendedStages": ["VEGETATIVE", "PRE_FLOWERING"],
"description": "Fertilizante organico para crecimiento vegetativo",
"instructions": "Usar 2-4ml por litro de agua",
"createdAt": "2024-01-15T10:00:00Z",
"updatedAt": "2024-10-01T14:30:00Z"
}
Tipos de Fertilizante (FertilizerType)
| Tipo | Descripcion | Uso |
|---|---|---|
BASE | Nutriente base | Todo el ciclo |
GROW | Crecimiento | Vegetativo |
BLOOM | Floracion | Floracion |
BOOSTER | Potenciador | Fases especificas |
SUPPLEMENT | Suplemento | Complementario |
MICRONUTRIENT | Micronutrientes | Deficiencias |
PH_ADJUSTER | Ajustador pH | Control pH |
ENZYME | Enzimas | Salud raices |
ROOT_STIMULATOR | Estimulador raices | Trasplantes |
FOLIAR | Foliar | Aplicacion hojas |
Tipos de Nutriente (NutrientType)
Macronutrientes Primarios
| Nutriente | Simbolo | Funcion |
|---|---|---|
NITROGEN | N | Crecimiento vegetativo |
PHOSPHORUS | P | Raices y floracion |
POTASSIUM | K | Salud general |
Macronutrientes Secundarios
| Nutriente | Simbolo | Funcion |
|---|---|---|
CALCIUM | Ca | Estructura celular |
MAGNESIUM | Mg | Clorofila |
SULFUR | S | Proteinas |
Micronutrientes
| Nutriente | Simbolo | Funcion |
|---|---|---|
IRON | Fe | Transporte oxigeno |
MANGANESE | Mn | Fotosintesis |
ZINC | Zn | Crecimiento |
COPPER | Cu | Enzimas |
BORON | B | Desarrollo floral |
MOLYBDENUM | Mo | Metabolismo N |
SILICON | Si | Resistencia |
Listar fertilizantes
Parametros de Consulta
- Name
type- Type
- FertilizerType
- Description
Filtrar por tipo.
- Name
brand- Type
- string
- Description
Filtrar por marca.
- Name
organic- Type
- boolean
- Description
Solo organicos.
- Name
stage- Type
- PlantStage
- Description
Filtrar por etapa recomendada.
- Name
search- Type
- string
- Description
Busqueda por nombre.
- Name
page- Type
- number
- Description
Pagina (default: 1).
- Name
limit- Type
- number
- Description
Items por pagina (default: 20).
Request
curl -G https://api.cannahub.tech/api/stock/fertilizers \
-H "Authorization: Bearer {token}" \
-d type=BLOOM \
-d organic=true
Response
{
"fertilizers": [...],
"count": 4,
"filters": { "type": "BLOOM", "organic": "true" }
}
Crear fertilizante
Registra un nuevo fertilizante en el inventario.
Campos Requeridos
- Name
name- Type
- string
- Description
Nombre del producto.
- Name
brand- Type
- string
- Description
Marca comercial.
- Name
type- Type
- FertilizerType
- Description
Tipo de fertilizante.
- Name
npk- Type
- object
- Description
Valores NPK (nitrogen, phosphorus, potassium).
- Name
organic- Type
- boolean
- Description
Si es organico.
- Name
unit- Type
- string
- Description
Unidad:
mlog.
- Name
stock- Type
- number
- Description
Cantidad inicial.
- Name
stockUnit- Type
- string
- Description
Unidad de stock.
Request
curl -X POST https://api.cannahub.tech/api/stock/fertilizers \
-H "Authorization: Bearer {token}" \
-H "Content-Type: application/json" \
-d '{
"name": "Top Max",
"brand": "BioBizz",
"type": "BOOSTER",
"npk": {
"nitrogen": 0,
"phosphorus": 1,
"potassium": 3
},
"organic": true,
"concentration": 4,
"unit": "ml",
"stock": 500,
"stockUnit": "ml",
"recommendedStages": ["FLOWERING"],
"description": "Potenciador organico de floracion"
}'
Response (201)
{
"fertilizer": {
"id": "fert-1698765432100",
"name": "Top Max",
"brand": "BioBizz",
"type": "BOOSTER",
"organic": true,
"stock": 500
}
}
Obtener fertilizante
Retorna los detalles de un fertilizante.
Request
curl https://api.cannahub.tech/api/stock/fertilizers/fert-001 \
-H "Authorization: Bearer {token}"
Actualizar fertilizante
Actualiza datos del fertilizante.
Campos Actualizables
- Name
stock- Type
- number
- Description
Cantidad en inventario.
- Name
pricePerUnit- Type
- number
- Description
Precio por unidad.
- Name
concentration- Type
- number
- Description
Dosis recomendada.
- Name
description- Type
- string
- Description
Descripcion.
- Name
instructions- Type
- string
- Description
Instrucciones de uso.
- Name
notes- Type
- string
- Description
Notas adicionales.
Request
curl -X PATCH https://api.cannahub.tech/api/stock/fertilizers/fert-001 \
-H "Authorization: Bearer {token}" \
-H "Content-Type: application/json" \
-d '{
"stock": 800,
"notes": "Restock 15/10/2024"
}'
Eliminar fertilizante
Elimina un fertilizante del inventario.
Request
curl -X DELETE https://api.cannahub.tech/api/stock/fertilizers/fert-001 \
-H "Authorization: Bearer {token}"
Programa de Fertilizacion
Obtiene recomendaciones de fertilizacion por etapa del cultivo.
Parametros de Consulta
- Name
stage- Type
- PlantStage
- Description
Etapa especifica (devuelve todas si no se especifica).
Respuesta
Retorna un programa con fertilizantes recomendados, dosis y frecuencia para cada etapa.
Request
curl -G https://api.cannahub.tech/api/stock/fertilizers/schedule \
-H "Authorization: Bearer {token}" \
-d stage=FLOWERING
Response
{
"schedules": [
{
"stage": "FLOWERING",
"fertilizers": [
{
"fertilizer": {
"id": "fert-002",
"name": "Bio Bloom",
"brand": "BioBizz",
"type": "BLOOM"
},
"dosage": 4,
"unit": "ml/L",
"frequency": "every_other_day"
},
{
"fertilizer": {
"id": "fert-003",
"name": "Top Max",
"brand": "BioBizz",
"type": "BOOSTER"
},
"dosage": 4,
"unit": "ml/L",
"frequency": "weekly"
}
],
"notes": "Reducir N, aumentar P-K"
}
],
"totalStages": 1
}
Guia NPK por Etapa
Ratios NPK recomendados segun etapa del cultivo:
| Etapa | N | P | K | Notas |
|---|---|---|---|---|
| Germinacion | 0 | 0 | 0 | Solo agua |
| Plantula | 2 | 1 | 2 | Muy diluido |
| Vegetativo | 3 | 1 | 2 | Alto N |
| Pre-floracion | 2 | 2 | 2 | Transicion |
| Floracion temprana | 1 | 2 | 2 | Reducir N |
| Floracion media | 0 | 3 | 3 | Alto P-K |
| Floracion tardia | 0 | 2 | 3 | Enfasis K |
| Lavado | 0 | 0 | 0 | Solo agua |
Sintomas de Deficiencias
| Nutriente | Sintoma | Solucion |
|---|---|---|
| Nitrogeno | Hojas amarillas (bajas) | Fertilizante alto N |
| Fosforo | Hojas purpuras, crecimiento lento | Fertilizante alto P |
| Potasio | Bordes quemados | Fertilizante alto K |
| Calcio | Manchas marrones | CalMag |
| Magnesio | Amarillamiento intervenal | Epsom salt |
| Hierro | Clorosis en hojas nuevas | Quelato de hierro |
React Query Hooks
Uso de hooks
import {
useFertilizersQuery,
useFertilizerQuery,
useCreateFertilizerMutation,
useUpdateFertilizerMutation,
useDeleteFertilizerMutation
} from '@/features/Club/Fertilizers/hooks'
// Listar fertilizantes con filtros
const { data: fertilizers, isLoading } = useFertilizersQuery({
type: 'BLOOM',
organic: true
})
// Obtener un fertilizante
const { data: fertilizer } = useFertilizerQuery('fert-001')
// Crear fertilizante
const createMutation = useCreateFertilizerMutation()
await createMutation.mutateAsync({
name: 'Bio Bloom',
brand: 'BioBizz',
type: 'BLOOM',
npk: { nitrogen: 2, phosphorus: 6, potassium: 3.5 },
organic: true,
unit: 'ml',
stock: 1000,
stockUnit: 'ml',
nutrients: ['PHOSPHORUS', 'POTASSIUM'],
recommendedStages: ['FLOWERING']
})
// Actualizar fertilizante
const updateMutation = useUpdateFertilizerMutation()
await updateMutation.mutateAsync({
id: 'fert-001',
data: { stock: 800 }
})
// Eliminar fertilizante
const deleteMutation = useDeleteFertilizerMutation()
await deleteMutation.mutateAsync('fert-001')
Query Keys
fertilizerKeys = {
all: ['fertilizers'],
lists: () => ['fertilizers', 'list'],
list: (filters) => ['fertilizers', 'list', filters],
details: () => ['fertilizers', 'detail'],
detail: (id) => ['fertilizers', 'detail', id]
}