Skip to main content

Rotations

Introduction

Rotations or Crop Organiser is a functionality within the management module that allows to assign crops per field in a quick and easy way without the need to generate a sowing record. Through this functionality, users have the possibility to register detailed information about the crop, such as the variety sown, the number of hectares to be sown, the estimated yield and other relevant details.

APIs

GET

List of all rotations for fields that the user has permissions for, across all campaigns.

Content-Type: text/plain
GET /api/rotations

The query string can include the following parameters, which apply an AND condition for filtering:

  • yeargroup: number, receives the year in which you want to search for the rotations (2022, 2023, etc.).
  • farms_id: integer, receives one or more field IDs separated by commas.

Response example:

[{
"farm_uuid": "25b02307-3da4-4d61-845a-45921715fd40",
"varieties": null,
"end_date": "2023-06-01T03:00:00Z",
"yeargroup": 2022,
"start_date": "2023-01-01T03:00:00Z",
"farm_id": 90677,
"field_id": 321961,
"crop_id": 1339,
"field_uuid": "d9f0c738-115f-4500-8a38-57244527418a",
"crop_name": "Maíz 2°",
"cicle_id": 82531,
"rotation_uuid": "334f581a-ee8b-4608-ada6-c4618e89e713",
"yield_crop": null,
"ha": null,
"field_name": "Test Field",
"crop_order": 1,
"metadata": null
},
{
"farm_uuid": "25b02307-3da4-4d61-845a-45921715fd40",
"varieties": null,
"end_date": "2023-10-18T03:00:00Z",
"yeargroup": 2022,
"start_date": "2023-01-12T03:00:00Z",
"farm_id": 90677,
"field_id": 321961,
"crop_id": 13,
"field_uuid": "d9f0c738-115f-4500-8a38-57244527418a",
"crop_name": "Maíz",
"cicle_id": 82531,
"rotation_uuid": "13483f90-5f19-462e-9c92-8df60ee16d6b",
"yield_crop": null,
"ha": null,
"field_name": "Test Field",
"crop_order": 2,
"metadata": null
}]

POST

Content-Type: application/json
POST /rotations

In the request body, include an array of objects representing each rotation to be created. Each object must include:

  • field_id: number (required), the field's ID to associate the rotation with.
  • crop_id: number(required), the crop's ID.
  • yeargroup: number(required), the year in which the rotation is to be defined.
  • ha: number, hectares over which the rotation is to be defined.
  • start_date: datetime(required), the rotation's start date [format YYYY-MM-DDTHH:mm:ssZ].
  • end_date: datetime(required), the rotation's end date [format YYYY-MM-DDTHH:mm:ssZ].

Response:

The API responds with two lists: one for the rotations created and another for those that couldn't be created.

Response example:

{
"data": {
"created_ones": [
{
"end_date": null,
"yeargroup": 2022,
"field_id": 258388,
"crop_id": 6,
"crop_name": null,
"cicle_id": 65805,
"start_date": null,
"ha": null,
"crop_order": 4,
"rotation_uuid": "b11f12b1-3265-4756-b18b-45de101da547"
}
],

"unabled_to_be_created": [
{
"varieties": null,
"end_date": "2024-02-01T00:00:00Z",
"yeargroup": 2023,
"start_date": "2023-11-01T00:00:00Z",
"field_id": 321961,
"reason": {
"error_code": -11,
"error_msg": "User is not allowed to perform this action"
},
"crop_id": 2,
"field_uuid": null,
"crop_name": null,
"cicle_id": null,
"rotation_uuid": null,
"yield_crop": null,
"ha": null,
"crop_order": null,
"metadata": null
}
]
}
}

PATCH

Content-Type: application/json
PATCH: /rotations/{rotation_uuid}

Certain aspects of a rotation can be modified:

  • ha
  • crop_id
  • start_date
  • end_date

Example request body:

PATCH /rotations/898430ea-fc6f-4a46-a7c6-9890ea702a41
{
"ha": 140,
"start_date":"2022-08-09 21:00:00.000",
"end_date": "2023-01-09 21:00:00.000",
"crop_id": 6
}

Response example:

Status: 200 OK
{
"crop_variety_id": 37582,
"crop_order": 1,
"end_date": "2023-01-09 21:00:00.000",
"yeargroup": 2022,
"crop_variety_name": "Colorado Chino",
"field_id": 258482,
"crop_id": 6,
"crop_name": "Cebada",
"cicle_id": 65847,
"rotation_uuid": "898430ea-fc6f-4a46-a7c6-9890ea702a41",
"ha": 140,
"start_date": "2022-08-09 21:00:00.000"
}

VARIETIES IN ROTATIONS

/rotations/variety/{rotation_uuid}

GET

Returns a list of available varieties for the crop associated with the rotation.

Response example:

{
"varieties": [
{
"variety_id": 37634,
"variety_name": "Variety 1"
},
{
"variety_id": 40138,
"variety_name": "Variety 2"
}
]
}

POST

This method is used to add one or more varieties to a rotation.

In the request body, include a list of the varieties to be added.

Example request body:

{
"varieties": [37634, 33305]
}
  • varieties: array of variety ids

DELETE

This method is used to remove a variety from a rotation.

/rotations/variety/{rotation_uuid}?variety_id={variety_id}
  • variety_id: ID of the variety to be removed.